local_task_count.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 = "状态变更失败"
  42. p.resp.Status = 40000
  43. return
  44. }
  45. p.resp.Message = "ok"
  46. p.resp.Data = data
  47. }
  48. func (p *LocalTaskCountHandler) checkParam() error {
  49. return nil
  50. }