service.go 791 B

123456789101112131415161718192021222324252627282930313233343536
  1. package service
  2. import (
  3. "context"
  4. )
  5. type CommentListVO struct {
  6. Id string
  7. CommentList []CommentVo
  8. }
  9. type CommentVo struct {
  10. Id string
  11. Desc string
  12. Score float32
  13. ReplyId string
  14. }
  15. type Service interface {
  16. GetCommentsList(ctx context.Context, id string) (CommentListVO, error)
  17. }
  18. func NewGoodsServiceImpl() Service {
  19. return &CommentsServiceImpl{}
  20. }
  21. type CommentsServiceImpl struct{}
  22. func (service *CommentsServiceImpl) GetCommentsList(ctx context.Context, id string) (CommentListVO, error) {
  23. comment1 := CommentVo{Id: "1", Desc: "comments", Score: 1.0, ReplyId: "0"}
  24. comment2 := CommentVo{Id: "2", Desc: "comments", Score: 1.0, ReplyId: "1"}
  25. list := []CommentVo{comment1, comment2}
  26. detail := CommentListVO{Id: id, CommentList: list}
  27. return detail, nil
  28. }