* feat: support product yarn batches * feat: improve product yarn ratio workflow * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
33 lines
898 B
Go
33 lines
898 B
Go
// Code scaffolded by goctl. Safe to edit.
|
|
|
|
package productbatch
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
|
"github.com/zeromicro/go-zero/rest/pathvar"
|
|
"muyu-apiserver/gateway/internal/logic/inventory/productbatch"
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
)
|
|
|
|
func CreateProductBatchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req types.CreateProductBatchReq
|
|
if err := httpx.Parse(r, &req); err != nil {
|
|
httpx.ErrorCtx(r.Context(), w, err)
|
|
return
|
|
}
|
|
ctx := context.WithValue(r.Context(), "pathId", pathvar.Vars(r)["id"])
|
|
l := productbatch.NewCreateProductBatchLogic(ctx, svcCtx)
|
|
resp, err := l.CreateProductBatch(&req)
|
|
if err != nil {
|
|
httpx.ErrorCtx(r.Context(), w, err)
|
|
} else {
|
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
}
|
|
}
|
|
}
|