44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
|
|
package inbound
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"muyu-apiserver/gateway/internal/svc"
|
||
|
|
"muyu-apiserver/gateway/internal/types"
|
||
|
|
"muyu-apiserver/pkg/ctxdata"
|
||
|
|
"muyu-apiserver/rpc/production/productionservice"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type CreateInboundLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewCreateInboundLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateInboundLogic {
|
||
|
|
return &CreateInboundLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *CreateInboundLogic) CreateInbound(req *types.GatewayCreateInboundReq) (*types.IdResp, error) {
|
||
|
|
resp, err := l.svcCtx.ProductionRpc.CreateInbound(l.ctx, &productionservice.CreateInboundReq{
|
||
|
|
PlanId: req.PlanId,
|
||
|
|
ProductId: req.ProductId,
|
||
|
|
BatchNo: req.BatchNo,
|
||
|
|
Quantity: req.Quantity,
|
||
|
|
Rolls: req.Rolls,
|
||
|
|
PricePerMeter: req.PricePerMeter,
|
||
|
|
OperatorId: ctxdata.GetUserId(l.ctx),
|
||
|
|
Remark: req.Remark,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &types.IdResp{Id: resp.Id}, nil
|
||
|
|
}
|