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).
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"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 ListBoltsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewListBoltsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListBoltsLogic {
|
|
return &ListBoltsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *ListBoltsLogic) ListBolts(in *pb.ListBoltReq) (*pb.ListBoltResp, error) {
|
|
bolts, err := l.svcCtx.BoltModel.FindByPanId(l.ctx, in.PanId)
|
|
if err != nil {
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
}
|
|
|
|
pbBolts := make([]*pb.BoltInfo, 0, len(bolts))
|
|
for _, b := range bolts {
|
|
pbBolts = append(pbBolts, &pb.BoltInfo{
|
|
BoltId: b.BoltId,
|
|
PanId: b.PanId,
|
|
LengthM: fmt.Sprintf("%.2f", b.LengthM),
|
|
SortOrder: b.SortOrder,
|
|
})
|
|
}
|
|
|
|
return &pb.ListBoltResp{List: pbBolts}, nil
|
|
}
|