From 3378f81a2d2ba5f7e848dbf86293a83853a837ee Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 15:05:11 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[EDIT]=20=E6=9C=88=E8=BB=A2=E6=8F=9B?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82=E7=8F=BE=E5=9C=A8=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E7=9B=AE=E6=A8=99=E3=81=AB=E9=96=A2=E3=81=99=E3=82=8B?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=82=92=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=81=A7=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4=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 --- .../controller/TransactionController.java | 93 +++++++++++++------ src/main/resources/static/css/menu.css | 35 ++++++- src/main/resources/templates/menu.html | 56 +++++++++-- 3 files changed, 146 insertions(+), 38 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 80735be..c75fc28 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 @@ -19,11 +19,15 @@ import org.springframework.web.bind.annotation.RequestParam; import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.service.CategoryService; +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.GoalForm; import com.example.demo.app.presentation.form.Income; import com.example.demo.app.presentation.form.TransactionForm; +import com.example.demo.app.presentation.form.UserForm; import lombok.RequiredArgsConstructor; @@ -33,6 +37,8 @@ public class TransactionController { private final TransactionService transactionService; private final CategoryService categoryService; + private final GoalService goalService; + private final UserService userService; // 一覧画面 @GetMapping("/transaction/list") @@ -222,50 +228,85 @@ public class TransactionController { @GetMapping("/menu") public String menu(HttpSession session, Model model, - @RequestParam(required = false, defaultValue = "0") String years, - @RequestParam(required = false, defaultValue = "0") String months) { + @RequestParam(required = false, defaultValue = "0") String years, + @RequestParam(required = false, defaultValue = "0") String months) { - LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); - LocalDate today = LocalDate.now(); + LocalDate today = LocalDate.now(); - int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years); - int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months); + int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years); - System.out.println("year : " + year + "month : " + month); + int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months); - YearMonth yearMonth = YearMonth.of(year, month); + YearMonth yearMonth = YearMonth.of(year, month); - int lastDay = yearMonth.lengthOfMonth(); + int lastDay = yearMonth.lengthOfMonth(); - int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7; + int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7; - model.addAttribute("year", year); - model.addAttribute("month", month); - model.addAttribute("day", today.getDayOfMonth()); + YearMonth previousYearMonth = yearMonth.minusMonths(1); - model.addAttribute("lastDay", lastDay); - model.addAttribute("firstDayOfWeek", firstDayOfWeek); + int previousYear = previousYearMonth.getYear(); + int previousMonth = previousYearMonth.getMonthValue(); - LocalDate startDate = LocalDate.now().withDayOfMonth(1); + YearMonth nextYearMonth = yearMonth.plusMonths(1); - LocalDate endDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()); + int nextYear = nextYearMonth.getYear(); + int nextMonth = nextYearMonth.getMonthValue(); - List incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId()); - List expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId()); - model.addAttribute("incomeList", incomeList); + model.addAttribute("year", year); + model.addAttribute("month", month); + model.addAttribute("day", today.getDayOfMonth()); - model.addAttribute("expenseList", expenseList); + model.addAttribute("lastDay", lastDay); + model.addAttribute("firstDayOfWeek", firstDayOfWeek); - int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId()); + model.addAttribute("previousYear", previousYear); + model.addAttribute("previousMonth", previousMonth); - int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId()); + model.addAttribute("nextYear", nextYear); + model.addAttribute("nextMonth", nextMonth); - model.addAttribute("totalIncome", totalIncome); - model.addAttribute("totalExpense", totalExpense); + LocalDate startDate = yearMonth.atDay(1); + LocalDate endDate = yearMonth.atEndOfMonth(); - return "menu"; + + 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()); + + + model.addAttribute("totalIncome", totalIncome); + model.addAttribute("totalExpense", totalExpense); + + + + GoalForm goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId())); + + UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId())); + + model.addAttribute("achievementRate", goalForm.getAchievementRate()); + + model.addAttribute("targetAmount", goalForm.getTargetAmount()); + + model.addAttribute("saving", userForm.getSaving()); + + model.addAttribute("deadline", goalForm.getDeadline()); + + + + return "menu"; } + } diff --git a/src/main/resources/static/css/menu.css b/src/main/resources/static/css/menu.css index 12d4ad2..f03042a 100644 --- a/src/main/resources/static/css/menu.css +++ b/src/main/resources/static/css/menu.css @@ -42,6 +42,22 @@ td:hover { background-color: bisque; } +.calendar-title { + display: flex; + justify-content: center; + align-items: center; + + gap: 30px; + + margin: 15px 10px; +} + +.calendar-date { + display: flex; + align-items: baseline; + gap: 10px; +} + .year { font-size: 20px; } @@ -51,8 +67,23 @@ td:hover { font-weight: bold; } -.calendar-title { - margin: 15px 10px; +.month-button { + display: flex; + justify-content: center; + align-items: center; + + width: 40px; + height: 40px; + + font-size: 28px; + text-decoration: none; + color: #333; + + border-radius: 50%; +} + +.month-button:hover { + background-color: #eee; } .date { diff --git a/src/main/resources/templates/menu.html b/src/main/resources/templates/menu.html index d7cd472..4afca1f 100644 --- a/src/main/resources/templates/menu.html +++ b/src/main/resources/templates/menu.html @@ -14,22 +14,30 @@ - +
- - + + ← + - - +
+ + +
+ + + → +
+ @@ -54,21 +62,25 @@
-
+
-
+
-
+
@@ -101,6 +113,30 @@
+
+ 目標貯金 + + 円 +
+
+ 貯金額 + + 円 +
+ +
+ +
+ 達成率 + + 円 +
+
+ 達成期限 + + 円 +
+
From 34e9a1727339ef9f24e7b71d6fac8258eb4708c7 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 15:05:44 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[FIX]=20user=E3=81=AE=E6=95=B4=E5=90=88?= =?UTF-8?q?=E6=80=A7=E3=82=92=E4=BF=AE=E6=AD=A3=E3=83=BB=E5=A4=89=E6=8F=9B?= =?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/model/UserModel.java | 22 ++++++++++++++++++- .../demo/app/domain/service/UserService.java | 3 +++ .../demo/app/presentation/form/UserForm.java | 19 ++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/demo/app/domain/model/UserModel.java b/src/main/java/com/example/demo/app/domain/model/UserModel.java index 1f79b0c..05cb388 100644 --- a/src/main/java/com/example/demo/app/domain/model/UserModel.java +++ b/src/main/java/com/example/demo/app/domain/model/UserModel.java @@ -2,6 +2,8 @@ package com.example.demo.app.domain.model; import java.time.LocalDate; +import com.example.demo.app.infra.entity.UserEntity; + import lombok.AllArgsConstructor; import lombok.Getter; @@ -12,7 +14,7 @@ public class UserModel { private String userName; private String mailAddress; private String password; - private Integer secretQuestionId; + private Long secretQuestionId; private String secretAnswer; private LocalDate brithDate; private Integer saving; @@ -21,4 +23,22 @@ public class UserModel { private Long goalId; private Long courseId; private Integer deleteFlag; + + public static UserModel convertFrom(UserEntity userEntity) { + return new UserModel( + userEntity.getUserId(), + userEntity.getUserName(), + userEntity.getMailAddress(), + userEntity.getPassword(), + userEntity.getQuestionEntity().getSecretQuestionId(), + userEntity.getSecretQuestionAnswer(), + userEntity.getBirthDate(), + userEntity.getSaving(), + userEntity.getAnnualIncome(), + userEntity.getMonthlyBudget(), + userEntity.getGoalEntity().getGoalId(), + userEntity.getCourseEntity().getCourseId(), + userEntity.getDeleteFlag() + ); + } } diff --git a/src/main/java/com/example/demo/app/domain/service/UserService.java b/src/main/java/com/example/demo/app/domain/service/UserService.java index 6ad3c04..f61fa9e 100644 --- a/src/main/java/com/example/demo/app/domain/service/UserService.java +++ b/src/main/java/com/example/demo/app/domain/service/UserService.java @@ -1,5 +1,6 @@ package com.example.demo.app.domain.service; +import com.example.demo.app.domain.model.UserModel; import com.example.demo.app.presentation.form.UserForm; public interface UserService { @@ -7,4 +8,6 @@ public interface UserService { void register(UserForm userForm); public void updateCourse(Long userId, Long courseId); + + public UserModel findByUserId(Long userId); } diff --git a/src/main/java/com/example/demo/app/presentation/form/UserForm.java b/src/main/java/com/example/demo/app/presentation/form/UserForm.java index dd8f655..f5401c6 100644 --- a/src/main/java/com/example/demo/app/presentation/form/UserForm.java +++ b/src/main/java/com/example/demo/app/presentation/form/UserForm.java @@ -2,6 +2,8 @@ package com.example.demo.app.presentation.form; import java.time.LocalDate; +import com.example.demo.app.domain.model.UserModel; + import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -21,4 +23,21 @@ public class UserForm { private Integer monthlyBudget; private Long goalId; private Long courseId; + + + public static UserForm convertFrom(UserModel userModel) { + return new UserForm( + userModel.getUserName(), + userModel.getMailAddress(), + userModel.getPassword(), + userModel.getSecretQuestionId(), + userModel.getSecretAnswer(), + userModel.getBrithDate(), + userModel.getSaving(), + userModel.getAnnualIncome(), + userModel.getMonthlyBudget(), + userModel.getGoalId(), + userModel.getCourseId() + ); + } } From db65afe184d2d85c5c8879f4bc7478185b05887a Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 15:06:16 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[EDIT]=20userId=E3=81=A7UserEntity=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E3=83=A1?= =?UTF-8?q?=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E8=BF=BD=E5=8A=A0=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 --- .../demo/app/domain/service/impl/UserServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java index d93f36b..00dad91 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java @@ -2,6 +2,7 @@ package com.example.demo.app.domain.service.impl; import org.springframework.stereotype.Service; +import com.example.demo.app.domain.model.UserModel; import com.example.demo.app.domain.service.UserService; import com.example.demo.app.infra.entity.CourseEntity; import com.example.demo.app.infra.entity.GoalEntity; @@ -69,6 +70,11 @@ public class UserServiceImpl implements UserService { userRepository.save(userEntity); } + + public UserModel findByUserId(Long userId) { + + return UserModel.convertFrom(userRepository.findById(userId).get()); + } } From d83559e9377e4fc6b1c44116491f474bb35bf5e7 Mon Sep 17 00:00:00 2001 From: s-choi Date: Fri, 18 Sep 2026 15:06:49 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[EDIT]=20header=E3=81=A8=E3=81=AE=E9=96=93?= =?UTF-8?q?=E9=9A=94=E3=82=92=E8=AA=BF=E6=95=B4=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 --- src/main/resources/templates/transaction_create.html | 2 +- src/main/resources/templates/transaction_detail.html | 2 +- src/main/resources/templates/transaction_list.html | 2 +- src/main/resources/templates/transaction_update.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/templates/transaction_create.html b/src/main/resources/templates/transaction_create.html index af393f2..80902c0 100644 --- a/src/main/resources/templates/transaction_create.html +++ b/src/main/resources/templates/transaction_create.html @@ -9,7 +9,7 @@ - +
diff --git a/src/main/resources/templates/transaction_detail.html b/src/main/resources/templates/transaction_detail.html index 43c3c5a..5fa195c 100644 --- a/src/main/resources/templates/transaction_detail.html +++ b/src/main/resources/templates/transaction_detail.html @@ -9,7 +9,7 @@ - +

diff --git a/src/main/resources/templates/transaction_list.html b/src/main/resources/templates/transaction_list.html index c2befdb..39a0e24 100644 --- a/src/main/resources/templates/transaction_list.html +++ b/src/main/resources/templates/transaction_list.html @@ -9,7 +9,7 @@ - +
diff --git a/src/main/resources/templates/transaction_update.html b/src/main/resources/templates/transaction_update.html index 5b120b1..24822a1 100644 --- a/src/main/resources/templates/transaction_update.html +++ b/src/main/resources/templates/transaction_update.html @@ -9,7 +9,7 @@ - +