invalid.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package operate
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_m_api/consts"
  6. "youngee_m_api/db"
  7. "youngee_m_api/model/http_model"
  8. "youngee_m_api/util"
  9. )
  10. func WrapInvalidHandler(ctx *gin.Context) {
  11. handler := newInvalidHandler(ctx)
  12. println(handler)
  13. BaseRun(handler)
  14. }
  15. type invalidHandler struct {
  16. req *http_model.InvalidRequest
  17. resp *http_model.CommonResponse
  18. ctx *gin.Context
  19. }
  20. func (i invalidHandler) getContext() *gin.Context {
  21. return i.ctx
  22. }
  23. func (i invalidHandler) getResponse() interface{} {
  24. return i.resp
  25. }
  26. func (i invalidHandler) getRequest() interface{} {
  27. return i.req
  28. }
  29. func (i invalidHandler) run() {
  30. println("invalidHandle-----------------------is")
  31. time := i.req.Time
  32. err := db.UpdateAutoTaskTime(i.ctx, time, 7)
  33. if err != nil {
  34. logrus.WithContext(i.ctx).Errorf("[invalidHandler] error invalid, err:%+v", err)
  35. util.HandlerPackErrorResp(i.resp, consts.ErrorInternal, consts.DefaultToast)
  36. return
  37. }
  38. i.resp.Message = "已启动全流程项目失效自动处理服务"
  39. }
  40. func (i invalidHandler) checkParam() error {
  41. return nil
  42. }
  43. func newInvalidHandler(ctx *gin.Context) *invalidHandler {
  44. return &invalidHandler{
  45. ctx: ctx,
  46. req: http_model.NewInvalidRequest(),
  47. resp: http_model.NewInvalidResponse(),
  48. }
  49. }