From 714ffba31fa9d2dcdd6fc72c5936fa0324b4faf6 Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 24 Sep 2026 12:43:45 +0900 Subject: [PATCH] =?UTF-8?q?[EDIT]=20=E3=82=B7=E3=83=A7=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=82=AB=E3=83=83=E3=83=88=E6=A9=9F=E8=83=BD=E3=82=92=E9=81=A9?= =?UTF-8?q?=E7=94=A8=E3=81=97=E3=81=BE=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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 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 4897ccb..6af43fa 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 @@ -20,11 +20,13 @@ import org.springframework.web.bind.annotation.RequestParam; import com.example.demo.aop.aspect.SessionCheck; import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.service.CategoryService; +import com.example.demo.app.domain.service.FixedCostService; import com.example.demo.app.domain.service.GoalService; import com.example.demo.app.domain.service.TransactionService; import com.example.demo.app.domain.service.UserService; import com.example.demo.app.presentation.form.CategoryForm; import com.example.demo.app.presentation.form.Expense; +import com.example.demo.app.presentation.form.FixedCostForm; import com.example.demo.app.presentation.form.GoalForm; import com.example.demo.app.presentation.form.Income; import com.example.demo.app.presentation.form.TransactionForm; @@ -40,6 +42,7 @@ public class TransactionController { private final CategoryService categoryService; private final GoalService goalService; private final UserService userService; + private final FixedCostService fixedCostService; // 一覧画面 @SessionCheck @@ -182,16 +185,23 @@ public class TransactionController { @SessionCheck @GetMapping("/transaction/create") public String createOneGet(@RequestParam(defaultValue = "") LocalDate today, + Long fixedCostId, Model model) { if (today == null) { today = LocalDate.now(); } + TransactionForm transactionForm = new TransactionForm(); + transactionForm.setTransactionDate(today); + if (fixedCostId != null) { + FixedCostForm fixedCostForm = FixedCostForm.convertFrom(fixedCostService.findById(fixedCostId)); + transactionForm.setCategoryId(fixedCostForm.getCategoryId()); + transactionForm.setAmount(fixedCostForm.getAmount()); + transactionForm.setTransactionType(CategoryForm.convertFrom(categoryService.findOne(fixedCostForm.getCategoryId())).getTransactionType()); + } List categoryFormList = CategoryForm.convertFrom(categoryService.findAll()); - TransactionForm transactionForm = new TransactionForm(); - transactionForm.setTransactionDate(today); System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount());