实现使用系统中所有可用的原料一键生成配方
This commit is contained in:
@@ -25,22 +25,31 @@ type RecipeService interface {
|
||||
DeleteRecipe(ctx context.Context, id uint32) error
|
||||
GetRecipeByID(ctx context.Context, id uint32) (*dto.RecipeResponse, error)
|
||||
ListRecipes(ctx context.Context, req *dto.ListRecipeRequest) (*dto.ListRecipeResponse, error)
|
||||
// GenerateRecipeWithAllRawMaterials 添加新方法
|
||||
GenerateRecipeWithAllRawMaterials(ctx context.Context, pigTypeID uint32) (*models.Recipe, error)
|
||||
}
|
||||
|
||||
// recipeServiceImpl 是 RecipeService 接口的实现
|
||||
type recipeServiceImpl struct {
|
||||
ctx context.Context
|
||||
recipeSvc recipe.RecipeCoreService
|
||||
recipeSvc recipe.Service
|
||||
}
|
||||
|
||||
// NewRecipeService 创建一个新的 RecipeService 实例
|
||||
func NewRecipeService(ctx context.Context, recipeSvc recipe.RecipeCoreService) RecipeService {
|
||||
func NewRecipeService(ctx context.Context, recipeSvc recipe.Service) RecipeService {
|
||||
return &recipeServiceImpl{
|
||||
ctx: ctx,
|
||||
recipeSvc: recipeSvc,
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateRecipeWithAllRawMaterials 实现新方法
|
||||
func (s *recipeServiceImpl) GenerateRecipeWithAllRawMaterials(ctx context.Context, pigTypeID uint32) (*models.Recipe, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "GenerateRecipeWithAllRawMaterials")
|
||||
// 直接调用领域服务的方法
|
||||
return s.recipeSvc.GenerateRecipeWithAllRawMaterials(serviceCtx, pigTypeID)
|
||||
}
|
||||
|
||||
// CreateRecipe 创建配方
|
||||
func (s *recipeServiceImpl) CreateRecipe(ctx context.Context, req *dto.CreateRecipeRequest) (*dto.RecipeResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "CreateRecipe")
|
||||
|
||||
Reference in New Issue
Block a user