getInvoiceRecord.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_b_api/consts"
  6. "youngee_b_api/db"
  7. "youngee_b_api/model/http_model"
  8. "youngee_b_api/util"
  9. )
  10. func WrapGetInvoiceRecordHandler(ctx *gin.Context) {
  11. handler := newGetInvoiceRecordHandler(ctx)
  12. baseRun(handler)
  13. }
  14. type GetInvoiceRecordHandler struct {
  15. ctx *gin.Context
  16. req *http_model.GetInvoiceRecordRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (g GetInvoiceRecordHandler) getContext() *gin.Context {
  20. return g.ctx
  21. }
  22. func (g GetInvoiceRecordHandler) getResponse() interface{} {
  23. return g.resp
  24. }
  25. func (g GetInvoiceRecordHandler) getRequest() interface{} {
  26. return g.req
  27. }
  28. func (g GetInvoiceRecordHandler) run() {
  29. data, err := db.GetInvoiceRecords(g.ctx, g.req)
  30. if err != nil {
  31. // 数据库查询失败,返回5001
  32. logrus.Errorf("[GetInvoiceRecordHandler] call GetInvoiceRecords err:%+v\n", err)
  33. util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "")
  34. logrus.Info("GetInvoiceRecords fail,req:%+v", g.req)
  35. return
  36. }
  37. g.resp.Data = data
  38. }
  39. func (g GetInvoiceRecordHandler) checkParam() error {
  40. return nil
  41. }
  42. func newGetInvoiceRecordHandler(ctx *gin.Context) *GetInvoiceRecordHandler {
  43. return &GetInvoiceRecordHandler{
  44. ctx: ctx,
  45. req: http_model.NewGetInvoiceRecordRequest(),
  46. resp: http_model.NewGetInvoiceRecordResponse(),
  47. }
  48. }