task_comment.go 1.1 KB

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