link_breach.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 WrapLinkBreachHandler(ctx *gin.Context) {
  11. handler := newLinkBreachHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type linkBreachHandler struct {
  15. req *http_model.LinkBreachRequest
  16. resp *http_model.CommonResponse
  17. ctx *gin.Context
  18. }
  19. func (l linkBreachHandler) getContext() *gin.Context {
  20. return l.ctx
  21. }
  22. func (l linkBreachHandler) getResponse() interface{} {
  23. return l.resp
  24. }
  25. func (l linkBreachHandler) getRequest() interface{} {
  26. return l.req
  27. }
  28. func (l linkBreachHandler) run() {
  29. time := l.req.Time
  30. err := db.UpdateAutoTaskTime(l.ctx, time, 11)
  31. if err != nil {
  32. logrus.WithContext(l.ctx).Errorf("[linkBreachHandler] error AutoLinkBreach, err:%+v", err)
  33. util.HandlerPackErrorResp(l.resp, consts.ErrorInternal, consts.DefaultToast)
  34. return
  35. }
  36. l.resp.Message = "已启动链接违约自动处理服务"
  37. }
  38. func (l linkBreachHandler) checkParam() error {
  39. return nil
  40. }
  41. func newLinkBreachHandler(ctx *gin.Context) *linkBreachHandler {
  42. return &linkBreachHandler{
  43. req: http_model.NewLinkBreachRequest(),
  44. resp: http_model.NewLinkBreachResponse(),
  45. ctx: ctx,
  46. }
  47. }