SpecialTaskFinishDataList.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package handler
  2. import (
  3. "errors"
  4. "fmt"
  5. "youngee_b_api/consts"
  6. "youngee_b_api/model/http_model"
  7. "youngee_b_api/pack"
  8. "youngee_b_api/service"
  9. "youngee_b_api/util"
  10. "github.com/gin-gonic/gin"
  11. "github.com/sirupsen/logrus"
  12. )
  13. func WrapSpecialTaskFinishDataListHandler(ctx *gin.Context) {
  14. handler := newSpecialTaskFinishDataListHandler(ctx)
  15. baseRun(handler)
  16. }
  17. func newSpecialTaskFinishDataListHandler(ctx *gin.Context) *SpecialTaskFinishDataListHandler {
  18. return &SpecialTaskFinishDataListHandler{
  19. req: http_model.NewSpecialTaskFinishDataListRequest(),
  20. resp: http_model.NewSpecialTaskFinishDataListResponse(),
  21. ctx: ctx,
  22. }
  23. }
  24. type SpecialTaskFinishDataListHandler struct {
  25. req *http_model.SpecialTaskFinishDataListRequest
  26. resp *http_model.CommonResponse
  27. ctx *gin.Context
  28. }
  29. func (h *SpecialTaskFinishDataListHandler) getRequest() interface{} {
  30. return h.req
  31. }
  32. func (h *SpecialTaskFinishDataListHandler) getContext() *gin.Context {
  33. return h.ctx
  34. }
  35. func (h *SpecialTaskFinishDataListHandler) getResponse() interface{} {
  36. return h.resp
  37. }
  38. func (h *SpecialTaskFinishDataListHandler) run() {
  39. conditions := pack.HttpSpecialTaskFinishDataListRequestToCondition(h.req)
  40. data, err := service.SpecialTask.GetSpecialTaskFinishDataList(h.ctx, h.req.ProjectId, h.req.PageSize, h.req.PageNum, conditions)
  41. if err != nil {
  42. logrus.WithContext(h.ctx).Errorf("[TaskLogisticsListHandler] error GetProjectTaskList, err:%+v", err)
  43. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
  44. return
  45. }
  46. h.resp.Data = data
  47. }
  48. func (h *SpecialTaskFinishDataListHandler) checkParam() error {
  49. var errs []error
  50. if h.req.PageNum < 0 || h.req.PageSize <= 0 {
  51. errs = append(errs, errors.New("page param error"))
  52. }
  53. h.req.PageNum--
  54. h.req.ProjectId = util.IsNull(h.req.ProjectId)
  55. if len(errs) != 0 {
  56. return fmt.Errorf("check param errs:%+v", errs)
  57. }
  58. return nil
  59. }