followup_comment.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package plat
  2. import (
  3. "context"
  4. "dashoo.cn/opms_libary/myerrors"
  5. "dashoo.cn/common_definition/comm_def"
  6. "github.com/gogf/gf/frame/g"
  7. "github.com/gogf/gf/util/gvalid"
  8. model "dashoo.cn/micro/app/model/plat"
  9. server "dashoo.cn/micro/app/service/plat"
  10. )
  11. type FollowUpCommentHandler struct{}
  12. // GetList 获取列表
  13. // Swagger:FollowUpComment 跟进 评论列表
  14. func (h *FollowUpCommentHandler) GetList(ctx context.Context, req *model.SearchPlatFollowupCommentReq, rsp *comm_def.CommonMsg) error {
  15. followupCommentService, err := server.NewFollowupCommentService(ctx)
  16. if err != nil {
  17. return err
  18. }
  19. g.Log().Info("搜索值", req)
  20. total, list, err := followupCommentService.GetList(req)
  21. if err != nil {
  22. return err
  23. }
  24. rsp.Data = g.Map{"list": list, "total": total}
  25. return nil
  26. }
  27. // GetNeedReplyComments 获取本人需要回复的评论列表
  28. // Swagger:FollowUpComment 跟进 获取本人需要回复的评论列表
  29. func (h *FollowUpCommentHandler) GetNeedReplyComments(ctx context.Context, req *model.SearchNeedReplyCommentsReq, rsp *comm_def.CommonMsg) error {
  30. followupCommentService, err := server.NewFollowupCommentService(ctx)
  31. if err != nil {
  32. return err
  33. }
  34. g.Log().Info("搜索值", req)
  35. total, list, err := followupCommentService.NeedReplyList(req)
  36. if err != nil {
  37. return err
  38. }
  39. rsp.Data = g.Map{"list": list, "total": total}
  40. return nil
  41. }
  42. // GetNeedReplyCount 获取本人需要回复的评论数量
  43. // Swagger:FollowUpComment 跟进 获取本人需要回复的评论数量
  44. func (h *FollowUpCommentHandler) GetNeedReplyCount(ctx context.Context, req *model.SearchNeedReplyCommentsReq, rsp *comm_def.CommonMsg) error {
  45. followupCommentService, err := server.NewFollowupCommentService(ctx)
  46. if err != nil {
  47. return err
  48. }
  49. g.Log().Info("搜索值", req)
  50. total, err := followupCommentService.NeedReplyCount(req)
  51. if err != nil {
  52. return err
  53. }
  54. rsp.Data = g.Map{"total": total}
  55. return nil
  56. }
  57. // GetLatestComments 获取最新50条数据
  58. // Swagger:FollowUpComment 跟进 获取最新50条数据
  59. func (h *FollowUpCommentHandler) GetLatestComments(ctx context.Context, req *model.SearchPlatFollowupCommentReq, rsp *comm_def.CommonMsg) error {
  60. followupCommentService, err := server.NewFollowupCommentService(ctx)
  61. if err != nil {
  62. return err
  63. }
  64. g.Log().Info("搜索值", req)
  65. total, list, err := followupCommentService.LatestComments(req)
  66. if err != nil {
  67. return err
  68. }
  69. rsp.Data = g.Map{"list": list, "total": total}
  70. return nil
  71. }
  72. // Create 添加跟进评论
  73. // Swagger:FollowUpComment 跟进 评论添加
  74. func (h *FollowUpCommentHandler) Create(ctx context.Context, req *model.AddPlatFollowupCommentReq, rsp *comm_def.CommonMsg) error {
  75. // 参数校验
  76. if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
  77. return err
  78. }
  79. followupCommentService, err := server.NewFollowupCommentService(ctx)
  80. if err != nil {
  81. return err
  82. }
  83. err = followupCommentService.Create(req)
  84. if err != nil {
  85. return err
  86. }
  87. return nil
  88. }
  89. // Reply 回复跟进评论
  90. // Swagger:FollowUpComment 跟进 回复跟进评论
  91. func (h *FollowUpCommentHandler) Reply(ctx context.Context, req *model.AddPlatFollowupCommentReq, rsp *comm_def.CommonMsg) error {
  92. // 参数校验
  93. if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
  94. return err
  95. }
  96. // 参数校验
  97. if req.Pid == 0 {
  98. return myerrors.TipsError("回复的评论Id不能为空")
  99. }
  100. followupCommentService, err := server.NewFollowupCommentService(ctx)
  101. if err != nil {
  102. return err
  103. }
  104. err = followupCommentService.Reply(req)
  105. if err != nil {
  106. return err
  107. }
  108. return nil
  109. }