|
|
|
@ -220,7 +220,7 @@ public class ToBuysService { |
|
|
|
|
* @param authentication 認証情報 |
|
|
|
|
* @return 追加された「買うもの」のリスト |
|
|
|
|
*/ |
|
|
|
|
public List<ToBuyResponseDTO> addByRecipeId(Long recipeId, Authentication authentication) { |
|
|
|
|
public List<ToBuyResponseDTO> addByRecipeId(Long recipeId, Long servings,Authentication authentication) { |
|
|
|
|
// ユーザー情報を取得
|
|
|
|
|
String username = authentication.getName(); |
|
|
|
|
User user = userRepository.findByUsername(username) |
|
|
|
@ -233,7 +233,9 @@ public class ToBuysService { |
|
|
|
|
|
|
|
|
|
for (RecipeStuffs rs : recipeStuffsList) { |
|
|
|
|
Stuffs stuff = rs.getStuff(); |
|
|
|
|
int requiredAmount = rs.getAmount(); |
|
|
|
|
|
|
|
|
|
// 材料の数量をサービング数に基づいて計算
|
|
|
|
|
int requiredAmount = rs.getAmount() * (servings != null ? servings.intValue() : 1); |
|
|
|
|
|
|
|
|
|
Optional<ToBuys> existingToBuyOpt = toBuysRepository.findByUserAndStuff(user, stuff); |
|
|
|
|
|
|
|
|
|