SelectionInvalid.go 1.4 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 WrapSelectionInvalidHandler(ctx *gin.Context) {
  11. handler := newSelectionInvalidHandler(ctx)
  12. println(handler)
  13. BaseRun(handler)
  14. }
  15. type selectioninvalidHandler struct {
  16. req *http_model.SelectionInvalid
  17. resp *http_model.CommonResponse
  18. ctx *gin.Context
  19. }
  20. func (i selectioninvalidHandler) getContext() *gin.Context {
  21. return i.ctx
  22. }
  23. func (i selectioninvalidHandler) getResponse() interface{} {
  24. return i.resp
  25. }
  26. func (i selectioninvalidHandler) getRequest() interface{} {
  27. return i.req
  28. }
  29. func (i selectioninvalidHandler) run() {
  30. println("selectioninvalid===============")
  31. time := i.req.Time
  32. err := db.UpdateAutoTaskTime(i.ctx, time, 13)
  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 selectioninvalidHandler) checkParam() error {
  41. return nil
  42. }
  43. func newSelectionInvalidHandler(ctx *gin.Context) *selectioninvalidHandler {
  44. return &selectioninvalidHandler{
  45. ctx: ctx,
  46. req: http_model.NewSelectionInvalidRequest(),
  47. resp: http_model.NewSelectionInvalidResponse(),
  48. }
  49. }