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).
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package stock
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
"muyu-apiserver/rpc/inventory/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ListStockLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewListStockLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListStockLogic {
|
|
return &ListStockLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *ListStockLogic) ListStock(req *types.ListProductReq) (resp *types.ListProductResp, err error) {
|
|
rpcResp, err := l.svcCtx.InventoryRpc.ListProduct(l.ctx, &pb.ListProductReq{
|
|
Page: req.Page,
|
|
PageSize: req.PageSize,
|
|
ProductName: req.ProductName,
|
|
Spec: req.Spec,
|
|
Color: req.Color,
|
|
Status: req.Status,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
list := make([]types.ProductInfo, 0, len(rpcResp.List))
|
|
for _, p := range rpcResp.List {
|
|
list = append(list, types.ProductInfo{
|
|
ProductId: p.ProductId,
|
|
ProductName: p.ProductName,
|
|
ImageUrl: p.ImageUrl,
|
|
Spec: p.Spec,
|
|
Color: p.Color,
|
|
SalesPrice: p.SalesPrice,
|
|
Remark: p.Remark,
|
|
Status: p.Status,
|
|
CreatedAt: p.CreatedAt,
|
|
UpdatedAt: p.UpdatedAt,
|
|
})
|
|
}
|
|
|
|
return &types.ListProductResp{
|
|
Total: rpcResp.Total,
|
|
List: list,
|
|
}, nil
|
|
}
|