2026-06-14 15:24:02 +08:00
|
|
|
package logic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"muyu-apiserver/pkg/tenantctx"
|
|
|
|
|
"muyu-apiserver/rpc/inventory/internal/svc"
|
|
|
|
|
"muyu-apiserver/rpc/inventory/pb"
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ListPanViewLogic struct {
|
|
|
|
|
ctx context.Context
|
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
|
logx.Logger
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewListPanViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPanViewLogic {
|
|
|
|
|
return &ListPanViewLogic{
|
|
|
|
|
ctx: ctx,
|
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *ListPanViewLogic) ListPanView(in *pb.ListPanViewReq) (*pb.ListPanViewResp, error) {
|
|
|
|
|
tenantId := tenantctx.ExtractTenantId(l.ctx)
|
|
|
|
|
list, total, err := l.svcCtx.PanModel.FindPanList(l.ctx, tenantId, in.Page, in.PageSize, in.ProductName, in.Position)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pbList := make([]*pb.PanListItem, 0, len(list))
|
|
|
|
|
for _, item := range list {
|
|
|
|
|
pbList = append(pbList, &pb.PanListItem{
|
|
|
|
|
PanId: item.PanId,
|
|
|
|
|
ProductId: item.ProductId,
|
2026-07-05 08:06:28 +09:00
|
|
|
BatchId: item.BatchId,
|
|
|
|
|
BatchNo: item.BatchNo,
|
2026-06-14 15:24:02 +08:00
|
|
|
Name: item.Name,
|
|
|
|
|
Position: item.Position,
|
|
|
|
|
ProductName: item.ProductName,
|
|
|
|
|
Colors: item.Colors,
|
|
|
|
|
BoltCount: item.BoltCount,
|
|
|
|
|
TotalLengthM: fmt.Sprintf("%.2f", item.TotalLengthM),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &pb.ListPanViewResp{Total: total, List: pbList}, nil
|
|
|
|
|
}
|