7 Commits

17 changed files with 121 additions and 54 deletions

View File

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

View File

@@ -8,4 +8,6 @@ public interface CourseService {
public List<CourseModel> findAll(); 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()); 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.getTargetAmount(),
goalModel.getDeadline(), goalModel.getDeadline(),
goalModel.getGoalComplete(), goalModel.getGoalComplete(),
achievementRate); achievementRate,
currentAmount);
} }
@Override @Override

View File

@@ -1,9 +1,14 @@
package com.example.demo.app.infra.repository; package com.example.demo.app.infra.repository;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import com.example.demo.app.infra.entity.CourseEntity; import com.example.demo.app.infra.entity.CourseEntity;
public interface CourseRepository extends JpaRepository<CourseEntity, Long> { 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.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; 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.AnalysisModel;
import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.AnalysisService; import com.example.demo.app.domain.service.AnalysisService;
@@ -23,6 +24,7 @@ public class AnalysisController {
private final AnalysisService analysisService; private final AnalysisService analysisService;
@SessionCheck
@GetMapping("/analysis") @GetMapping("/analysis")
public String showAnalysis( public String showAnalysis(
@RequestParam(required = false) Integer year, @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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; 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.model.AuthenticationModel;
import com.example.demo.app.domain.service.AuthenticationService; import com.example.demo.app.domain.service.AuthenticationService;
import com.example.demo.app.infra.repository.QuestionRepository; import com.example.demo.app.infra.repository.QuestionRepository;
@@ -21,6 +22,7 @@ public class AuthenticationController {
private final AuthenticationService authenticationService; private final AuthenticationService authenticationService;
private final QuestionRepository questionRepository; private final QuestionRepository questionRepository;
@SessionCheck
@GetMapping("/authentication") @GetMapping("/authentication")
public String showAuthentication(Model model) { public String showAuthentication(Model model) {
@@ -30,6 +32,7 @@ public class AuthenticationController {
return "authentication"; return "authentication";
} }
@SessionCheck
@PostMapping("/authentication") @PostMapping("/authentication")
public String authenticate( public String authenticate(
AuthenticationForm authenticationForm, AuthenticationForm authenticationForm,

View File

@@ -7,24 +7,25 @@ import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; 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.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; 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.LoginModel;
import com.example.demo.app.domain.model.UserModel;
import com.example.demo.app.domain.service.CourseInfoService; import com.example.demo.app.domain.service.CourseInfoService;
import com.example.demo.app.domain.service.CourseService; import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.domain.service.UserService; import com.example.demo.app.domain.service.UserService;
import com.example.demo.app.presentation.form.CourseForm; import com.example.demo.app.presentation.form.CourseForm;
import com.example.demo.app.presentation.form.CourseInfoForm; import com.example.demo.app.presentation.form.CourseInfoForm;
import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@Controller @Controller
@RequestMapping("/course") //@RequestMapping("/course")
@RequiredArgsConstructor @RequiredArgsConstructor
public class CourseController { public class CourseController {
@@ -38,16 +39,19 @@ public class CourseController {
private final UserService userService; private final UserService userService;
@SessionCheck
@PostMapping("/select/register") @GetMapping("/course/select/register")
public String showSelectCourse(@ModelAttribute UserModel userModel, Model model) { public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
try { 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("courseList", CourseForm.convertFrom(courseService.findAll()));
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll())); model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
return "select_course"; return "select_course";
} catch (Exception e) { } catch (Exception e) {
@@ -63,7 +67,8 @@ public class CourseController {
} }
} }
@PostMapping("/select/change") @SessionCheck
@GetMapping("/select/change")
public String showChangeCourse(Model model) { public String showChangeCourse(Model model) {
try { try {
@@ -87,6 +92,7 @@ public class CourseController {
} }
} }
@SessionCheck
@PostMapping("/change") @PostMapping("/change")
public String changeCourse(@RequestParam Long courseId) { 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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; 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.GoalModel;
import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.GoalService; import com.example.demo.app.domain.service.GoalService;
@@ -23,6 +24,7 @@ public class GoalController {
private final GoalService goalService; private final GoalService goalService;
@SessionCheck
@GetMapping("") @GetMapping("")
public String getGoal(Model model, HttpSession session) { public String getGoal(Model model, HttpSession session) {
@@ -37,6 +39,7 @@ public class GoalController {
return "goal_view"; return "goal_view";
} }
@SessionCheck
@GetMapping("/edit") @GetMapping("/edit")
public String editGoal(Model model, HttpSession session) { public String editGoal(Model model, HttpSession session) {
@@ -50,6 +53,7 @@ public class GoalController {
return "goal_edit"; return "goal_edit";
} }
@SessionCheck
@PostMapping("/update") @PostMapping("/update")
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) { 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.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping; 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.LoginModel;
import com.example.demo.app.domain.model.ProfileModel; import com.example.demo.app.domain.model.ProfileModel;
import com.example.demo.app.domain.service.ProfileService; import com.example.demo.app.domain.service.ProfileService;
@@ -21,6 +22,7 @@ import lombok.RequiredArgsConstructor;
public class ProfileController { public class ProfileController {
private final ProfileService profileService; private final ProfileService profileService;
@SessionCheck
@GetMapping("/profile") @GetMapping("/profile")
public String profile(Model model, HttpSession session) { public String profile(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
@@ -33,6 +35,7 @@ public class ProfileController {
return "profile"; return "profile";
} }
@SessionCheck
@GetMapping("/profile/edit") @GetMapping("/profile/edit")
public String showEditProfile( public String showEditProfile(
Model model, Model model,
@@ -84,6 +87,7 @@ public class ProfileController {
return "redirect:/login"; return "redirect:/login";
} }
@PostMapping("/logout") @PostMapping("/logout")
public String logout(HttpSession session) { public String logout(HttpSession session) {
session.invalidate(); 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.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; 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.LoginModel;
import com.example.demo.app.domain.service.CategoryService; import com.example.demo.app.domain.service.CategoryService;
import com.example.demo.app.domain.service.GoalService; import com.example.demo.app.domain.service.GoalService;
@@ -41,6 +42,7 @@ public class TransactionController {
private final UserService userService; private final UserService userService;
// 一覧画面 // 一覧画面
@SessionCheck
@GetMapping("/transaction/list") @GetMapping("/transaction/list")
public String transactionList( public String transactionList(
@RequestParam(required = false, defaultValue = "0") String years, @RequestParam(required = false, defaultValue = "0") String years,
@@ -124,6 +126,7 @@ public class TransactionController {
} }
// 詳細画面 // 詳細画面
@SessionCheck
@GetMapping("/transaction/detail") @GetMapping("/transaction/detail")
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) { public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
@@ -176,6 +179,7 @@ public class TransactionController {
return "transaction_detail"; return "transaction_detail";
} }
@SessionCheck
@GetMapping("/transaction/create") @GetMapping("/transaction/create")
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today, public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
Model model) { Model model) {
@@ -200,6 +204,7 @@ public class TransactionController {
return "transaction_create"; return "transaction_create";
} }
@SessionCheck
@PostMapping("/transaction/create") @PostMapping("/transaction/create")
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today,
Model model, Model model,
@@ -215,6 +220,7 @@ public class TransactionController {
} }
@SessionCheck
@GetMapping("/transaction/update") @GetMapping("/transaction/update")
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today, public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
Model model) { Model model) {
@@ -246,6 +252,7 @@ public class TransactionController {
} }
@SessionCheck
@PostMapping("/transaction/update") @PostMapping("/transaction/update")
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm, public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm,
@RequestParam LocalDate today, Model model, @RequestParam LocalDate today, Model model,
@@ -264,6 +271,7 @@ public class TransactionController {
} }
@SessionCheck
@PostMapping("/transaction/delete") @PostMapping("/transaction/delete")
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) { public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
@@ -271,6 +279,7 @@ public class TransactionController {
return "redirect:/transaction/detail?todayDates=" + today; return "redirect:/transaction/detail?todayDates=" + today;
} }
@SessionCheck
@GetMapping("/menu") @GetMapping("/menu")
public String menu(HttpSession session, Model model, public String menu(HttpSession session, Model model,
@RequestParam(required = false, defaultValue = "0") String years, @RequestParam(required = false, defaultValue = "0") String years,
@@ -336,6 +345,8 @@ public class TransactionController {
model.addAttribute("achievementRate", goalForm.getAchievementRate()); model.addAttribute("achievementRate", goalForm.getAchievementRate());
model.addAttribute("currentAmount", goalForm.getCurrentAmount());
model.addAttribute("targetAmount", goalForm.getTargetAmount()); model.addAttribute("targetAmount", goalForm.getTargetAmount());
model.addAttribute("saving", userForm.getSaving()); model.addAttribute("saving", userForm.getSaving());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,17 +9,9 @@
<body> <body>
<h1>コース選択</h1> <h1>コース選択</h1>
<form th:action="@{/user/register}" th:object="${userForm}" method="post">
<input type="hidden" th:field="*{userName}">
<input type="hidden" th:field="*{mailAddress}"> <form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
<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> <button type="submit">確定</button>
<div class="accordion" id="accordionExample"> <div class="accordion" id="accordionExample">
<div class="accordion-item" th:each="course:${courseList}"> <div class="accordion-item" th:each="course:${courseList}">