* feat: support product yarn batches * feat: improve product yarn ratio workflow * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
36 lines
801 B
Go
36 lines
801 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"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 GetProductLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductLogic {
|
|
return &GetProductLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetProductLogic) GetProduct(in *pb.GetProductReq) (*pb.ProductInfo, error) {
|
|
product, err := l.svcCtx.ProductModel.FindOneByProductId(l.ctx, in.ProductId)
|
|
if err != nil {
|
|
return nil, status.Error(codes.NotFound, "product not found")
|
|
}
|
|
|
|
return productToPb(product), nil
|
|
}
|