123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package handler
- import (
- "github.com/gin-gonic/gin"
- "github.com/sirupsen/logrus"
- "youngee_b_api/consts"
- "youngee_b_api/db"
- "youngee_b_api/model/http_model"
- "youngee_b_api/util"
- )
- 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() {
- data, err := db.GetInvoiceRecords(g.ctx, g.req)
- 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(),
- }
- }
|