task_comment.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package plat
  2. import (
  3. "context"
  4. "dashoo.cn/common_definition/comm_def"
  5. model "dashoo.cn/micro/app/model/plat"
  6. server "dashoo.cn/micro/app/service/plat"
  7. "dashoo.cn/opms_libary/myerrors"
  8. "github.com/gogf/gf/frame/g"
  9. "github.com/gogf/gf/util/gvalid"
  10. )
  11. type TaskCommentHandler struct{}
  12. // GetList 获取列表
  13. func (h *TaskCommentHandler) GetList(ctx context.Context, req *model.SearchPlatTaskCommentReq, rsp *comm_def.CommonMsg) error {
  14. taskCommentService, err := server.NewTaskCommentService(ctx)
  15. if err != nil {
  16. g.Log().Error(err)
  17. return err
  18. }
  19. g.Log().Info("搜索值", req)
  20. total, list, err := taskCommentService.GetList(req)
  21. _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
  22. if err != nil {
  23. g.Log().Error(err)
  24. return err
  25. }
  26. rsp.Data = g.Map{"list": list, "total": total}
  27. return nil
  28. }
  29. // Create 添加任务评论
  30. func (h *TaskCommentHandler) Create(ctx context.Context, req *model.AddPlatTaskCommentReq, rsp *comm_def.CommonMsg) error {
  31. // 参数校验
  32. if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
  33. return err
  34. }
  35. taskCommentService, err := server.NewTaskCommentService(ctx)
  36. if err != nil {
  37. g.Log().Error(err)
  38. return err
  39. }
  40. err = taskCommentService.Create(req)
  41. _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
  42. if err != nil {
  43. g.Log().Error(err)
  44. return err
  45. }
  46. return nil
  47. }