contract_breach.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 WrapContractBreachHandler(ctx *gin.Context) {
  11. handler := newContractBreachHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. func newContractBreachHandler(ctx *gin.Context) *ContractBreachHandler {
  15. return &ContractBreachHandler{
  16. ctx: ctx,
  17. req: http_model.NewContractBreachRequest(),
  18. resp: http_model.NewContractBreachResponse(),
  19. }
  20. }
  21. type ContractBreachHandler struct {
  22. ctx *gin.Context
  23. req *http_model.ContractBreachRequest
  24. resp *http_model.CommonResponse
  25. }
  26. func (c ContractBreachHandler) getContext() *gin.Context {
  27. return c.ctx
  28. }
  29. func (c ContractBreachHandler) getResponse() interface{} {
  30. return c.resp
  31. }
  32. func (c ContractBreachHandler) getRequest() interface{} {
  33. return c.req
  34. }
  35. func (c ContractBreachHandler) run() {
  36. err := db.ContractBreach(c.ctx, c.req)
  37. if err != nil {
  38. logrus.WithContext(c.ctx).Errorf("[ContractBreachHandler] error ContractBreach, err:%+v", err)
  39. util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, consts.DefaultToast)
  40. return
  41. }
  42. c.resp.Message = "违约记录处理成功"
  43. }
  44. func (c ContractBreachHandler) checkParam() error {
  45. return nil
  46. }