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).
54 lines
1.4 KiB
Go
54 lines
1.4 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 ListBoltViewLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewListBoltViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListBoltViewLogic {
|
|
return &ListBoltViewLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *ListBoltViewLogic) ListBoltView(in *pb.ListBoltViewReq) (*pb.ListBoltViewResp, error) {
|
|
tenantId := tenantctx.ExtractTenantId(l.ctx)
|
|
list, total, err := l.svcCtx.BoltModel.FindBoltList(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.BoltListItem, 0, len(list))
|
|
for _, item := range list {
|
|
pbList = append(pbList, &pb.BoltListItem{
|
|
BoltId: item.BoltId,
|
|
PanId: item.PanId,
|
|
LengthM: fmt.Sprintf("%.2f", item.LengthM),
|
|
Color: item.Color,
|
|
SortOrder: item.SortOrder,
|
|
PanName: item.PanName,
|
|
Position: item.Position,
|
|
ProductId: item.ProductId,
|
|
ProductName: item.ProductName,
|
|
})
|
|
}
|
|
|
|
return &pb.ListBoltViewResp{Total: total, List: pbList}, nil
|
|
}
|