Align origin/main with upstream/main (GitHub). The two branches diverged due to pre-rebase vs post-rebase merge commits for the k8s-amd64-dockerfiles feature. Includes: multi-stage Go compilation Dockerfiles, pan-bolt inventory features, CRM relations, Excel import tooling, proto/gRPC updates, migration scripts, and tools/ directory. Excludes deploy/bin/ pre-compiled binaries (arm64, not needed for amd64 K3s cluster; builds use multi-stage Dockerfiles now).
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
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,
|
|
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
|
|
}
|