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 currentAmount; // 現在の資産
public static GoalModel convertFrom(GoalEntity goalEntity) {
return new GoalModel(
goalEntity.getGoalId(),
@@ -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

@@ -56,7 +56,8 @@ public class GoalServiceImpl implements GoalService {
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
achievementRate);
achievementRate,
currentAmount);
}
@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.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";
}

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

View File

@@ -345,6 +345,8 @@ public class TransactionController {
model.addAttribute("achievementRate", goalForm.getAchievementRate());
model.addAttribute("currentAmount", goalForm.getCurrentAmount());
model.addAttribute("targetAmount", goalForm.getTargetAmount());
model.addAttribute("saving", userForm.getSaving());

View File

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

View File

@@ -30,6 +30,8 @@ public class GoalForm {
private Integer achievementRate; // 達成率
private Integer currentAmount; // 現在の資産
public static GoalForm convertFrom(GoalModel goalModel) {
return new GoalForm(
goalModel.getGoalId(),
@@ -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"
@@ -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>