This commit is contained in:
2026-09-29 14:37:39 +09:00
6 changed files with 43 additions and 17 deletions

View File

@@ -57,6 +57,8 @@ public class GoalController {
Long userId = loginUser.getUserId();
LocalDate today = LocalDate.now();
goalService.updateGoalComplete(userId);
List<GoalModel> goalModelList = goalService.getGoalByUserId(userId);
@@ -64,7 +66,8 @@ public class GoalController {
List<GoalForm> goalFormList1 = GoalForm.convertFrom(goalModelList);
List<GoalForm> goalFormList = goalFormList1.stream()
.filter(goalForm -> goalForm.getGoalComplete() == 0)
.filter(goalForm -> goalForm.getGoalComplete() == 0
&& !goalForm.getDeadline().isBefore(today))
.collect(Collectors.toList());
model.addAttribute(
@@ -107,8 +110,6 @@ public class GoalController {
1,
1);
LocalDate today = LocalDate.now();
Map<LocalDate, List<TransactionForm>> transactionFormMap = new HashMap<>();
transactionService
@@ -233,15 +234,14 @@ public class GoalController {
@GetMapping(TransitionTargetPageNameKeyword.EDIT)
public String editGoal(Model model, HttpSession session, Long goalId) {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
GoalForm goalForm = GoalForm.convertFrom(goalService.getGoalById(goalId));
model.addAttribute(PageReturnAttributeKeyword.GOAL_FORM, goalForm);
return TransitionTargetPageNameKeyword.GOAL_EDIT_HTML;
}
@SessionCheck
@@ -272,11 +272,11 @@ public class GoalController {
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
int currentAmount = goalService.getCurrentAmount(userId);
model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, currentAmount);
return TransitionTargetPageNameKeyword.GOAL_CREATE_HTML;
}
@@ -305,7 +305,8 @@ public class GoalController {
if (record == null) {
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL;
} else {
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL + TransitionTargetPageNameKeyword.RECORD;
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL
+ TransitionTargetPageNameKeyword.RECORD;
}
}
@@ -314,6 +315,8 @@ public class GoalController {
@GetMapping(TransitionTargetPageNameKeyword.RECORD)
public String getRecord(HttpSession session, Model model) {
LocalDate today = LocalDate.now();
LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
@@ -325,7 +328,13 @@ public class GoalController {
List<GoalForm> goalCompleteFormList = new ArrayList<>();
goalFormList.stream().forEach(goalForm -> {
if (goalForm.getGoalComplete() == 1) {
if (goalForm.getGoalComplete() == 1 || goalForm.getDeadline().isBefore(today)) {
goalForm.setStatus(
goalForm.getGoalComplete() == 1
? "達成"
: "未達成");
goalCompleteFormList.add(goalForm);
}
});

View File

@@ -29,6 +29,8 @@ public class GoalForm {
private Integer goalComplete;
private String status;
private Integer achievementRate; // 達成率
private Integer currentAmount; // 現在の資産
@@ -43,6 +45,7 @@ public class GoalForm {
goalModel.getTargetAmount(),
goalModel.getDeadline(),
goalModel.getGoalComplete(),
null,
goalModel.getAchievementRate(),
goalModel.getCurrentAmount(),
goalModel.getUserId());

View File

@@ -46,6 +46,10 @@ body {
border-top: 1px solid #d0d7de;
}
.a-footer {
text-decoration: none;
}
/* =======================
カード
======================= */
@@ -178,6 +182,10 @@ td:hover {
text-align: right;
}
.a-calender {
text-decoration: none;
}
/* =======================
金額表示
======================= */

View File

@@ -15,22 +15,22 @@
<div class="row">
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/transaction/create}">入力</a>
<a th:href="@{/transaction/create}" class="a-footer">入力</a>
</button>
</div>
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/transaction/list}">一覧</a>
<a th:href="@{/transaction/list}" class="a-footer">一覧</a>
</button>
</div>
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/analysis}">分析</a>
<a th:href="@{/analysis}" class="a-footer">分析</a>
</button>
</div>
<div class="col border-end">
<button type="button" class="btn btn-link text-black text-decoration-none">
<a th:href="@{/goal}">目標</a>
<a th:href="@{/goal}" class="a-footer">目標</a>
</button>
</div>
</div>

View File

@@ -47,6 +47,12 @@
<br>
状態:
<span class="fw-bold" th:text="${goalForm.status}">
</span>
<br>
</p>
</form>

View File

@@ -63,7 +63,7 @@
<a th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1
and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}" th:href="@{/transaction/detail(
todayDates=${T(java.time.LocalDate).of(year, month, week * 7 + weekDay - firstDayOfWeek + 1)}
)}">
)}" class="a-footer">
<div