7 Commits

10 changed files with 74 additions and 40 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

@@ -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

@@ -7,11 +7,11 @@ 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;
import com.example.demo.app.presentation.form.AuthenticationForm; import com.example.demo.app.presentation.form.AuthenticationForm;
import com.example.demo.app.presentation.form.PasswordResetForm;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -22,7 +22,6 @@ 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) {
@@ -32,7 +31,6 @@ public class AuthenticationController {
return "authentication"; return "authentication";
} }
@SessionCheck
@PostMapping("/authentication") @PostMapping("/authentication")
public String authenticate( public String authenticate(
AuthenticationForm authenticationForm, AuthenticationForm authenticationForm,
@@ -53,6 +51,10 @@ public class AuthenticationController {
"passwordResetUserId", "passwordResetUserId",
authenticationModel.getUserId()); authenticationModel.getUserId());
model.addAttribute(
"passwordResetForm",
new PasswordResetForm());
return "password_reset"; return "password_reset";
} }

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.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.PasswordResetService; import com.example.demo.app.domain.service.PasswordResetService;
import com.example.demo.app.presentation.form.PasswordResetForm; import com.example.demo.app.presentation.form.PasswordResetForm;
@@ -32,13 +33,24 @@ public class PasswordResetController {
Long userId = Long userId =
(Long) session.getAttribute("passwordResetUserId"); (Long) session.getAttribute("passwordResetUserId");
if(userId == null) { if (userId == null) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
if (loginUser != null) {
userId = loginUser.getUserId();
}
}
if (userId == null) {
return "redirect:/login"; return "redirect:/login";
} }
boolean isReset = boolean isReset =
passwordResetService.resetPassword(userId, passwordResetForm); passwordResetService.resetPassword(userId, passwordResetForm);
System.out.println("isReset=" + isReset);
if(!isReset) { if(!isReset) {
model.addAttribute("Message", "パスワードが一致しません。"); model.addAttribute("Message", "パスワードが一致しません。");
return "password_reset"; return "password_reset";
@@ -46,8 +58,13 @@ public class PasswordResetController {
session.removeAttribute("passwordResetUserId"); session.removeAttribute("passwordResetUserId");
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
if (loginUser != null) {
return "redirect:/menu";
}
return "redirect:/login"; return "redirect:/login";
} }
} }

View File

@@ -345,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

@@ -9,6 +9,6 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public class AuthenticationForm { public class AuthenticationForm {
private String mailAddress; private String mailAddress;
private Integer secretQuestionId; private Long secretQuestionId;
private String secretAnswer; private String secretAnswer;
} }

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"
@@ -35,8 +36,8 @@
<button type="submit">再設定</button> <button type="submit">再設定</button>
</form> </form>
<div th:if="${errorMessage}"> <div th:if="${Message}">
<p th:text="${errorMessage}"></p> <p th:text="${Message}"></p>
</div> </div>
</main> </main>
</body> </body>