|
|
@ -27,6 +27,7 @@ import com.example.todoapp.model.Stuffs; |
|
|
|
import com.example.todoapp.repository.RecipeStuffsRepository; |
|
|
|
import com.example.todoapp.repository.RecipeStuffsRepository; |
|
|
|
import com.example.todoapp.repository.RecipesRepository; |
|
|
|
import com.example.todoapp.repository.RecipesRepository; |
|
|
|
import com.example.todoapp.repository.StuffsRepository; |
|
|
|
import com.example.todoapp.repository.StuffsRepository; |
|
|
|
|
|
|
|
import com.example.todoapp.repository.UserRepository; |
|
|
|
|
|
|
|
|
|
|
|
import jakarta.transaction.Transactional; |
|
|
|
import jakarta.transaction.Transactional; |
|
|
|
|
|
|
|
|
|
|
@ -140,7 +141,7 @@ public class RecipeService { |
|
|
|
* @return レシピ詳細情報(レシピ基本情報と関連食材情報) |
|
|
|
* @return レシピ詳細情報(レシピ基本情報と関連食材情報) |
|
|
|
* @throws RuntimeException レシピが見つからない場合 |
|
|
|
* @throws RuntimeException レシピが見つからない場合 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public RecipeDetailDTO getRecipeDetailsById(Long recipeId) { |
|
|
|
public RecipeDetailDTO getRecipeDetailsById(Long userId, Long recipeId) { |
|
|
|
Recipes recipe = recipesRepository.findById(recipeId) |
|
|
|
Recipes recipe = recipesRepository.findById(recipeId) |
|
|
|
.orElseThrow(() -> new RuntimeException("レシピが見つかりません")); |
|
|
|
.orElseThrow(() -> new RuntimeException("レシピが見つかりません")); |
|
|
|
|
|
|
|
|
|
|
@ -162,6 +163,7 @@ public class RecipeService { |
|
|
|
dto.setRecipeId(recipe.getRecipeId()); |
|
|
|
dto.setRecipeId(recipe.getRecipeId()); |
|
|
|
dto.setRecipeName(recipe.getRecipeName()); |
|
|
|
dto.setRecipeName(recipe.getRecipeName()); |
|
|
|
dto.setSummary(recipe.getSummary()); |
|
|
|
dto.setSummary(recipe.getSummary()); |
|
|
|
|
|
|
|
dto.setMaxServings(getRecipeMaxServings(userId, recipe)); |
|
|
|
dto.setStuffAndAmountArray(stuffList); |
|
|
|
dto.setStuffAndAmountArray(stuffList); |
|
|
|
|
|
|
|
|
|
|
|
return dto; |
|
|
|
return dto; |
|
|
|