From a73516297473893d456bd5722e04c26c10e6b95a Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Thu, 17 Sep 2026 14:43:11 +0900 Subject: [PATCH 01/12] =?UTF-8?q?[EDIT]=E6=94=AF=E5=87=BA=E5=88=86?= =?UTF-8?q?=E6=9E=90=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AE=E3=82=B5=E3=83=BC?= =?UTF-8?q?=E3=83=93=E3=82=B9=E5=AE=9F=E8=A3=85=E9=83=A8=E5=88=86=E3=82=92?= =?UTF-8?q?=E8=A8=98=E8=BF=B0=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 --- .../service/impl/AnalysisServiceImpl.java | 132 ++++++++++++++++-- 1 file changed, 117 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java index 66f4bbc..d0f3388 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java @@ -1,9 +1,21 @@ package com.example.demo.app.domain.service.impl; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + import org.springframework.stereotype.Service; import com.example.demo.app.domain.model.AnalysisModel; +import com.example.demo.app.domain.model.CategoryAnalysisModel; import com.example.demo.app.domain.service.AnalysisService; +import com.example.demo.app.infra.entity.AllocationEntity; +import com.example.demo.app.infra.entity.CategoryEntity; +import com.example.demo.app.infra.entity.UserEntity; +import com.example.demo.app.infra.repository.AllocationRepository; +import com.example.demo.app.infra.repository.CategoryRepository; +import com.example.demo.app.infra.repository.TransactionRepository; +import com.example.demo.app.infra.repository.UserRepository; import lombok.RequiredArgsConstructor; @@ -12,29 +24,119 @@ import lombok.RequiredArgsConstructor; public class AnalysisServiceImpl implements AnalysisService { //Repositoryの呼び出し -// private final TransactionRepository transactionRepository; -// private final AllocationRepository allocationRepository; -// private final UserRepository userRepository; -// private final CategoryRepository categoryRepository; + private final TransactionRepository transactionRepository; + private final AllocationRepository allocationRepository; + private final UserRepository userRepository; + private final CategoryRepository categoryRepository; @Override public AnalysisModel getAnalysis(Long userId) { // ユーザー情報取得、月別使用可能資金取得 + UserEntity userEntity = userRepository.findById(userId).orElseThrow(); + + // コースID取得 + Long courseId = userEntity.getCourseEntity().getCourseId(); + + // 月別使用可能資金取得 + Integer monthlyBudget =userEntity.getMonthlyBudget(); // 今月の期間取得 - // 前月の期間取得 - // 今月の支出取得 - // 前月の支出取得 - // コース配分取得 - // カテゴリ別集計 - // 前月との差額集計 - //総支出算出 - // コース限度額算出、コース別差額算出 - // CategoryAnalysisModel生成 - // AnalysisModelの生成 + LocalDate currentMonthStartDate = LocalDate.now().withDayOfMonth(1); + LocalDate currentMonthEndDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()); - return null; + // 前月の期間取得 + LocalDate previousMonthStartDate = LocalDate.now().minusMonths(1).withDayOfMonth(1); + LocalDate previousMonthEndDate = LocalDate.now().minusMonths(1).withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()); + + // 今月の支出取得 + Integer currentMonthTotalAmount = transactionRepository.findTotalExpense(currentMonthStartDate, currentMonthEndDate, userId); + + if (currentMonthTotalAmount == null) { + currentMonthTotalAmount = 0; + } + + // 前月の支出取得 + Integer previousMonthTotalAmount = transactionRepository.findTotalExpense(previousMonthStartDate, previousMonthEndDate, userId); + + if (previousMonthTotalAmount == null) { + previousMonthTotalAmount = 0; + } + + //総支出差額算出 + Integer totalDifferenceAmount = currentMonthTotalAmount - previousMonthTotalAmount; + + //カテゴリ一覧取得 + List categoryAnalysisModelList = new ArrayList<>(); + List categoryEntityList = categoryRepository.findAll(); + List allocationEntityList = allocationRepository.findByCourseEntity_CourseId(courseId); + + //取得ループ + for (CategoryEntity categoryEntity : categoryEntityList) { + + if (categoryEntity.getTransactionType() != 0) { + continue; + } + // カテゴリ別今月金額取得 + Integer currentMonthAmount = + transactionRepository.findCategoryExpense(currentMonthStartDate, + currentMonthEndDate, + userId, + categoryEntity.getCategoryId()); + + // カテゴリ別前月金額取得 + Integer previousMonthAmount = + transactionRepository.findCategoryExpense(previousMonthStartDate, + previousMonthEndDate, + userId, + categoryEntity.getCategoryId()); + + if (currentMonthAmount == null) { + currentMonthAmount = 0; + } + + if (previousMonthAmount == null) { + previousMonthAmount = 0; + } + + // カテゴリ別前月差額算出 + Integer monthDifferenceAmount = currentMonthAmount - previousMonthAmount; + + // コース配分取得 + AllocationEntity allocationEntity = allocationEntityList.stream().filter(allocation -> + allocation.getCategoryEntity() + .getCategoryId() + .equals(categoryEntity.getCategoryId())) + .findFirst() + .orElse(null); + + Integer allocationRatio = 0; + + if (allocationEntity != null) { + allocationRatio = + allocationEntity.getAllocationRatio(); + } + + // コース限度額算出 + Integer courseLimitAmount = monthlyBudget * allocationRatio / 100; + + // コース差額算出 + Integer courseDifferenceAmount = currentMonthAmount - courseLimitAmount; + + // CategoryAnalysisModel生成 + CategoryAnalysisModel categoryAnalysisModel = new CategoryAnalysisModel( + categoryEntity.getCategoryName(), + currentMonthAmount, + previousMonthAmount, + monthDifferenceAmount, + courseLimitAmount, + courseDifferenceAmount); + + categoryAnalysisModelList.add(categoryAnalysisModel); + } + + // AnalysisModelの生成 + return new AnalysisModel(currentMonthTotalAmount, previousMonthTotalAmount, totalDifferenceAmount, categoryAnalysisModelList); } } From ca7e93908dd38b38dbeb54a610e6768049da00e4 Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Thu, 17 Sep 2026 14:43:44 +0900 Subject: [PATCH 02/12] =?UTF-8?q?[FIX]HOTFIX=E3=81=AB=E5=90=88=E3=82=8F?= =?UTF-8?q?=E3=81=9B=E3=81=A6=E3=80=81=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=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 --- .../example/demo/app/domain/model/CategoryAnalysisModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java b/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java index 3a94930..47cdadf 100644 --- a/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java +++ b/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java @@ -13,7 +13,7 @@ public class CategoryAnalysisModel { private Integer previousMonthAmount; - private Integer previousMonthDifferenceAmount; + private Integer monthDifferenceAmount; private Integer courseLimitAmount; From a5799843d335e1b80402f55243a71ab9b6f90572 Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Thu, 17 Sep 2026 15:33:02 +0900 Subject: [PATCH 03/12] =?UTF-8?q?[ADD]=E6=94=AF=E5=87=BA=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AEform?= =?UTF-8?q?=E3=82=AF=E3=83=A9=E3=82=B9=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 --- .../app/presentation/form/AnalysisForm.java | 32 +++++++++++++ .../form/CategoryAnalysisForm.java | 48 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java create mode 100644 src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java diff --git a/src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java b/src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java new file mode 100644 index 0000000..c9c4202 --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java @@ -0,0 +1,32 @@ +package com.example.demo.app.presentation.form; + +import java.util.List; + +import com.example.demo.app.domain.model.AnalysisModel; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AnalysisForm { + + private Integer currentMonthTotalAmount; + private Integer previousMonthTotalAmount; + private Integer totalDifferenceAmount; + private List categoryAnalysisFormList; + + public static AnalysisForm convertFrom( + AnalysisModel analysisModel) { + + return new AnalysisForm( + analysisModel.getCurrentMonthTotalAmount(), + analysisModel.getPreviousMonthTotalAmount(), + analysisModel.getTotalDifferenceAmount(), + CategoryAnalysisForm.convertFrom( + analysisModel.getCategoryAnalysisModelList())); + } + +} diff --git a/src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java b/src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java new file mode 100644 index 0000000..add1762 --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java @@ -0,0 +1,48 @@ +package com.example.demo.app.presentation.form; + +import java.util.List; + +import com.example.demo.app.domain.model.CategoryAnalysisModel; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CategoryAnalysisForm { + + private String categoryName; + + private Integer currentMonthAmount; + + private Integer previousMonthAmount; + + private Integer monthDifferenceAmount; + + private Integer courseLimitAmount; + + private Integer courseDifferenceAmount; + + public static CategoryAnalysisForm convertFrom( + + CategoryAnalysisModel categoryAnalysisModel) { + return new CategoryAnalysisForm( + categoryAnalysisModel.getCategoryName(), + categoryAnalysisModel.getCurrentMonthAmount(), + categoryAnalysisModel.getPreviousMonthAmount(), + categoryAnalysisModel.getMonthDifferenceAmount(), + categoryAnalysisModel.getCourseLimitAmount(), + categoryAnalysisModel.getCourseDifferenceAmount()); + } + + public static List convertFrom( + List categoryAnalysisModelList) { + + return categoryAnalysisModelList.stream() + .map(CategoryAnalysisForm::convertFrom) + .toList(); + } + +} From 9b51b26b0ebc384079b835bd188617a6dc060bd6 Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Thu, 17 Sep 2026 15:33:55 +0900 Subject: [PATCH 04/12] =?UTF-8?q?[EDIT]AnalysisController=E3=81=AEform?= =?UTF-8?q?=E5=A4=89=E6=8F=9B=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E8=BF=BD?= =?UTF-8?q?=E8=A8=98=E3=82=92=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/controller/AnalysisController.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java b/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java index 905f2c3..5bc8cd9 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java @@ -1,10 +1,15 @@ package com.example.demo.app.presentation.controller; +import jakarta.servlet.http.HttpSession; + import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import com.example.demo.app.domain.model.AnalysisModel; +import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.service.AnalysisService; +import com.example.demo.app.presentation.form.AnalysisForm; import lombok.RequiredArgsConstructor; @@ -16,13 +21,18 @@ public class AnalysisController { private final AnalysisService analysisService; @GetMapping("/analysis") - public String showAnalysis(Model model) { + public String showAnalysis(Model model, HttpSession session) { //ログインユーザーの取得(セッション) + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); //分析結果の取得(Service) + AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId()); + AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel); + //model格納 + model.addAttribute("analysisForm", analysisForm); return "analysis"; } From cbaee01d13d0652bd4d3e2e42fa3d64f19c01468 Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Thu, 17 Sep 2026 15:48:17 +0900 Subject: [PATCH 05/12] =?UTF-8?q?[EDIT]=E6=94=AF=E5=87=BA=E5=88=86?= =?UTF-8?q?=E6=9E=90=E7=94=BB=E9=9D=A2=E3=82=92=E8=BF=BD=E8=A8=98=E3=81=97?= =?UTF-8?q?=E3=80=81=E4=BD=9C=E6=88=90=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 --- src/main/resources/templates/analysis.html | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/main/resources/templates/analysis.html b/src/main/resources/templates/analysis.html index 31b6d9b..9415ae2 100644 --- a/src/main/resources/templates/analysis.html +++ b/src/main/resources/templates/analysis.html @@ -20,8 +20,8 @@ 総支出 - ¥234,000 - +¥38,000 + 0 + 0 @@ -33,24 +33,32 @@ カテゴリ別 支出 - 前月比
コース比 + + 前月比 +
+ コース比 + - - 食費 - ¥34,000 - +¥8,000
+¥1,100 - - - 交通費 - ¥14,000 - +¥8,000
+¥1,100 - - - 日用品 - ¥4,000 - +¥8,000
+¥1,100 + + + + 食費 + + + + 0 + + + + + +
+ + + From a89c54f8c0be3b81503242377b8cf852a9dc698a Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 15:49:11 +0900 Subject: [PATCH 06/12] =?UTF-8?q?[ADD]=20Course,=20CoureseInfo=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=93=E3=82=B9=E3=81=A8=E3=81=9D=E3=82=8C?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97=E3=81=9F=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=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 --- .../app/domain/service/CourseInfoService.java | 10 ++++++++ .../app/domain/service/CourseService.java | 11 +++++++++ .../service/impl/CourseInfoServiceImpl.java | 23 ++++++++++++++++++ .../service/impl/CourseServiceImpl.java | 24 +++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 src/main/java/com/example/demo/app/domain/service/CourseInfoService.java create mode 100644 src/main/java/com/example/demo/app/domain/service/CourseService.java create mode 100644 src/main/java/com/example/demo/app/domain/service/impl/CourseInfoServiceImpl.java create mode 100644 src/main/java/com/example/demo/app/domain/service/impl/CourseServiceImpl.java diff --git a/src/main/java/com/example/demo/app/domain/service/CourseInfoService.java b/src/main/java/com/example/demo/app/domain/service/CourseInfoService.java new file mode 100644 index 0000000..83cf4ab --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/CourseInfoService.java @@ -0,0 +1,10 @@ +package com.example.demo.app.domain.service; + +import java.util.List; + +import com.example.demo.app.domain.model.CourseInfoModel; + +public interface CourseInfoService { + + public List findAll(); +} diff --git a/src/main/java/com/example/demo/app/domain/service/CourseService.java b/src/main/java/com/example/demo/app/domain/service/CourseService.java new file mode 100644 index 0000000..4681860 --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/CourseService.java @@ -0,0 +1,11 @@ +package com.example.demo.app.domain.service; + +import java.util.List; + +import com.example.demo.app.domain.model.CourseModel; + +public interface CourseService { + + public List findAll(); + +} diff --git a/src/main/java/com/example/demo/app/domain/service/impl/CourseInfoServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/CourseInfoServiceImpl.java new file mode 100644 index 0000000..4658a18 --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/impl/CourseInfoServiceImpl.java @@ -0,0 +1,23 @@ +package com.example.demo.app.domain.service.impl; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.example.demo.app.domain.model.CourseInfoModel; +import com.example.demo.app.domain.service.CourseInfoService; +import com.example.demo.app.infra.repository.AllocationRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class CourseInfoServiceImpl implements CourseInfoService { + + private final AllocationRepository allocationRepository; + + @Override + public List findAll() { + return allocationRepository.findAllJoinedAllocation(); + } +} diff --git a/src/main/java/com/example/demo/app/domain/service/impl/CourseServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/CourseServiceImpl.java new file mode 100644 index 0000000..a4dec5f --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/impl/CourseServiceImpl.java @@ -0,0 +1,24 @@ +package com.example.demo.app.domain.service.impl; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.example.demo.app.domain.model.CourseModel; +import com.example.demo.app.domain.service.CourseService; +import com.example.demo.app.infra.entity.CourseEntity; +import com.example.demo.app.infra.repository.CourseRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class CourseServiceImpl implements CourseService { + + private final CourseRepository courseRepository; + + public List findAll(){ + return CourseEntity.createCourseModelList(courseRepository.findAll()); + } + +} From 1e0946398414163441ac7ac510b8be69bcf80a04 Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 15:50:11 +0900 Subject: [PATCH 07/12] =?UTF-8?q?[ADD]=20=E3=82=B3=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E9=81=B8=E6=8A=9E=E7=94=BB=E9=9D=A2=E3=81=AB=E9=81=B7=E7=A7=BB?= =?UTF-8?q?=E3=81=99=E3=82=8BCourseController=E3=82=92=E4=BD=9C=E6=88=90?= =?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/CourseController.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/com/example/demo/app/presentation/controller/CourseController.java diff --git a/src/main/java/com/example/demo/app/presentation/controller/CourseController.java b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java new file mode 100644 index 0000000..c9199af --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java @@ -0,0 +1,52 @@ +package com.example.demo.app.presentation.controller; + +import java.util.logging.Logger; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +import com.example.demo.app.domain.service.CourseInfoService; +import com.example.demo.app.domain.service.CourseService; +import com.example.demo.app.presentation.form.CourseForm; +import com.example.demo.app.presentation.form.CourseInfoForm; + +import lombok.RequiredArgsConstructor; + + +@Controller +@RequiredArgsConstructor +public class CourseController { + + private final static Logger LOGGER = Logger.getLogger(CourseController.class.getName()); + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + + // private final HttpSession httpSession; + private final CourseService courseService; + private final CourseInfoService courseInfoService; + + + + @GetMapping("/select-course") + public String select(Model model) { + + //try { + model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll())); + model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll())); + + return "select-course"; + + //} catch (Exception e) { +// // ログイン情報の破棄 +// httpSession.invalidate(); +// +// e.printStackTrace(); +// +// // エラーログ出力 +// LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); +// // エラー画面遷移 +// return null; +// } + } +} From bda791567cb7f91ff683f2e4245691ea07befcc8 Mon Sep 17 00:00:00 2001 From: kkazuya Date: Thu, 17 Sep 2026 15:50:43 +0900 Subject: [PATCH 08/12] =?UTF-8?q?[ADD]=20=E3=82=B3=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E9=81=B8=E6=8A=9E=E7=94=BB=E9=9D=A2=E3=82=92=E4=BD=9C=E6=88=90?= =?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 --- .../resources/templates/select_course.html | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/resources/templates/select_course.html diff --git a/src/main/resources/templates/select_course.html b/src/main/resources/templates/select_course.html new file mode 100644 index 0000000..6718ef4 --- /dev/null +++ b/src/main/resources/templates/select_course.html @@ -0,0 +1,35 @@ + + + + +コース選択 + + + +
+
+

+ +

+
+
+ + + + 配分(%) + + + + + +
カテゴリ名
+
+
+
+
+ + + + \ No newline at end of file From 192191d352f1a468d450890424445c7383c82262 Mon Sep 17 00:00:00 2001 From: s-morimoto Date: Thu, 17 Sep 2026 15:59:33 +0900 Subject: [PATCH 09/12] =?UTF-8?q?[ADD]=E3=83=91=E3=82=B9=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E5=86=8D=E8=A8=AD=E5=AE=9A=E3=81=AE=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/service/PasswordResetService.java | 8 +++ .../impl/PasswordResetServiceImpl.java | 41 +++++++++++++ .../controller/PasswordResetController.java | 61 +++++++++++++++++++ .../presentation/form/PasswordResetForm.java | 13 ++++ .../resources/templates/password_reset.html | 42 +++++++++++++ .../templates/user_register_confirm.html | 2 +- 6 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/example/demo/app/domain/service/PasswordResetService.java create mode 100644 src/main/java/com/example/demo/app/domain/service/impl/PasswordResetServiceImpl.java create mode 100644 src/main/java/com/example/demo/app/presentation/controller/PasswordResetController.java create mode 100644 src/main/java/com/example/demo/app/presentation/form/PasswordResetForm.java create mode 100644 src/main/resources/templates/password_reset.html diff --git a/src/main/java/com/example/demo/app/domain/service/PasswordResetService.java b/src/main/java/com/example/demo/app/domain/service/PasswordResetService.java new file mode 100644 index 0000000..ec1140e --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/PasswordResetService.java @@ -0,0 +1,8 @@ +package com.example.demo.app.domain.service; + +import com.example.demo.app.presentation.form.PasswordResetForm; + +public interface PasswordResetService { + + boolean resetPassword(Long userId, PasswordResetForm passwordResetForm); +} diff --git a/src/main/java/com/example/demo/app/domain/service/impl/PasswordResetServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/PasswordResetServiceImpl.java new file mode 100644 index 0000000..2866cea --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/impl/PasswordResetServiceImpl.java @@ -0,0 +1,41 @@ +package com.example.demo.app.domain.service.impl; + +import org.springframework.stereotype.Service; + +import com.example.demo.app.domain.service.PasswordResetService; +import com.example.demo.app.infra.entity.UserEntity; +import com.example.demo.app.infra.repository.UserRepository; +import com.example.demo.app.presentation.form.PasswordResetForm; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class PasswordResetServiceImpl implements PasswordResetService { + + private final UserRepository userRepository; + + @Override + public boolean resetPassword( + Long userId, + PasswordResetForm passwordResetForm) { + + if (!passwordResetForm.getPassword() + .equals(passwordResetForm.getPasswordConfirm())) { + return false; + } + + UserEntity userEntity = + userRepository.findById(userId).orElse(null); + + if (userEntity == null) { + return false; + } + + userEntity.setPassword(passwordResetForm.getPassword()); + + userRepository.save(userEntity); + + return true; + } +} diff --git a/src/main/java/com/example/demo/app/presentation/controller/PasswordResetController.java b/src/main/java/com/example/demo/app/presentation/controller/PasswordResetController.java new file mode 100644 index 0000000..b5fcfba --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/controller/PasswordResetController.java @@ -0,0 +1,61 @@ +package com.example.demo.app.presentation.controller; + +import jakarta.servlet.http.HttpSession; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; + +import com.example.demo.app.domain.service.PasswordResetService; +import com.example.demo.app.presentation.form.PasswordResetForm; + +import lombok.RequiredArgsConstructor; + +@Controller +@RequiredArgsConstructor +public class PasswordResetController { + + private final PasswordResetService passwordResetService; + + @GetMapping("/password_reset") + public String showPasswordReset(Model model) { + + model.addAttribute( + "passwordResetForm", + new PasswordResetForm()); + + return "password_reset"; + } + + @PostMapping("/password_reset") + public String resetPassword( + PasswordResetForm passwordResetForm, + Model model, + HttpSession session) { + + Long userId = + (Long) session.getAttribute("passwordResetUserId"); + + if (userId == null) { + return "redirect:/login"; + } + + boolean isReset = + passwordResetService.resetPassword( + userId, + passwordResetForm); + + if (!isReset) { + model.addAttribute( + "errorMessage", + "パスワードが一致していません。"); + + return "password_reset"; + } + + session.removeAttribute("passwordResetUserId"); + + return "redirect:/login"; + } +} diff --git a/src/main/java/com/example/demo/app/presentation/form/PasswordResetForm.java b/src/main/java/com/example/demo/app/presentation/form/PasswordResetForm.java new file mode 100644 index 0000000..3213e1b --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/PasswordResetForm.java @@ -0,0 +1,13 @@ +package com.example.demo.app.presentation.form; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PasswordResetForm { + private String password; + private String passwordConfirm; +} diff --git a/src/main/resources/templates/password_reset.html b/src/main/resources/templates/password_reset.html new file mode 100644 index 0000000..522fd4b --- /dev/null +++ b/src/main/resources/templates/password_reset.html @@ -0,0 +1,42 @@ + + + + +パスワード再設定 + + +
+ +
+

パスワード再設定

+ +
+
+ + +
+ +
+ + +
+ + +
+ +
+

+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/user_register_confirm.html b/src/main/resources/templates/user_register_confirm.html index aad56dd..2b35041 100644 --- a/src/main/resources/templates/user_register_confirm.html +++ b/src/main/resources/templates/user_register_confirm.html @@ -1,5 +1,5 @@ - + 新規会員登録確認 From 4e3477af77d60204e34b233881f962caf87405fd Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Thu, 17 Sep 2026 16:07:35 +0900 Subject: [PATCH 10/12] =?UTF-8?q?[EDIT]=E5=88=86=E6=9E=90=E5=80=A4?= =?UTF-8?q?=E3=81=AE+-=E8=A1=A8=E8=A8=98=E3=81=A8=E8=89=B2=E5=88=86?= =?UTF-8?q?=E3=81=91=E3=81=AB=E3=81=A4=E3=81=84=E3=81=A6=E8=A8=98=E8=BF=B0?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/analysis.html | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/resources/templates/analysis.html b/src/main/resources/templates/analysis.html index 9415ae2..55201dd 100644 --- a/src/main/resources/templates/analysis.html +++ b/src/main/resources/templates/analysis.html @@ -12,7 +12,7 @@ - + @@ -20,8 +20,17 @@ - - + +
カテゴリ別 支出 前月比
総支出00 + 0 + + 0 +
@@ -44,7 +53,7 @@ + th:text="${category.categoryName}"> 食費 @@ -53,10 +62,20 @@ - +
- + From 49ad550839a2778e23fc67706652bbef6448decf Mon Sep 17 00:00:00 2001 From: s-morimoto Date: Thu, 17 Sep 2026 16:25:46 +0900 Subject: [PATCH 11/12] =?UTF-8?q?[EDIT]=E3=83=A1=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=82=A2=E3=83=89=E3=83=AC=E3=82=B9=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/app/infra/repository/UserRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/example/demo/app/infra/repository/UserRepository.java b/src/main/java/com/example/demo/app/infra/repository/UserRepository.java index 239dba4..868dd8a 100644 --- a/src/main/java/com/example/demo/app/infra/repository/UserRepository.java +++ b/src/main/java/com/example/demo/app/infra/repository/UserRepository.java @@ -16,5 +16,6 @@ public interface UserRepository extends JpaRepository { String mailAddress, String password); + Optional findByMailAddress(String mailAddress); } From d87bdfbe916b64083c597bc4e2a627a3d19a69b2 Mon Sep 17 00:00:00 2001 From: s-morimoto Date: Thu, 17 Sep 2026 16:28:23 +0900 Subject: [PATCH 12/12] =?UTF-8?q?[EDIT]controller=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/controller/UserController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/example/demo/app/presentation/controller/UserController.java b/src/main/java/com/example/demo/app/presentation/controller/UserController.java index 2914032..7b2aef4 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/UserController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/UserController.java @@ -31,5 +31,19 @@ public class UserController { return "user_register_confirm"; } + + @PostMapping("/user/register/complete") + public String completeRegister(HttpSession session) { + + UserForm userForm = + (UserForm) session.getAttribute("userForm"); + + // DBへの登録処理 + + session.removeAttribute("userForm"); + + return "redirect:/login"; + } + }