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 0b0984b..50addac 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,18 +378,33 @@ 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(); + model.addAttribute("achievementRate", result.getAchievementRate()); - GoalForm result = resultList.getFirst(); + model.addAttribute("currentAmount", result.getCurrentAmount()); - model.addAttribute("achievementRate", result.getAchievementRate()); + model.addAttribute("targetAmount", result.getTargetAmount()); - model.addAttribute("currentAmount", result.getCurrentAmount()); + model.addAttribute("saving", userForm.getSaving()); - model.addAttribute("targetAmount", result.getTargetAmount()); + model.addAttribute("deadline", result.getDeadline()); - model.addAttribute("saving", userForm.getSaving()); + } else { + model.addAttribute("achievementRate", "目標を設定してください"); + + model.addAttribute("currentAmount", "目標を設定してください"); + + model.addAttribute("targetAmount", "目標を設定してください"); + + model.addAttribute("saving", userForm.getSaving()); + + model.addAttribute("deadline", "目標を設定してください"); + + } - model.addAttribute("deadline", result.getDeadline()); return "menu"; }