2026-06-15 09:20:56 +08:00
|
|
|
package supplier
|
|
|
|
|
|
|
|
|
|
import (
|
2026-06-18 18:24:35 +09:00
|
|
|
"context"
|
2026-06-15 09:20:56 +08:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
2026-06-18 18:24:35 +09:00
|
|
|
"github.com/zeromicro/go-zero/rest/pathvar"
|
2026-06-15 09:20:56 +08:00
|
|
|
"muyu-apiserver/gateway/internal/logic/purchase/supplier"
|
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
|
|
|
"muyu-apiserver/gateway/internal/types"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func UpdateSupplierHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
var req types.UpdateSupplierReq
|
|
|
|
|
if err := httpx.Parse(r, &req); err != nil {
|
|
|
|
|
httpx.ErrorCtx(r.Context(), w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-18 18:24:35 +09:00
|
|
|
ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"])
|
|
|
|
|
l := supplier.NewUpdateSupplierLogic(ctx, svcCtx)
|
2026-06-15 09:20:56 +08:00
|
|
|
err := l.UpdateSupplier(&req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
httpx.ErrorCtx(r.Context(), w, err)
|
|
|
|
|
} else {
|
|
|
|
|
httpx.OkJsonCtx(r.Context(), w, nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|