43 lines
963 B
Go
43 lines
963 B
Go
|
|
package adjust
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"muyu-apiserver/gateway/internal/svc"
|
||
|
|
"muyu-apiserver/gateway/internal/types"
|
||
|
|
"muyu-apiserver/pkg/ctxdata"
|
||
|
|
"muyu-apiserver/rpc/inventory/pb"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type ApproveStockAdjustLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewApproveStockAdjustLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApproveStockAdjustLogic {
|
||
|
|
return &ApproveStockAdjustLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *ApproveStockAdjustLogic) ApproveStockAdjust(req *types.ApproveStockAdjustReq) (resp *types.IdResp, err error) {
|
||
|
|
id := ctxdata.GetPathId(l.ctx)
|
||
|
|
userId := ctxdata.GetUserId(l.ctx)
|
||
|
|
|
||
|
|
_, err = l.svcCtx.InventoryRpc.ApproveStockAdjust(l.ctx, &pb.ApproveStockAdjustReq{
|
||
|
|
AdjustId: id,
|
||
|
|
Approver: userId,
|
||
|
|
Action: req.Action,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &types.IdResp{Id: id}, nil
|
||
|
|
}
|