refusewithdraw.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package handler
  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 WrapRefuseWithdrawHandler(ctx *gin.Context) {
  11. handler := newRefuseWithdrawHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type RefuseWithdrawHandler struct {
  15. ctx *gin.Context
  16. req *http_model.RefuseWithdrawRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (c RefuseWithdrawHandler) getContext() *gin.Context {
  20. return c.ctx
  21. }
  22. func (c RefuseWithdrawHandler) getResponse() interface{} {
  23. return c.resp
  24. }
  25. func (c RefuseWithdrawHandler) getRequest() interface{} {
  26. return c.req
  27. }
  28. func (c RefuseWithdrawHandler) run() {
  29. err := db.RefuseWithdraw(c.ctx, c.req)
  30. if err != nil {
  31. // 数据库查询失败,返回5001
  32. logrus.Errorf("[RefuseWithdrawHandler] call RefuseWithdraw err:%+v\n", err)
  33. util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
  34. logrus.Info("RefuseWithdraw fail,req:%+v", c.req)
  35. return
  36. }
  37. c.resp.Message = "拒绝成功"
  38. }
  39. func (c RefuseWithdrawHandler) checkParam() error {
  40. return nil
  41. }
  42. func newRefuseWithdrawHandler(ctx *gin.Context) *RefuseWithdrawHandler {
  43. return &RefuseWithdrawHandler{
  44. ctx: ctx,
  45. req: http_model.NewRefuseWithdrawRequest(),
  46. resp: http_model.NewRefuseWithdrawResponse(),
  47. }
  48. }