pay_sum.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/model/http_model"
  7. "youngee_m_api/service"
  8. "youngee_m_api/util"
  9. )
  10. func WrapPaySumHandler(ctx *gin.Context) {
  11. handler := newPaySumHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. func newPaySumHandler(ctx *gin.Context) *PaySumHandler {
  15. return &PaySumHandler{
  16. req: http_model.NewPaySumRequest(),
  17. resp: http_model.NewPaySumResponse(),
  18. ctx: ctx,
  19. }
  20. }
  21. type PaySumHandler struct {
  22. req *http_model.PaySumRequest
  23. resp *http_model.CommonResponse
  24. ctx *gin.Context
  25. }
  26. func (h *PaySumHandler) getRequest() interface{} {
  27. return h.req
  28. }
  29. func (h *PaySumHandler) getContext() *gin.Context {
  30. return h.ctx
  31. }
  32. func (h *PaySumHandler) getResponse() interface{} {
  33. return h.resp
  34. }
  35. func (h *PaySumHandler) run() {
  36. data := http_model.PaySumRequest{}
  37. data = *h.req
  38. res, err := service.Pay.GetPaysum(h.ctx, data)
  39. if err != nil {
  40. // 数据库查询失败,返回5001
  41. logrus.Errorf("[FindAllProductHandler] call FindAll err:%+v\n", err)
  42. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  43. logrus.Info("FindAllProduct fail,req:%+v", h.req)
  44. return
  45. }
  46. // h.resp.Message = "查询成功"
  47. h.resp.Data = res
  48. }
  49. func (h *PaySumHandler) checkParam() error {
  50. return nil
  51. }