Compare commits
9 Commits
ee5ec5009d
...
s-morimto
| Author | SHA1 | Date | |
|---|---|---|---|
| acd7534fdb | |||
|
|
add6a85c64 | ||
|
|
fd74dee965 | ||
|
|
7aa8e31bfd | ||
|
|
e3af89a694 | ||
|
|
efdaacbb27 | ||
| 154e6787d4 | |||
| 75f2f7c8d0 | |||
| ac101172d2 |
@@ -4,6 +4,8 @@ package com.example.demo.aop.handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
@@ -37,25 +39,31 @@ public class GlobalExceptionHandler {
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public String handleBadRequestException(Model model, Exception e) {
|
||||
public String handleBadRequestException(Model model, Exception e, HttpSession session) {
|
||||
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||
model.addAttribute("status", HttpStatus.BAD_REQUEST.value());
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||
|
||||
System.out.println("session invalidated");
|
||||
session.invalidate();
|
||||
|
||||
return "error";
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public String AllException(Model model, Exception e) {
|
||||
public String AllException(Model model, Exception e, HttpSession session) {
|
||||
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||
|
||||
System.out.println("session invalidated");
|
||||
session.invalidate();
|
||||
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class ProfileServiceImpl implements ProfileService{
|
||||
userEntity.setSaving(profileEditForm.getSaving());
|
||||
userEntity.setAnnualIncome(profileEditForm.getAnnualIncome());
|
||||
userEntity.setMonthlyBudget(profileEditForm.getMonthlyBudget());
|
||||
userEntity.setBirthDate(profileEditForm.getBirthDate());
|
||||
userRepository.save(userEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,9 +54,11 @@ public class ProfileController {
|
||||
new ProfileEditForm(
|
||||
profileModel.getUserName(),
|
||||
profileModel.getMailAddress(),
|
||||
profileModel.getBirthDate(),
|
||||
profileModel.getSaving(),
|
||||
profileModel.getAnnualIncome(),
|
||||
profileModel.getMonthlyBudget());
|
||||
profileModel.getMonthlyBudget(),
|
||||
profileModel.getBirthDate());
|
||||
|
||||
model.addAttribute(PageReturnAttributeKeyword.PROFILE_EDIT_FORM, profileEditForm);
|
||||
return TransitionTargetPageNameKeyword.PROFILE_EDIT_HTML;
|
||||
|
||||
@@ -237,6 +237,8 @@ public class TransactionController {
|
||||
model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
|
||||
|
||||
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM, transactionForm);
|
||||
|
||||
session.setAttribute("tType", String.valueOf(transactionForm.getTransactionType()));
|
||||
|
||||
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -10,7 +12,9 @@ import lombok.NoArgsConstructor;
|
||||
public class ProfileEditForm {
|
||||
private String userName;
|
||||
private String mailAddress;
|
||||
private LocalDate birthDate;
|
||||
private Integer saving;
|
||||
private Integer annualIncome;
|
||||
private Integer monthlyBudget;
|
||||
private LocalDate birthDate;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,6 @@
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="pb-5 pt-5">
|
||||
|
||||
<div th:replace="~{header :: header}">
|
||||
</div>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div th:replace="~{header :: header}">
|
||||
</div>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
|
||||
<div th:replace="~{footer :: footer}"></div>
|
||||
|
||||
|
||||
<script>
|
||||
const transactionType = document.getElementById("transactionType");
|
||||
const categoryId = document.getElementById("categoryId");
|
||||
@@ -90,6 +91,7 @@
|
||||
const expenseList = document.getElementsByClassName("expenseListClass");
|
||||
const incomeList = document.getElementsByClassName("incomeListClass");
|
||||
|
||||
|
||||
transactionType.addEventListener("change", function () {
|
||||
|
||||
if (this.value === "1") {
|
||||
|
||||
@@ -52,13 +52,15 @@
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">
|
||||
パスワード
|
||||
生年月日
|
||||
</label>
|
||||
|
||||
<input type="password"
|
||||
<input type="date"
|
||||
class="form-control"
|
||||
value="********"
|
||||
disabled>
|
||||
id="birthDate"
|
||||
name="birthDate"
|
||||
th:value="*{birthDate}"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
@@ -105,7 +107,7 @@
|
||||
<div class="d-grid">
|
||||
<button type="submit"
|
||||
class="btn btn-primary">
|
||||
確認
|
||||
確定
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<title>コース選択</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body style="padding-bottom: 120px">
|
||||
<div th:replace="~{header :: header}"></div>
|
||||
|
||||
<h1 class="page-title">コース選択</h1>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
収入・支出
|
||||
</label>
|
||||
|
||||
<select id="transactionType" class="form-select" th:field="*{transactionType}" required>
|
||||
<select id="transactionType" class="form-select" name="transactionType" required>
|
||||
|
||||
<option value="">
|
||||
選択してください
|
||||
@@ -114,13 +114,22 @@
|
||||
|
||||
<div th:replace="~{footer :: footer}"></div>
|
||||
|
||||
<script>
|
||||
<script inline="javascript">
|
||||
const transactionType = document.getElementById("transactionType");
|
||||
const categoryId = document.getElementById("categoryId");
|
||||
|
||||
const expenseList = document.getElementsByClassName("expenseListClass");
|
||||
const incomeList = document.getElementsByClassName("incomeListClass");
|
||||
|
||||
const tType = '[[${session.tType}]]';
|
||||
|
||||
if (tType == "0") {
|
||||
transactionType.value = 1;
|
||||
} else {
|
||||
transactionType.value = 2;
|
||||
}
|
||||
|
||||
|
||||
transactionType.addEventListener("change", function () {
|
||||
|
||||
if (this.value === "1") {
|
||||
|
||||
@@ -1,124 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
|
||||
<title>収支詳細</title>
|
||||
<link rel="stylesheet" th:href="@{/css/transaction_detail.css}">
|
||||
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" th:href="@{/css/style.css}">
|
||||
</head>
|
||||
|
||||
|
||||
<body style="padding-top:80px; padding-bottom:80px;">
|
||||
|
||||
|
||||
<div th:replace="~{header :: header}"></div>
|
||||
<div class="main-container">
|
||||
|
||||
|
||||
<h2 class="page-title"
|
||||
th:text="${today}">
|
||||
</h2>
|
||||
|
||||
|
||||
<div th:each="transactionForm : ${transactionFormList}"
|
||||
class="card shadow-sm mb-3">
|
||||
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
|
||||
<span class="fw-bold"
|
||||
th:text="${transactionForm.categoryName}">
|
||||
</span>
|
||||
|
||||
|
||||
<span th:text="'¥' + ${transactionForm.amount}">
|
||||
</span>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-flex justify-content-end gap-2 mt-3">
|
||||
|
||||
|
||||
<form th:action="@{/transaction/update}"
|
||||
method="get">
|
||||
|
||||
|
||||
<input type="hidden"
|
||||
name="today"
|
||||
th:value="${today}">
|
||||
|
||||
|
||||
<input type="hidden"
|
||||
name="transactionId"
|
||||
th:value="${transactionForm.transactionId}">
|
||||
|
||||
|
||||
<button class="btn btn-sm btn-primary"
|
||||
type="submit">
|
||||
|
||||
|
||||
編集
|
||||
|
||||
|
||||
</button>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<form th:action="@{/transaction/delete}"
|
||||
method="post">
|
||||
|
||||
|
||||
<input type="hidden"
|
||||
name="today"
|
||||
th:value="${today}">
|
||||
|
||||
|
||||
<input type="hidden"
|
||||
name="transactionId"
|
||||
th:value="${transactionForm.transactionId}">
|
||||
|
||||
|
||||
<button class="btn btn-sm btn-danger"
|
||||
type="submit">
|
||||
|
||||
|
||||
削除
|
||||
|
||||
|
||||
</button>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-grid mt-4">
|
||||
|
||||
|
||||
<form th:action="@{/transaction/create}"
|
||||
method="get">
|
||||
|
||||
|
||||
<input type="hidden"
|
||||
name="today"
|
||||
id="today"
|
||||
th:value="${today}">
|
||||
|
||||
|
||||
<button class="btn btn-success w-100"
|
||||
type="submit">
|
||||
|
||||
|
||||
新規登録
|
||||
|
||||
|
||||
</button>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-grid mt-4">
|
||||
|
||||
<form th:action="@{/fixed-cost/list}" method="get">
|
||||
|
||||
<input type="hidden"
|
||||
name="today"
|
||||
id="today"
|
||||
th:value="${today}">
|
||||
|
||||
<button class="btn btn-dark w-100"
|
||||
type="submit">
|
||||
|
||||
固定費一覧
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-grid mt-4">
|
||||
|
||||
<form th:action="@{/category/list}"
|
||||
method="get">
|
||||
|
||||
<input type="hidden"
|
||||
name="today"
|
||||
id="today"
|
||||
th:value="${today}">
|
||||
|
||||
<button class="btn btn-dark w-100"
|
||||
type="submit">
|
||||
|
||||
カテゴリ一覧
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<form th:action="@{/transaction/create}" method="get">
|
||||
<input type="hidden" name="today" id="today" th:value="${today}">
|
||||
<button type="submit">新規登録</button>
|
||||
</form>
|
||||
<form th:action="@{/fixed-cost/list}" method="get">
|
||||
<input type="hidden" name="today" th:value="${today}">
|
||||
<button type="submit">固定費一覧</button>
|
||||
</form>
|
||||
<form th:action="@{/category/list}" method="get">
|
||||
<input type="hidden" name="today" th:value="${today}">
|
||||
<button type="submit">カテゴリ一覧</button>
|
||||
</form>
|
||||
|
||||
|
||||
<div th:replace="~{footer :: footer}"></div>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user