diff --git a/internal/biz/warning_budget.go b/internal/biz/warning_budget.go index f2fc2d2..0618135 100644 --- a/internal/biz/warning_budget.go +++ b/internal/biz/warning_budget.go @@ -15,9 +15,9 @@ import ( "voucher/internal/biz/vo" ) -func (this *VoucherBiz) Warning(ctx context.Context, batchNo string) error { +func (this *VoucherBiz) Warning(ctx context.Context, id int32) error { - product, err := this.ProductRepo.GetByBatchNo(ctx, batchNo) + product, err := this.ProductRepo.GetById(ctx, id) if err != nil { return err } diff --git a/internal/server/http.go b/internal/server/http.go index 63de995..505217d 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -43,7 +43,7 @@ func NewHTTPServer( srv.Route("/voucher/").POST("pushWechatQuery", cmb.PushWechatQuery) srv.Route("/voucher/").POST("timeSliceQueryPush", cmb.TimeSliceQueryPush) srv.Route("/voucher/").POST("pushWechatRetry/{batch_no}", cmb.PushWechatRetry) - srv.Route("/voucher/").POST("warningBudget/{batch_no}", cmb.WarningBudget) + srv.Route("/voucher/").POST("warningBudget/{id}", cmb.WarningBudget) v1.RegisterCmbHTTPServer(srv, cmb) diff --git a/internal/service/script.go b/internal/service/script.go index 9c99afc..dd1cdd6 100644 --- a/internal/service/script.go +++ b/internal/service/script.go @@ -136,17 +136,21 @@ func (this *CmbService) PushWechatRetry(ctx http.Context) error { func (this *CmbService) WarningBudget(ctx http.Context) error { - batchNo := ctx.Vars().Get("batch_no") - if batchNo == "" { - return fmt.Errorf("batch_no is empty") + id := ctx.Vars().Get("id") + if id == "" { + return fmt.Errorf("id is empty") } - err := this.VoucherBiz.Warning(ctx, batchNo) + int64Id, err := strconv.ParseInt(id, 10, 32) if err != nil { return err } + if err = this.VoucherBiz.Warning(ctx, int32(int64Id)); err != nil { + return err + } + return ctx.JSON(http2.StatusOK, map[string]interface{}{ - "data": batchNo, + "data": id, }) }