40 lines
996 B
Go
Raw Normal View History

package yarn
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 ListYarnLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewListYarnLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListYarnLogic {
return &ListYarnLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}
func (l *ListYarnLogic) ListYarn(req *types.ListYarnReq) (*types.ListYarnResp, error) {
resp, err := l.svcCtx.InventoryRpc.ListYarn(l.ctx, &pb.ListYarnReq{
Page: req.Page,
PageSize: req.PageSize,
YarnName: req.YarnName,
SupplierId: req.SupplierId,
Status: req.Status,
})
if err != nil {
return nil, err
}
list := make([]types.YarnInfo, 0, len(resp.List))
for _, item := range resp.List {
list = append(list, yarnInfoFromPB(item))
}
return &types.ListYarnResp{Total: resp.Total, List: list}, nil
}