package handler import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "youngee_b_api/consts" "youngee_b_api/db" "youngee_b_api/middleware" "youngee_b_api/model/http_model" "youngee_b_api/util" ) func WrapOperateReceiveInfoHandler(ctx *gin.Context) { handler := newOperateReceiveInfoHandler(ctx) baseRun(handler) } type OperateReceiveInfo struct { ctx *gin.Context req *http_model.OperateReceiveInfoRequest resp *http_model.CommonResponse } func (o OperateReceiveInfo) getContext() *gin.Context { return o.ctx } func (o OperateReceiveInfo) getResponse() interface{} { return o.resp } func (o OperateReceiveInfo) getRequest() interface{} { return o.req } func (o OperateReceiveInfo) run() { auth := middleware.GetSessionAuth(o.ctx) enterpriseID := auth.EnterpriseID err := db.OperateReceiveInfo(o.ctx, enterpriseID, o.req) if err != nil { // 数据库查询失败,返回5001 logrus.Errorf("[OperateReceiveInfo] call OperateReceiveInfo err:%+v\n", err) util.HandlerPackErrorResp(o.resp, consts.ErrorInternal, "") logrus.Info("OperateReceiveInfo fail,req:%+v", o.req) return } if o.req.OperateType == 2 { o.resp.Message = "已删除该发票信息" } else { o.resp.Message = "修改发票信息成功" } } func (o OperateReceiveInfo) checkParam() error { return nil } func newOperateReceiveInfoHandler(ctx *gin.Context) *OperateReceiveInfo { return &OperateReceiveInfo{ ctx: ctx, req: http_model.NewOperateReceiveInfoRequest(), resp: http_model.NewOperateReceiveInfoResponse(), } }