getinvoiceinfo.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 WrapGetInvoiceInfoHandler(ctx *gin.Context) {
  11. handler := newGetInvoiceInfoHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type GetInvoiceInfoHandler struct {
  15. ctx *gin.Context
  16. req *http_model.GetInvoiceInfoRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (g GetInvoiceInfoHandler) getContext() *gin.Context {
  20. return g.ctx
  21. }
  22. func (g GetInvoiceInfoHandler) getResponse() interface{} {
  23. return g.resp
  24. }
  25. func (g GetInvoiceInfoHandler) getRequest() interface{} {
  26. return g.req
  27. }
  28. func (g GetInvoiceInfoHandler) run() {
  29. req := g.req
  30. data, err := db.GetInvoiceInfo(g.ctx, *req)
  31. if err != nil {
  32. logrus.WithContext(g.ctx).Errorf("[GetInvoiceInfoHandler] error GetInvoiceInfo, err:%+v", err)
  33. util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
  34. return
  35. }
  36. g.resp.Data = data
  37. g.resp.Message = "OK"
  38. g.resp.Status = consts.ErrorSuccess
  39. }
  40. func (g GetInvoiceInfoHandler) checkParam() error {
  41. return nil
  42. }
  43. func newGetInvoiceInfoHandler(ctx *gin.Context) *GetInvoiceInfoHandler {
  44. return &GetInvoiceInfoHandler{
  45. ctx: ctx,
  46. req: http_model.NewGetInvoiceInfoRequest(),
  47. resp: http_model.NewGetInvoiceInfoResponse(),
  48. }
  49. }