package handler import ( "youngee_b_api/consts" "youngee_b_api/db" "youngee_b_api/middleware" "youngee_b_api/model/http_model" "youngee_b_api/util" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" ) func WrapGetInvoiceRecordHandler(ctx *gin.Context) { handler := newGetInvoiceRecordHandler(ctx) baseRun(handler) } type GetInvoiceRecordHandler struct { ctx *gin.Context req *http_model.GetInvoiceRecordRequest resp *http_model.CommonResponse } func (g GetInvoiceRecordHandler) getContext() *gin.Context { return g.ctx } func (g GetInvoiceRecordHandler) getResponse() interface{} { return g.resp } func (g GetInvoiceRecordHandler) getRequest() interface{} { return g.req } func (g GetInvoiceRecordHandler) run() { enterpriseID := middleware.GetSessionAuth(g.ctx).EnterpriseID data, err := db.GetInvoiceRecords(g.ctx, g.req, enterpriseID) if err != nil { // 数据库查询失败,返回5001 logrus.Errorf("[GetInvoiceRecordHandler] call GetInvoiceRecords err:%+v\n", err) util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "") logrus.Info("GetInvoiceRecords fail,req:%+v", g.req) return } g.resp.Data = data } func (g GetInvoiceRecordHandler) checkParam() error { return nil } func newGetInvoiceRecordHandler(ctx *gin.Context) *GetInvoiceRecordHandler { return &GetInvoiceRecordHandler{ ctx: ctx, req: http_model.NewGetInvoiceRecordRequest(), resp: http_model.NewGetInvoiceRecordResponse(), } }