From 12550c5b1d0990a9d8b002e37318457b34dae1d5 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:51:59 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[STYLE]=20menu=E3=81=AE=E3=83=87=E3=82=B6?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=92=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 --- src/main/resources/static/css/menu.css | 81 ++++++++++++++-- src/main/resources/templates/menu.html | 129 ++++++++++++++++--------- 2 files changed, 155 insertions(+), 55 deletions(-) diff --git a/src/main/resources/static/css/menu.css b/src/main/resources/static/css/menu.css index 5195e7c..12d4ad2 100644 --- a/src/main/resources/static/css/menu.css +++ b/src/main/resources/static/css/menu.css @@ -1,15 +1,80 @@ -table, th, td {border: 1px solid black; border-collapse: collapse;} +body { + margin: 0; + padding: 0; +} -td:hover{background-color: lightblue;} +#calendar { + width: 100%; + border-collapse: collapse; + table-layout: fixed; +} -th{font-weight: bold; height: 50px;} +#calendar th, +#calendar td { + border: 1px solid black; +} -td{text-align: left; vertical-align: text-top; width: 200px; height: 100px; padding: 10px} +th { + font-weight: bold; + height: 35px; + font-size: 13px; + text-align: center; +} -.holiday{color: red;} +td { + width: 14.28%; + height: 70px; + padding: 5px; + text-align: left; + vertical-align: top; +} -#today{font-weight: bold; background-color: bisque;} +td:hover { + background-color: lightblue; +} -.year{font-size: 30px;} +.holiday { + color: red; +} -.month{font-size: 50px; font-weight: bold;} \ No newline at end of file +#today { + font-weight: bold; + background-color: bisque; +} + +.year { + font-size: 20px; +} + +.month { + font-size: 30px; + font-weight: bold; +} + +.calendar-title { + margin: 15px 10px; +} + +.date { + font-size: 13px; + font-weight: bold; +} + +.income { + color: blue; + font-size: 10px; +} + +.expense { + color: red; + font-size: 10px; +} + +.total { + margin: 15px 10px; + padding: 10px; + border-top: 1px solid #ddd; + + font-size: 16px; + text-align: right; +} diff --git a/src/main/resources/templates/menu.html b/src/main/resources/templates/menu.html index 15365cf..9c6fc1f 100644 --- a/src/main/resources/templates/menu.html +++ b/src/main/resources/templates/menu.html @@ -2,71 +2,106 @@ - - Calendar - + + + + + Calendar + + + + + - - +
- - - - - - - - - - - - +
-
+ + - + + - + + + + + + + + +
日月火水木金土
+ -
-
-
+ -
-
+ -
-
+ + + + + + + + + - + - - + - -
日月火水木金土
+
+ + + + +
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ 収入: + + 円 +
+ +
+ 支出: + + 円 +
+ +
-
-

- - -

-
- + \ No newline at end of file From d415bf1ad5c5b98cac1b8726163cb269b1027aa4 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:53:27 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[EDIT]=20=E5=8F=8E=E6=94=AF=E8=A9=B3?= =?UTF-8?q?=E7=B4=B0=E3=81=AB=E7=B7=A8=E9=9B=86=E3=83=9C=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/transaction_detail.html | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/main/resources/templates/transaction_detail.html b/src/main/resources/templates/transaction_detail.html index d96d00b..bc11005 100644 --- a/src/main/resources/templates/transaction_detail.html +++ b/src/main/resources/templates/transaction_detail.html @@ -4,32 +4,56 @@ 収支詳細 + + + + +

    -
  • -

    カテゴリ名: -
    金額: -

    -
    - - +
  • - -
  • -
    +
    +

    + カテゴリ名: + +
    + 金額: + +

    +
    + +
    + +
    + + + +
    + +
    + + + +
    + +
    + +
    +
+
-
From 2300aa36447d33315bf08df66b685ec034ca7850 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:54:32 +0900 Subject: [PATCH 3/9] =?UTF-8?q?[EDIT]=20=E5=8F=8E=E6=94=AF=E8=A9=B3?= =?UTF-8?q?=E7=B4=B0=E7=94=BB=E9=9D=A2=E3=81=AE=E3=83=87=E3=82=B6=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=92=E4=BD=9C=E6=88=90=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/css/transaction_detail.css | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/resources/static/css/transaction_detail.css diff --git a/src/main/resources/static/css/transaction_detail.css b/src/main/resources/static/css/transaction_detail.css new file mode 100644 index 0000000..9e568ca --- /dev/null +++ b/src/main/resources/static/css/transaction_detail.css @@ -0,0 +1,15 @@ +.transaction-item { + display: flex; + align-items: center; + justify-content: space-between; +} + +.transaction-buttons { + display: flex; + gap: 10px; + margin-right: 20px; +} + +.transaction-buttons form { + margin: 0; +} From 200ebe2a61a2e4627b3694cd829886edbfed8b65 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:55:32 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[EDIT]=20=E5=8F=8E=E6=94=AFID=E3=81=A7?= =?UTF-8?q?=E3=82=AB=E3=83=86=E3=82=B4=E3=83=AA=E3=82=A8=E3=83=B3=E3=83=86?= =?UTF-8?q?=E3=82=A3=E3=83=86=E3=82=A3=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90=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 --- .../com/example/demo/app/domain/service/CategoryService.java | 2 ++ .../demo/app/domain/service/impl/CategoryServiceImpl.java | 5 +++++ .../demo/app/infra/repository/CategoryRepository.java | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/main/java/com/example/demo/app/domain/service/CategoryService.java b/src/main/java/com/example/demo/app/domain/service/CategoryService.java index ddea344..2f61d9d 100644 --- a/src/main/java/com/example/demo/app/domain/service/CategoryService.java +++ b/src/main/java/com/example/demo/app/domain/service/CategoryService.java @@ -11,4 +11,6 @@ public interface CategoryService { public CategoryModel findOne(Long categoryId); public CategoryModel findOneByCategoryName(String categoryName); + + public CategoryModel findByTransactionId(Long transactionId); } diff --git a/src/main/java/com/example/demo/app/domain/service/impl/CategoryServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/CategoryServiceImpl.java index 6e59cdb..b48188b 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/CategoryServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/CategoryServiceImpl.java @@ -48,4 +48,9 @@ public class CategoryServiceImpl implements CategoryService { } + public CategoryModel findByTransactionId(Long transactionId) { + return CategoryModel.convertFrom(categoryRepository.findByTransactionId(transactionId)); + } + + } diff --git a/src/main/java/com/example/demo/app/infra/repository/CategoryRepository.java b/src/main/java/com/example/demo/app/infra/repository/CategoryRepository.java index 79b439b..c6d1a47 100644 --- a/src/main/java/com/example/demo/app/infra/repository/CategoryRepository.java +++ b/src/main/java/com/example/demo/app/infra/repository/CategoryRepository.java @@ -12,4 +12,7 @@ public interface CategoryRepository extends JpaRepository @Query("select c from CategoryEntity c where c.categoryName = :categoryName") public CategoryEntity findByCategoryName(@Param("categoryName") String categoryName); + @Query("select c from CategoryEntity c inner join TransactionEntity t on c.categoryId = t.categoryEntity.categoryId where t.transactionId = :transactionId") + public CategoryEntity findByTransactionId(Long transactionId); + } From a5c9ab9abe0037d6a0a96691be1aa27fae0f9626 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:56:27 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[EDIT]=20=E8=A9=B2=E5=BD=93=E3=83=86?= =?UTF-8?q?=E3=83=BC=E3=83=96=E3=83=AB=E3=81=AE=E5=8F=8E=E6=94=AF=E3=81=AE?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=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 --- .../demo/app/domain/service/TransactionService.java | 4 ++++ .../domain/service/impl/TransactionServiceImpl.java | 12 ++++++++++++ .../app/infra/repository/TransactionRepository.java | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/main/java/com/example/demo/app/domain/service/TransactionService.java b/src/main/java/com/example/demo/app/domain/service/TransactionService.java index ab4aa12..f8b0c24 100644 --- a/src/main/java/com/example/demo/app/domain/service/TransactionService.java +++ b/src/main/java/com/example/demo/app/domain/service/TransactionService.java @@ -10,6 +10,8 @@ import com.example.demo.app.presentation.form.Income; public interface TransactionService { + public TransactionModel findByTransactionId(Long transactionId); + public Map> findAllByDate(LocalDate startDate, LocalDate endDate, Long userId); public List findByUserIdAndDate(LocalDate todayDate, Long userId); @@ -18,6 +20,8 @@ public interface TransactionService { public int findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId); + public int findMoneyRecord(Long transactionId); + public int createTransaction(TransactionModel transactionModel); public int updateTransaction(TransactionModel transactionModel); diff --git a/src/main/java/com/example/demo/app/domain/service/impl/TransactionServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/TransactionServiceImpl.java index 9467f9c..cf4e496 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/TransactionServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/TransactionServiceImpl.java @@ -29,6 +29,13 @@ public class TransactionServiceImpl implements TransactionService { private final UserRepository userRepository; private final CategoryRepository categoryRepository; + + public TransactionModel findByTransactionId(Long transactionId) { + + return TransactionModel.convertFrom(transactionRepository.findById(transactionId).get()); + + } + public Map> findAllByDate( LocalDate startDate, LocalDate endDate, @@ -92,6 +99,11 @@ public class TransactionServiceImpl implements TransactionService { return TransactionModel.convertFrom(transactionRepository.findByUserIdAndDate(todayDate, userId)); } + + public int findMoneyRecord(Long transactionId) { + return transactionRepository.findMoneyRecord(transactionId); + } + public int createTransaction(TransactionModel transactionModel) { diff --git a/src/main/java/com/example/demo/app/infra/repository/TransactionRepository.java b/src/main/java/com/example/demo/app/infra/repository/TransactionRepository.java index e68e169..8696f24 100644 --- a/src/main/java/com/example/demo/app/infra/repository/TransactionRepository.java +++ b/src/main/java/com/example/demo/app/infra/repository/TransactionRepository.java @@ -33,5 +33,7 @@ public interface TransactionRepository extends JpaRepository findTotalIncomeList(LocalDate startDate, LocalDate endDate, Long userId); + @Query("select coalesce(t.amount, 0) from TransactionEntity t where t.transactionId = :transactionId") + public Integer findMoneyRecord(Long transactionId); } From 04d62956f7fd38f3f1414e1f9ad89d12c8c0bb2c Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:57:08 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[EDIT]=20=E6=97=A5=E4=BB=98=E3=81=8C?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E3=81=A7=E8=A8=98=E5=85=A5=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97?= =?UTF-8?q?=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 --- src/main/resources/templates/transaction_create.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/resources/templates/transaction_create.html b/src/main/resources/templates/transaction_create.html index 01abaae..e85cf4d 100644 --- a/src/main/resources/templates/transaction_create.html +++ b/src/main/resources/templates/transaction_create.html @@ -4,16 +4,22 @@ Insert title here + + + + +
+

取引登録

- +

From 6dd182ed0b7829e95be8a5eda621fd85fd7e52d8 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:57:30 +0900 Subject: [PATCH 7/9] =?UTF-8?q?[ADD]=20=E5=8F=8E=E6=94=AF=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E7=94=BB=E9=9D=A2=E3=82=92=E4=BD=9C=E6=88=90=E3=81=97?= =?UTF-8?q?=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 --- .../templates/transaction_update.html | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/resources/templates/transaction_update.html diff --git a/src/main/resources/templates/transaction_update.html b/src/main/resources/templates/transaction_update.html new file mode 100644 index 0000000..1e03895 --- /dev/null +++ b/src/main/resources/templates/transaction_update.html @@ -0,0 +1,76 @@ + + + + + + Insert title here + + + + + + + +
+ +

取引登録

+ + + + + +
+ + +
+ +
+ +
+ + + +
+ +
+ +
+ + + +
+ +
+ +
+ + + +
+ +
+ + + + + + + + + + + \ No newline at end of file From 9cdf7b7767746ee7c09b1fdb07c943bfb3d5d960 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:57:51 +0900 Subject: [PATCH 8/9] =?UTF-8?q?[EDIT]=20=E5=8F=8E=E6=94=AF=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=81=AB=E3=83=87=E3=82=B6=E3=82=A4=E3=83=B3=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=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 --- src/main/resources/templates/transaction_list.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/templates/transaction_list.html b/src/main/resources/templates/transaction_list.html index a6a4707..53a58ff 100644 --- a/src/main/resources/templates/transaction_list.html +++ b/src/main/resources/templates/transaction_list.html @@ -4,10 +4,15 @@ 一覧 + + + +
+
From b49c9156a1452819dd8b2a016ec35806aee23307 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 13:58:12 +0900 Subject: [PATCH 9/9] =?UTF-8?q?[FIX]=20=E5=85=A8=E4=BD=93=E7=9A=84?= =?UTF-8?q?=E3=81=AA=E6=95=B4=E5=90=88=E6=80=A7=E3=82=92=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=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 | 175 ++++++++++++------ 1 file changed, 119 insertions(+), 56 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 053cbd5..526f98b 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 @@ -2,6 +2,7 @@ package com.example.demo.app.presentation.controller; import java.time.LocalDate; import java.time.YearMonth; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -65,9 +66,7 @@ public class TransactionController { }).collect(Collectors.toList()); transactionFormMap.put(date, transactionFormList); }); - - - + model.addAttribute("transactionFormMap", transactionFormMap); return "transaction_list"; @@ -78,21 +77,45 @@ public class TransactionController { public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) { LocalDate todayDate = (todayDates == null) ? LocalDate.now() : todayDates; - - + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); List transactionFormList = transactionService .findByUserIdAndDate(todayDate, loginUser.getUserId()).stream() .map(transaction -> { - TransactionForm transactionForm = TransactionForm.convertFrom( - transaction, - CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId())) - .getCategoryName(), - transactionService.findTotalExpense(todayDate, todayDate, loginUser.getUserId()), - transactionService.findTotalIncome(todayDate, todayDate, loginUser.getUserId()), - CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId())) - .getTransactionType()); + + int type = CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId())) + .getTransactionType(); + + TransactionForm transactionForm; + if (type == 1) { + + transactionForm = TransactionForm.convertFrom( + transaction, + CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId())) + .getCategoryName(), + 0, + transactionService.findMoneyRecord(transaction.getTransactionId()), + type); + + } else if (type == 0) { + transactionForm = TransactionForm.convertFrom( + transaction, + CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId())) + .getCategoryName(), + transactionService.findMoneyRecord(transaction.getTransactionId()), + 0, + type); + } else { + transactionForm = TransactionForm.convertFrom( + transaction, + CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId())) + .getCategoryName(), + 0, + 0, + type); + } + return transactionForm; }).collect(Collectors.toList()); @@ -103,102 +126,142 @@ public class TransactionController { } @GetMapping("/transaction/create") - public String createOneGet(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model) { + public String createOneGet(@RequestParam(defaultValue = "") LocalDate today, + Model model) { List categoryFormList = CategoryForm.convertFrom(categoryService.findAll()); - + + TransactionForm transactionForm = new TransactionForm(); + transactionForm.setTransactionDate(today); + + System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount()); + + model.addAttribute("transactionForm", transactionForm); + model.addAttribute("categoryFormList", categoryFormList); - model.addAttribute("today", today); - + + model.addAttribute("today", today.format(DateTimeFormatter.ISO_LOCAL_DATE)); + return "transaction_create"; } @PostMapping("/transaction/create") - public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model, HttpSession session) { + public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, + Model model, + HttpSession session) { + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); transactionForm.setUserId(loginUser.getUserId()); - transactionForm.setTransactionDate(today); if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) { return "error"; } - return "redirect:/transaction/detail?todayDates=" + today; + return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate(); } @GetMapping("/transaction/update") - public String updateOneGet(@ModelAttribute TransactionForm transactionForm) { + public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today, + Model model) { + + if (today.equals(null)) { + today = LocalDate.now(); + } + + List categoryFormList = CategoryForm.convertFrom(categoryService.findAll()); + + TransactionForm transactionForm = TransactionForm.convertFrom( + transactionService.findByTransactionId(transactionId), + CategoryForm.convertFrom(categoryService.findByTransactionId(transactionId)).getCategoryName(), + transactionService.findMoneyRecord(transactionId), + transactionService.findMoneyRecord(transactionId), + CategoryForm.convertFrom(categoryService.findByTransactionId(transactionId)).getTransactionType()); + + System.out.println("category: " + transactionForm.getCategoryId() + "金額: " + transactionForm.getAmount()); + + + model.addAttribute("transactionId", transactionId); + + model.addAttribute("transactionForm", transactionForm); + + model.addAttribute("categoryFormList", categoryFormList); + + model.addAttribute("today", today); + + return "transaction_update"; - return ""; } @PostMapping("/transaction/update") - public String updateOnePost(@ModelAttribute TransactionForm transactionForm, Model model) { + public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model, + HttpSession session) { + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); + + transactionForm.setUserId(loginUser.getUserId()); + transactionForm.setTransactionId(transactionId); + if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) { return "error"; } - return ""; + return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate(); } @PostMapping("/transaction/delete") public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) { - + transactionService.deleteTransaction(transactionId); return "redirect:/transaction/detail?todayDates=" + today; } - + @GetMapping("/menu") - public String menu(HttpSession session, Model model, @RequestParam(required = false, defaultValue = "0") String years, @RequestParam(required = false, defaultValue = "0") String months) { - + public String menu(HttpSession session, Model model, + @RequestParam(required = false, defaultValue = "0") String years, + @RequestParam(required = false, defaultValue = "0") String months) { + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); LocalDate today = LocalDate.now(); - + int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years); int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months); System.out.println("year : " + year + "month : " + month); - - YearMonth yearMonth = YearMonth.of(year, month); - - int lastDay = yearMonth.lengthOfMonth(); - int firstDayOfWeek = - yearMonth.atDay(1).getDayOfWeek().getValue() % 7; + YearMonth yearMonth = YearMonth.of(year, month); - model.addAttribute("year", year); - model.addAttribute("month", month); - model.addAttribute("day", today.getDayOfMonth()); + int lastDay = yearMonth.lengthOfMonth(); - model.addAttribute("lastDay", lastDay); - model.addAttribute("firstDayOfWeek", firstDayOfWeek); + int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7; - LocalDate startDate = LocalDate.now().withDayOfMonth(1); + model.addAttribute("year", year); + model.addAttribute("month", month); + model.addAttribute("day", today.getDayOfMonth()); + + model.addAttribute("lastDay", lastDay); + model.addAttribute("firstDayOfWeek", firstDayOfWeek); + + LocalDate startDate = LocalDate.now().withDayOfMonth(1); LocalDate endDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()); - - + List incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId()); List expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId()); - + model.addAttribute("incomeList", incomeList); - + model.addAttribute("expenseList", expenseList); - - + int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId()); - - int totalExpense= transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId()); - + + int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId()); + model.addAttribute("totalIncome", totalIncome); model.addAttribute("totalExpense", totalExpense); - - - return "menu"; - } - - + + return "menu"; + } + }