39 lines
831 B
Go
39 lines
831 B
Go
|
|
package product
|
||
|
|
|
||
|
|
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 SavePansLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewSavePansLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SavePansLogic {
|
||
|
|
return &SavePansLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *SavePansLogic) SavePans(req *types.SavePansReq) (resp *types.IdResp, err error) {
|
||
|
|
id := ctxdata.GetPathId(l.ctx)
|
||
|
|
_, err = l.svcCtx.InventoryRpc.SavePans(l.ctx, &pb.SavePansReq{
|
||
|
|
ProductId: id,
|
||
|
|
Pans: panInputsToPb(req.Pans),
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &types.IdResp{Id: id}, nil
|
||
|
|
}
|