Pull latest changes from upstream/main (GitHub) including: - Purchase RPC service (proto, server, logic, models) - Gateway route updates for purchase endpoints - SQL migration and config updates Excludes deploy/bin/ pre-compiled arm64 binaries (builds use multi-stage Dockerfiles targeting amd64).
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package order
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
"muyu-apiserver/pkg/ctxdata"
|
|
"muyu-apiserver/rpc/purchase/purchaseservice"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UpdatePurchaseOrderLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewUpdatePurchaseOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdatePurchaseOrderLogic {
|
|
return &UpdatePurchaseOrderLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UpdatePurchaseOrderLogic) UpdatePurchaseOrder(req *types.UpdatePurchaseOrderReq) error {
|
|
id := ctxdata.GetPathId(l.ctx)
|
|
|
|
details := make([]*purchaseservice.PurchaseOrderDetailReq, 0, len(req.Details))
|
|
for _, d := range req.Details {
|
|
details = append(details, &purchaseservice.PurchaseOrderDetailReq{
|
|
ProductId: d.ProductId,
|
|
ProductName: d.ProductName,
|
|
Spec: d.Spec,
|
|
Color: d.Color,
|
|
Quantity: d.Quantity,
|
|
UnitPrice: d.UnitPrice,
|
|
Remark: d.Remark,
|
|
})
|
|
}
|
|
|
|
_, err := l.svcCtx.PurchaseRpc.UpdatePurchaseOrder(l.ctx, &purchaseservice.UpdatePurchaseOrderReq{
|
|
OrderId: id,
|
|
SupplierId: req.SupplierId,
|
|
OrderDate: req.OrderDate,
|
|
PurchaseBy: req.PurchaseBy,
|
|
Remark: req.Remark,
|
|
Details: details,
|
|
})
|
|
return err
|
|
}
|