Compare commits
7 Commits
642cd7ee69
...
336adf0dec
| Author | SHA1 | Date | |
|---|---|---|---|
| 336adf0dec | |||
| 52fe77a5b4 | |||
| ac85c2dc23 | |||
| 8282331339 | |||
| 1759c45fea | |||
| 44ac862bdb | |||
| ed7a3a67b7 |
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,7 +56,8 @@ public class GoalServiceImpl implements GoalService {
|
||||
goalModel.getTargetAmount(),
|
||||
goalModel.getDeadline(),
|
||||
goalModel.getGoalComplete(),
|
||||
achievementRate);
|
||||
achievementRate,
|
||||
currentAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,11 +7,11 @@ 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;
|
||||
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -22,7 +22,6 @@ public class AuthenticationController {
|
||||
private final AuthenticationService authenticationService;
|
||||
private final QuestionRepository questionRepository;
|
||||
|
||||
@SessionCheck
|
||||
@GetMapping("/authentication")
|
||||
public String showAuthentication(Model model) {
|
||||
|
||||
@@ -32,7 +31,6 @@ public class AuthenticationController {
|
||||
return "authentication";
|
||||
}
|
||||
|
||||
@SessionCheck
|
||||
@PostMapping("/authentication")
|
||||
public String authenticate(
|
||||
AuthenticationForm authenticationForm,
|
||||
@@ -53,6 +51,10 @@ public class AuthenticationController {
|
||||
"passwordResetUserId",
|
||||
authenticationModel.getUserId());
|
||||
|
||||
model.addAttribute(
|
||||
"passwordResetForm",
|
||||
new PasswordResetForm());
|
||||
|
||||
return "password_reset";
|
||||
|
||||
}
|
||||
|
||||
@@ -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.app.domain.model.LoginModel;
|
||||
import com.example.demo.app.domain.service.PasswordResetService;
|
||||
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||
|
||||
@@ -25,29 +26,45 @@ public class PasswordResetController {
|
||||
|
||||
@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("Message", "パスワードが一致しません。");
|
||||
return "password_reset";
|
||||
}
|
||||
|
||||
session.removeAttribute("passwordResetUserId");
|
||||
|
||||
return "redirect:/login";
|
||||
PasswordResetForm passwordResetForm,
|
||||
Model model,
|
||||
HttpSession session){
|
||||
|
||||
Long userId =
|
||||
(Long) session.getAttribute("passwordResetUserId");
|
||||
|
||||
if (userId == null) {
|
||||
LoginModel loginUser =
|
||||
(LoginModel) session.getAttribute("loginUser");
|
||||
|
||||
if (loginUser != null) {
|
||||
userId = loginUser.getUserId();
|
||||
}
|
||||
}
|
||||
|
||||
if (userId == null) {
|
||||
return "redirect:/login";
|
||||
}
|
||||
|
||||
boolean isReset =
|
||||
passwordResetService.resetPassword(userId, passwordResetForm);
|
||||
|
||||
System.out.println("isReset=" + isReset);
|
||||
|
||||
if(!isReset) {
|
||||
model.addAttribute("Message", "パスワードが一致しません。");
|
||||
return "password_reset";
|
||||
}
|
||||
|
||||
session.removeAttribute("passwordResetUserId");
|
||||
|
||||
LoginModel loginUser =
|
||||
(LoginModel) session.getAttribute("loginUser");
|
||||
|
||||
if (loginUser != null) {
|
||||
return "redirect:/menu";
|
||||
}
|
||||
|
||||
return "redirect:/login";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -344,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());
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class AuthenticationForm {
|
||||
private String mailAddress;
|
||||
private Integer secretQuestionId;
|
||||
private Long secretQuestionId;
|
||||
private String secretAnswer;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<h1>目標詳細</h1>
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<th>目標名</th>
|
||||
<td th:text="${goalForm.goalTitle}"></td>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
@@ -35,8 +36,8 @@
|
||||
<button type="submit">再設定</button>
|
||||
</form>
|
||||
|
||||
<div th:if="${errorMessage}">
|
||||
<p th:text="${errorMessage}"></p>
|
||||
<div th:if="${Message}">
|
||||
<p th:text="${Message}"></p>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user