54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
|
|
package panbolt
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"muyu-apiserver/gateway/internal/svc"
|
||
|
|
"muyu-apiserver/gateway/internal/types"
|
||
|
|
"muyu-apiserver/rpc/inventory/pb"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type ListBoltViewLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewListBoltViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListBoltViewLogic {
|
||
|
|
return &ListBoltViewLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *ListBoltViewLogic) ListBoltView(req *types.ListBoltViewReq) (resp *types.ListBoltViewResp, err error) {
|
||
|
|
rpcResp, err := l.svcCtx.InventoryRpc.ListBoltView(l.ctx, &pb.ListBoltViewReq{
|
||
|
|
Page: req.Page,
|
||
|
|
PageSize: req.PageSize,
|
||
|
|
ProductName: req.ProductName,
|
||
|
|
Position: req.Position,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
list := make([]types.BoltListItem, 0, len(rpcResp.List))
|
||
|
|
for _, item := range rpcResp.List {
|
||
|
|
list = append(list, types.BoltListItem{
|
||
|
|
BoltId: item.BoltId,
|
||
|
|
PanId: item.PanId,
|
||
|
|
LengthM: item.LengthM,
|
||
|
|
Color: item.Color,
|
||
|
|
SortOrder: item.SortOrder,
|
||
|
|
PanName: item.PanName,
|
||
|
|
Position: item.Position,
|
||
|
|
ProductId: item.ProductId,
|
||
|
|
ProductName: item.ProductName,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
return &types.ListBoltViewResp{Total: rpcResp.Total, List: list}, nil
|
||
|
|
}
|