local_task_count.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package handler
  2. import (
  3. "youngee_b_api/consts"
  4. "youngee_b_api/model/http_model"
  5. "youngee_b_api/service"
  6. "youngee_b_api/util"
  7. "github.com/sirupsen/logrus"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func WrapLocalTaskCountHandler(ctx *gin.Context) {
  11. handler := newLocalTaskCountHandler(ctx)
  12. baseRun(handler)
  13. }
  14. func newLocalTaskCountHandler(ctx *gin.Context) *LocalTaskCountHandler {
  15. return &LocalTaskCountHandler{
  16. req: http_model.NewLocalTaskCountRequest(),
  17. resp: http_model.NewLocalTaskCountResponse(),
  18. ctx: ctx,
  19. }
  20. }
  21. type LocalTaskCountHandler struct {
  22. req *http_model.LocalTaskCountRequest
  23. resp *http_model.CommonResponse
  24. ctx *gin.Context
  25. }
  26. func (p *LocalTaskCountHandler) getContext() *gin.Context {
  27. return p.ctx
  28. }
  29. func (p *LocalTaskCountHandler) getResponse() interface{} {
  30. return p.resp
  31. }
  32. func (p *LocalTaskCountHandler) getRequest() interface{} {
  33. return p.req
  34. }
  35. func (p *LocalTaskCountHandler) run() {
  36. data, err := service.SLocalLife.CountLocalTask(p.ctx, p.req)
  37. if err != nil {
  38. logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err)
  39. util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
  40. logrus.Info("ChangeTaskStatus fail,req:%+v", p.req)
  41. p.resp.Message = "err"
  42. p.resp.Status = 40000
  43. return
  44. }
  45. p.resp.Message = "ok"
  46. p.resp.Data = data
  47. p.resp.Status = 20000
  48. }
  49. func (p *LocalTaskCountHandler) checkParam() error {
  50. return nil
  51. }