diff --git a/refrigerator/src/main/java/moja/refrigerator/service/recipe/RecipeServiceImpl.java b/refrigerator/src/main/java/moja/refrigerator/service/recipe/RecipeServiceImpl.java index 6e0d8b0..6029d28 100644 --- a/refrigerator/src/main/java/moja/refrigerator/service/recipe/RecipeServiceImpl.java +++ b/refrigerator/src/main/java/moja/refrigerator/service/recipe/RecipeServiceImpl.java @@ -577,13 +577,18 @@ public RecipeRecommendResponse getRandomRecipe() { int randomIndex = random.nextInt(allRecipes.size()); Recipe selectedRecipe = allRecipes.get(randomIndex); - // Response 객체로 변환 - RecipeRecommendResponse response = mapper.map(selectedRecipe, RecipeRecommendResponse.class); + // 로그 추가 + System.out.println("선택된 레시피: " + selectedRecipe.getRecipeName()); - // 재료 정보 추가 List recipeIngredients = recipeIngredientRepository.findByRecipe(selectedRecipe); + // 로그 추가 + System.out.println("조회된 재료 수: " + recipeIngredients.size()); + List ingredientInfoList = recipeIngredients.stream() .map(ri -> { + // 로그 추가 + System.out.println("재료 정보: " + ri.getIngredientManagement().getIngredientName()); + RecipeIngredientInfo info = new RecipeIngredientInfo(); info.setIngredientName(ri.getIngredientManagement().getIngredientName()); info.setNecessary(ri.isIngredientIsNecessary()); @@ -591,6 +596,7 @@ public RecipeRecommendResponse getRandomRecipe() { }) .collect(Collectors.toList()); + RecipeRecommendResponse response = mapper.map(selectedRecipe, RecipeRecommendResponse.class); response.setIngredients(ingredientInfoList); return response;