diff --git a/gateway/internal/handler/purchase/order/cancelpurchaseorderhandler.go b/gateway/internal/handler/purchase/order/cancelpurchaseorderhandler.go index 7bcff9c..43219e8 100644 --- a/gateway/internal/handler/purchase/order/cancelpurchaseorderhandler.go +++ b/gateway/internal/handler/purchase/order/cancelpurchaseorderhandler.go @@ -1,16 +1,19 @@ package order import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/order" "muyu-apiserver/gateway/internal/svc" ) func CancelPurchaseOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - l := order.NewCancelPurchaseOrderLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := order.NewCancelPurchaseOrderLogic(ctx, svcCtx) err := l.CancelPurchaseOrder() if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/order/confirmpurchaseorderhandler.go b/gateway/internal/handler/purchase/order/confirmpurchaseorderhandler.go index c4e8c72..05ed1d3 100644 --- a/gateway/internal/handler/purchase/order/confirmpurchaseorderhandler.go +++ b/gateway/internal/handler/purchase/order/confirmpurchaseorderhandler.go @@ -1,16 +1,19 @@ package order import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/order" "muyu-apiserver/gateway/internal/svc" ) func ConfirmPurchaseOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - l := order.NewConfirmPurchaseOrderLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := order.NewConfirmPurchaseOrderLogic(ctx, svcCtx) err := l.ConfirmPurchaseOrder() if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/order/getpurchaseorderhandler.go b/gateway/internal/handler/purchase/order/getpurchaseorderhandler.go index 1a5a35e..e7cc0dd 100644 --- a/gateway/internal/handler/purchase/order/getpurchaseorderhandler.go +++ b/gateway/internal/handler/purchase/order/getpurchaseorderhandler.go @@ -1,16 +1,19 @@ package order import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/order" "muyu-apiserver/gateway/internal/svc" ) func GetPurchaseOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - l := order.NewGetPurchaseOrderLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := order.NewGetPurchaseOrderLogic(ctx, svcCtx) resp, err := l.GetPurchaseOrder() if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/order/updatepurchaseorderhandler.go b/gateway/internal/handler/purchase/order/updatepurchaseorderhandler.go index 00a6b6c..5e35fdf 100644 --- a/gateway/internal/handler/purchase/order/updatepurchaseorderhandler.go +++ b/gateway/internal/handler/purchase/order/updatepurchaseorderhandler.go @@ -1,9 +1,11 @@ package order import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/order" "muyu-apiserver/gateway/internal/svc" "muyu-apiserver/gateway/internal/types" @@ -17,7 +19,8 @@ func UpdatePurchaseOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return } - l := order.NewUpdatePurchaseOrderLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := order.NewUpdatePurchaseOrderLogic(ctx, svcCtx) err := l.UpdatePurchaseOrder(&req) if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/receipt/confirmpurchasereceipthandler.go b/gateway/internal/handler/purchase/receipt/confirmpurchasereceipthandler.go index a998f0b..23e2337 100644 --- a/gateway/internal/handler/purchase/receipt/confirmpurchasereceipthandler.go +++ b/gateway/internal/handler/purchase/receipt/confirmpurchasereceipthandler.go @@ -1,16 +1,19 @@ package receipt import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/receipt" "muyu-apiserver/gateway/internal/svc" ) func ConfirmPurchaseReceiptHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - l := receipt.NewConfirmPurchaseReceiptLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := receipt.NewConfirmPurchaseReceiptLogic(ctx, svcCtx) err := l.ConfirmPurchaseReceipt() if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/receipt/getpurchasereceipthandler.go b/gateway/internal/handler/purchase/receipt/getpurchasereceipthandler.go index 830e0bf..d811fbf 100644 --- a/gateway/internal/handler/purchase/receipt/getpurchasereceipthandler.go +++ b/gateway/internal/handler/purchase/receipt/getpurchasereceipthandler.go @@ -1,16 +1,19 @@ package receipt import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/receipt" "muyu-apiserver/gateway/internal/svc" ) func GetPurchaseReceiptHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - l := receipt.NewGetPurchaseReceiptLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := receipt.NewGetPurchaseReceiptLogic(ctx, svcCtx) resp, err := l.GetPurchaseReceipt() if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/supplier/deletesupplierhandler.go b/gateway/internal/handler/purchase/supplier/deletesupplierhandler.go index ac1cee5..c149af2 100644 --- a/gateway/internal/handler/purchase/supplier/deletesupplierhandler.go +++ b/gateway/internal/handler/purchase/supplier/deletesupplierhandler.go @@ -1,16 +1,19 @@ package supplier import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/supplier" "muyu-apiserver/gateway/internal/svc" ) func DeleteSupplierHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - l := supplier.NewDeleteSupplierLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := supplier.NewDeleteSupplierLogic(ctx, svcCtx) err := l.DeleteSupplier() if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/supplier/getsupplierhandler.go b/gateway/internal/handler/purchase/supplier/getsupplierhandler.go index 11e10c3..15223a6 100644 --- a/gateway/internal/handler/purchase/supplier/getsupplierhandler.go +++ b/gateway/internal/handler/purchase/supplier/getsupplierhandler.go @@ -1,16 +1,19 @@ package supplier import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/supplier" "muyu-apiserver/gateway/internal/svc" ) func GetSupplierHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - l := supplier.NewGetSupplierLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := supplier.NewGetSupplierLogic(ctx, svcCtx) resp, err := l.GetSupplier() if err != nil { httpx.ErrorCtx(r.Context(), w, err) diff --git a/gateway/internal/handler/purchase/supplier/updatesupplierhandler.go b/gateway/internal/handler/purchase/supplier/updatesupplierhandler.go index 8c9c6bd..19a3637 100644 --- a/gateway/internal/handler/purchase/supplier/updatesupplierhandler.go +++ b/gateway/internal/handler/purchase/supplier/updatesupplierhandler.go @@ -1,9 +1,11 @@ package supplier import ( + "context" "net/http" "github.com/zeromicro/go-zero/rest/httpx" + "github.com/zeromicro/go-zero/rest/pathvar" "muyu-apiserver/gateway/internal/logic/purchase/supplier" "muyu-apiserver/gateway/internal/svc" "muyu-apiserver/gateway/internal/types" @@ -17,7 +19,8 @@ func UpdateSupplierHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return } - l := supplier.NewUpdateSupplierLogic(r.Context(), svcCtx) + ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"]) + l := supplier.NewUpdateSupplierLogic(ctx, svcCtx) err := l.UpdateSupplier(&req) if err != nil { httpx.ErrorCtx(r.Context(), w, err)