pay_sum.go 1.4 KB

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