From 4a574294b75f6060c3d1782519556966e4711a91 Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 24 Sep 2026 15:33:37 +0900 Subject: [PATCH] =?UTF-8?q?[EDIT]=20=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=88=E3=82=AB=E3=83=86=E3=82=B4=E3=83=AA=E3=83=BB=E3=82=AB?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=A0=E3=82=AB=E3=83=86=E3=82=B4=E3=83=AA?= =?UTF-8?q?=E4=B8=A1=E6=96=B9=E5=8F=96=E5=BE=97=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TransactionController.java | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) 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 5b4b753..8643554 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 @@ -3,6 +3,7 @@ package com.example.demo.app.presentation.controller; import java.time.LocalDate; import java.time.YearMonth; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -185,8 +186,9 @@ public class TransactionController { @GetMapping("/transaction/create") public String createOneGet(@RequestParam(defaultValue = "") LocalDate today, Long fixedCostId, - Model model) { + Model model, HttpSession session) { + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); if (today == null) { today = LocalDate.now(); } @@ -196,11 +198,21 @@ public class TransactionController { FixedCostForm fixedCostForm = FixedCostForm.convertFrom(fixedCostService.findById(fixedCostId)); transactionForm.setCategoryId(fixedCostForm.getCategoryId()); transactionForm.setAmount(fixedCostForm.getAmount()); - transactionForm.setTransactionType(CategoryForm.convertFrom(categoryService.findOne(fixedCostForm.getCategoryId())).getTransactionType()); + transactionForm.setTransactionType(CategoryForm + .convertFrom(categoryService.findOne(fixedCostForm.getCategoryId())).getTransactionType()); } - List categoryFormList = CategoryForm.convertFrom(categoryService.findAll()); + List categoryFormList = new ArrayList<>( + CategoryForm.convertFrom(categoryService.findAllExceptCustom())); + List categoryFormCustomList = CategoryForm + .convertFrom(categoryService.findAllByuserId(loginUser.getUserId())); + + if (!categoryFormCustomList.isEmpty()) { + for (CategoryForm form : categoryFormCustomList) { + categoryFormList.add(form); + } + } System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount()); @@ -232,13 +244,24 @@ public class TransactionController { @SessionCheck @GetMapping("/transaction/update") public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today, - Model model) { + Model model, HttpSession session) { + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); if (today == null) { today = LocalDate.now(); } - List categoryFormList = CategoryForm.convertFrom(categoryService.findAll()); + List categoryFormList = new ArrayList<>( + CategoryForm.convertFrom(categoryService.findAllExceptCustom())); + + List categoryFormCustomList = CategoryForm + .convertFrom(categoryService.findAllByuserId(loginUser.getUserId())); + + if (!categoryFormCustomList.isEmpty()) { + for (CategoryForm form : categoryFormCustomList) { + categoryFormList.add(form); + } + } TransactionForm transactionForm = TransactionForm.convertFrom( transactionService.findByTransactionId(transactionId), @@ -348,19 +371,19 @@ public class TransactionController { model.addAttribute("totalIncome", totalIncome); model.addAttribute("totalExpense", totalExpense); -// List goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId())); + // List goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId())); UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId())); -// model.addAttribute("achievementRate", goalForm.getAchievementRate()); -// -// model.addAttribute("currentAmount", goalForm.getCurrentAmount()); -// -// model.addAttribute("targetAmount", goalForm.getTargetAmount()); + // model.addAttribute("achievementRate", goalForm.getAchievementRate()); + // + // model.addAttribute("currentAmount", goalForm.getCurrentAmount()); + // + // model.addAttribute("targetAmount", goalForm.getTargetAmount()); model.addAttribute("saving", userForm.getSaving()); -// model.addAttribute("deadline", goalForm.getDeadline()); + // model.addAttribute("deadline", goalForm.getDeadline()); return "menu"; }