7 Commits

17 changed files with 121 additions and 54 deletions

View File

@@ -25,6 +25,8 @@ public class GoalModel {
private Integer goalComplete;
private Integer achievementRate; // 達成率
private Integer currentAmount; // 現在の資産
public static GoalModel convertFrom(GoalEntity goalEntity) {
return new GoalModel(
@@ -34,7 +36,7 @@ public class GoalModel {
goalEntity.getTargetAmount(),
goalEntity.getDeadline(),
goalEntity.getGoalComplete(),
null);
null,null);
}
public static GoalEntity convertTo(GoalModel goalModel) {
@@ -56,7 +58,7 @@ public class GoalModel {
goalForm.getTargetAmount(),
goalForm.getDeadline(),
goalForm.getGoalComplete()
,null);
,null,null);
}
}

View File

@@ -8,4 +8,6 @@ public interface CourseService {
public List<CourseModel> findAll();
public CourseModel findById(Long courseId);
}

View File

@@ -21,4 +21,8 @@ public class CourseServiceImpl implements CourseService {
return CourseEntity.createCourseModelList(courseRepository.findAll());
}
public CourseModel findById(Long courseId) {
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
}
}

View File

@@ -56,7 +56,8 @@ public class GoalServiceImpl implements GoalService {
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
achievementRate);
achievementRate,
currentAmount);
}
@Override

View File

@@ -1,9 +1,14 @@
package com.example.demo.app.infra.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import com.example.demo.app.infra.entity.CourseEntity;
public interface CourseRepository extends JpaRepository<CourseEntity, Long> {
@Query("SELECT c FROM CourseEntity c WHERE c.courseId = :courseId ")
public CourseEntity findByCourseId(Long courseId);
}

View File

@@ -9,6 +9,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.AnalysisModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.AnalysisService;
@@ -23,6 +24,7 @@ public class AnalysisController {
private final AnalysisService analysisService;
@SessionCheck
@GetMapping("/analysis")
public String showAnalysis(
@RequestParam(required = false) Integer year,

View File

@@ -7,6 +7,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.AuthenticationModel;
import com.example.demo.app.domain.service.AuthenticationService;
import com.example.demo.app.infra.repository.QuestionRepository;
@@ -21,6 +22,7 @@ public class AuthenticationController {
private final AuthenticationService authenticationService;
private final QuestionRepository questionRepository;
@SessionCheck
@GetMapping("/authentication")
public String showAuthentication(Model model) {
@@ -29,7 +31,8 @@ public class AuthenticationController {
return "authentication";
}
@SessionCheck
@PostMapping("/authentication")
public String authenticate(
AuthenticationForm authenticationForm,

View File

@@ -7,24 +7,25 @@ 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.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
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.model.UserModel;
import com.example.demo.app.domain.service.CourseInfoService;
import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.domain.service.UserService;
import com.example.demo.app.presentation.form.CourseForm;
import com.example.demo.app.presentation.form.CourseInfoForm;
import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@Controller
@RequestMapping("/course")
//@RequestMapping("/course")
@RequiredArgsConstructor
public class CourseController {
@@ -38,15 +39,18 @@ public class CourseController {
private final UserService userService;
@PostMapping("/select/register")
public String showSelectCourse(@ModelAttribute UserModel userModel, Model model) {
@SessionCheck
@GetMapping("/course/select/register")
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
try {
System.out.println(userForm.getMailAddress());
model.addAttribute("mode", "select");
session.setAttribute("userForm", userForm);
model.addAttribute("mode", "regist");
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
return "select_course";
@@ -63,7 +67,8 @@ public class CourseController {
}
}
@PostMapping("/select/change")
@SessionCheck
@GetMapping("/select/change")
public String showChangeCourse(Model model) {
try {
@@ -87,6 +92,7 @@ public class CourseController {
}
}
@SessionCheck
@PostMapping("/change")
public String changeCourse(@RequestParam Long courseId) {

View File

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.GoalModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.GoalService;
@@ -23,6 +24,7 @@ public class GoalController {
private final GoalService goalService;
@SessionCheck
@GetMapping("")
public String getGoal(Model model, HttpSession session) {
@@ -37,6 +39,7 @@ public class GoalController {
return "goal_view";
}
@SessionCheck
@GetMapping("/edit")
public String editGoal(Model model, HttpSession session) {
@@ -50,6 +53,7 @@ public class GoalController {
return "goal_edit";
}
@SessionCheck
@PostMapping("/update")
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) {

View File

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.model.ProfileModel;
import com.example.demo.app.domain.service.ProfileService;
@@ -21,6 +22,7 @@ import lombok.RequiredArgsConstructor;
public class ProfileController {
private final ProfileService profileService;
@SessionCheck
@GetMapping("/profile")
public String profile(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
@@ -33,6 +35,7 @@ public class ProfileController {
return "profile";
}
@SessionCheck
@GetMapping("/profile/edit")
public String showEditProfile(
Model model,
@@ -84,6 +87,7 @@ public class ProfileController {
return "redirect:/login";
}
@PostMapping("/logout")
public String logout(HttpSession session) {
session.invalidate();

View File

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
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.GoalService;
@@ -41,6 +42,7 @@ public class TransactionController {
private final UserService userService;
// 一覧画面
@SessionCheck
@GetMapping("/transaction/list")
public String transactionList(
@RequestParam(required = false, defaultValue = "0") String years,
@@ -124,6 +126,7 @@ public class TransactionController {
}
// 詳細画面
@SessionCheck
@GetMapping("/transaction/detail")
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
@@ -176,6 +179,7 @@ public class TransactionController {
return "transaction_detail";
}
@SessionCheck
@GetMapping("/transaction/create")
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
Model model) {
@@ -200,6 +204,7 @@ public class TransactionController {
return "transaction_create";
}
@SessionCheck
@PostMapping("/transaction/create")
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today,
Model model,
@@ -215,6 +220,7 @@ public class TransactionController {
}
@SessionCheck
@GetMapping("/transaction/update")
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
Model model) {
@@ -246,6 +252,7 @@ public class TransactionController {
}
@SessionCheck
@PostMapping("/transaction/update")
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm,
@RequestParam LocalDate today, Model model,
@@ -264,6 +271,7 @@ public class TransactionController {
}
@SessionCheck
@PostMapping("/transaction/delete")
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
@@ -271,6 +279,7 @@ public class TransactionController {
return "redirect:/transaction/detail?todayDates=" + today;
}
@SessionCheck
@GetMapping("/menu")
public String menu(HttpSession session, Model model,
@RequestParam(required = false, defaultValue = "0") String years,
@@ -335,6 +344,8 @@ public class TransactionController {
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
model.addAttribute("achievementRate", goalForm.getAchievementRate());
model.addAttribute("currentAmount", goalForm.getCurrentAmount());
model.addAttribute("targetAmount", goalForm.getTargetAmount());

View File

@@ -7,24 +7,45 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class UserController {
private final CourseService courseService;
@GetMapping("/user/register")
public String showRegister(Model model, HttpSession session) {
UserForm userForm = new UserForm();
model.addAttribute("userForm", userForm);
return "user_register";
}
@PostMapping("/user/register/return")
public String showRegisterReturn(@RequestParam(required = false) Long courseId, Model model, HttpSession session) {
UserForm userForm = (UserForm) session.getAttribute("userForm");
if(userForm == null) {
userForm = new UserForm();
userForm.setCourseId(courseId);
}
if(courseId != null) {
model.addAttribute("selectedCourseName", courseService.findById(courseId).getCourseName());
}
model.addAttribute("courseId", courseId);
model.addAttribute("userForm", userForm);
return "user_register";
}

View File

@@ -29,6 +29,8 @@ public class GoalForm {
private Integer goalComplete;
private Integer achievementRate; // 達成率
private Integer currentAmount; // 現在の資産
public static GoalForm convertFrom(GoalModel goalModel) {
return new GoalForm(
@@ -38,7 +40,8 @@ public class GoalForm {
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
goalModel.getAchievementRate());
goalModel.getAchievementRate(),
goalModel.getCurrentAmount());
}
// public static List<GoalForm> convertFrom(List<GoalModel> goalModelList) {

View File

@@ -14,7 +14,6 @@
<h1>目標詳細</h1>
<table>
<tr>
<th>目標名</th>
<td th:text="${goalForm.goalTitle}"></td>

View File

@@ -118,6 +118,13 @@
<span th:text="${targetAmount}"></span>
<span>円</span>
</div>
<div>
<span>現在高</span>
<span th:text="${currentAmount}"></span>
<span>円</span>
</div>
<div>
<span>貯金額</span>
<span th:text="${saving}"></span>

View File

@@ -4,14 +4,15 @@
<meta charset="UTF-8">
<title>パスワード再設定</title>
</head>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<body>
<!--<body class="pb-5 pt-5">-->
<!-- <div th:replace="~{header :: header}">-->
<!-- </div>-->
<main>
<h1>パスワード再設定</h1>
<form th:action="@{/password_reset}" th:object="${passwordResetForm}" method="post">
<form th:action="@{/password/reset}" th:object="${passwordResetForm}" method="post">
<div>
<label for="password">新しいパスワード</label>
<input type="password"

View File

@@ -9,42 +9,34 @@
<body>
<h1>コース選択</h1>
<form th:action="@{/user/register}" th:object="${userForm}" method="post">
<input type="hidden" th:field="*{userName}">
<input type="hidden" th:field="*{mailAddress}">
<input type="hidden" th:field="*{birthDate}">
<input type="hidden" th:field="*{password}">
<input type="hidden" th:field="*{secretQuestionId}">
<input type="hidden" th:field="*{secretAnswer}">
<input type="hidden" th:field="*{saving}">
<input type="hidden" th:field="*{annualIncome}">
<input type="hidden" th:field="*{monthlyBudget}">
<input type="hidden" th:field="*{targetAmount}">
<button type="submit">確定</button>
<div class="accordion" id="accordionExample">
<div class="accordion-item" th:each="course:${courseList}">
<h2 class="accordion-header d-flex align-items-center">
<input type="radio" name="courseId" th:value="${course.courseId}" class="form-check-input ms-3 me-2">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#collapse' + ${course.courseId}" aria-expanded="false" aria-controls="'collapse' + ${course.courseId}">
<span th:text="${course.courseName}"></span>
</button>
</h2>
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
<div class="accordion-body">
<span th:text="${course.description}"></span>
<table border="1">
<tr>
<th>カテゴリ名</th><th>配分(%)</th>
</tr>
<tr th:each="courseInfo:${courseInfoList}" th:if="${course.courseId == courseInfo.courseId}">
<td th:text="${courseInfo.categoryName}"></td>
<td th:text="${courseInfo.allocationRatio}"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
<button type="submit">確定</button>
<div class="accordion" id="accordionExample">
<div class="accordion-item" th:each="course:${courseList}">
<h2 class="accordion-header d-flex align-items-center">
<input type="radio" name="courseId" th:value="${course.courseId}" class="form-check-input ms-3 me-2">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#collapse' + ${course.courseId}" aria-expanded="false" aria-controls="'collapse' + ${course.courseId}">
<span th:text="${course.courseName}"></span>
</button>
</h2>
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
<div class="accordion-body">
<span th:text="${course.description}"></span>
<table border="1">
<tr>
<th>カテゴリ名</th><th>配分(%)</th>
</tr>
<tr th:each="courseInfo:${courseInfoList}" th:if="${course.courseId == courseInfo.courseId}">
<td th:text="${courseInfo.categoryName}"></td>
<td th:text="${courseInfo.allocationRatio}"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</form>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>