pay_sum.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package handler
  2. import (
  3. "youngee_b_api/consts"
  4. "youngee_b_api/model/http_model"
  5. "youngee_b_api/service"
  6. "youngee_b_api/util"
  7. "github.com/gin-gonic/gin"
  8. "github.com/sirupsen/logrus"
  9. log "github.com/sirupsen/logrus"
  10. )
  11. func WrapPaySumHandler(ctx *gin.Context) {
  12. handler := newPaySumHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newPaySumHandler(ctx *gin.Context) *PaySumHandler {
  16. return &PaySumHandler{
  17. req: http_model.NewPaySumRequest(),
  18. resp: http_model.NewPaySumResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type PaySumHandler struct {
  23. req *http_model.PaySumRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *PaySumHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *PaySumHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *PaySumHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *PaySumHandler) run() {
  37. data := http_model.PaySumRequest{}
  38. data = *h.req
  39. //auth := middleware.GetSessionAuth(h.ctx)
  40. //enterpriseID := auth.EnterpriseID
  41. res, err := service.Pay.GetPaysum(h.ctx, data)
  42. if err != nil {
  43. // 数据库查询失败,返回5001
  44. logrus.Errorf("[FindAllProductHandler] call FindAll err:%+v\n", err)
  45. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  46. log.Info("FindAllProduct fail,req:%+v", h.req)
  47. return
  48. }
  49. // h.resp.Message = "查询成功"
  50. h.resp.Data = res
  51. }
  52. func (h *PaySumHandler) checkParam() error {
  53. return nil
  54. }