diff --git a/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java b/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java index 50addac..a6baff2 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java @@ -378,34 +378,24 @@ public class TransactionController { List resultList = goalForm.stream().filter(goal -> goal.getGoalComplete() == 0) .collect(Collectors.toList()); - GoalForm result = new GoalForm(); - - if (resultList.getFirst() != null) { - result = resultList.getFirst(); + + if (!resultList.isEmpty()) { + GoalForm result = resultList.getFirst(); + model.addAttribute("achievementRate", result.getAchievementRate()); - model.addAttribute("currentAmount", result.getCurrentAmount()); - model.addAttribute("targetAmount", result.getTargetAmount()); - model.addAttribute("saving", userForm.getSaving()); - model.addAttribute("deadline", result.getDeadline()); } else { model.addAttribute("achievementRate", "目標を設定してください"); - model.addAttribute("currentAmount", "目標を設定してください"); - model.addAttribute("targetAmount", "目標を設定してください"); - model.addAttribute("saving", userForm.getSaving()); - model.addAttribute("deadline", "目標を設定してください"); - } - return "menu"; }