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).
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package product
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
"muyu-apiserver/pkg/ctxdata"
|
|
"muyu-apiserver/rpc/inventory/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetProductTreeLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetProductTreeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductTreeLogic {
|
|
return &GetProductTreeLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetProductTreeLogic) GetProductTree() (resp *types.ProductTreeResp, err error) {
|
|
id := ctxdata.GetPathId(l.ctx)
|
|
rpcResp, err := l.svcCtx.InventoryRpc.GetProductTree(l.ctx, &pb.GetProductReq{
|
|
ProductId: id,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
pans := make([]types.PanInfo, 0, len(rpcResp.Pans))
|
|
for _, p := range rpcResp.Pans {
|
|
pans = append(pans, panInfoFromPB(p))
|
|
}
|
|
return &types.ProductTreeResp{
|
|
Product: productInfoFromPB(rpcResp.Product),
|
|
Pans: pans,
|
|
TotalPanCount: rpcResp.TotalPanCount,
|
|
TotalBoltCount: rpcResp.TotalBoltCount,
|
|
TotalLengthM: rpcResp.TotalLengthM,
|
|
}, nil
|
|
}
|