4 Commits

12 changed files with 78 additions and 18 deletions

View File

@@ -3,5 +3,6 @@ package com.example.demo.app.domain.service;
import com.example.demo.app.domain.model.ProfileModel;
public interface ProfileService {
ProfileModel findOne(Long userId);
ProfileModel findOne(Long userId);
void withdraw(Long userId);
}

View File

@@ -31,4 +31,16 @@ public class ProfileServiceImpl implements ProfileService{
userEntity.getAnnualIncome(),
userEntity.getMonthlyBudget());
}
@Override
public void withdraw(Long userId) {
UserEntity userEntity =userRepository.findById(userId).orElse(null);
if (userEntity == null) {
return;
}
userEntity.setDeleteFlag(1);
userRepository.save(userEntity);
}
}

View File

@@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
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.model.ProfileModel;
@@ -29,4 +30,28 @@ public class ProfileController {
model.addAttribute("profileForm", profileForm);
return "profile";
}
@GetMapping("/profile/edit")
public String showEditProfile() {
return "profile_edit";
}
@PostMapping("/withdraw")
public String withdraw(HttpSession session) {
LoginModel loginUser =
(LoginModel) session.getAttribute("loginUser");
profileService.withdraw(loginUser.getUserId());
session.invalidate();
return "redirect:/login";
}
@PostMapping("/logout")
public String logout(HttpSession session) {
session.invalidate();
return "redirect:/login";
}
}

View File

@@ -6,7 +6,11 @@
<title>認証</title>
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>本人認証確認</h1>
@@ -48,6 +52,9 @@
alert(/*[[${errorMessage}]]*/);
</script>
<div th:replace="~{footer :: footer}">
</div>
</body>
</html>

View File

@@ -5,7 +5,10 @@
<title>エラー</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
</head>
<body>

View File

@@ -7,7 +7,8 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>
<h1>目標編集</h1>

View File

@@ -7,7 +7,7 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}"></div>

View File

@@ -4,8 +4,9 @@
<meta charset="UTF-8">
<title>ログイン</title>
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>ログイン</h1>

View File

@@ -4,8 +4,9 @@
<meta charset="UTF-8">
<title>パスワード再設定</title>
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>パスワード再設定</h1>

View File

@@ -4,8 +4,10 @@
<meta charset="UTF-8">
<title>プロフィール</title>
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<div>
@@ -51,13 +53,18 @@
</form>
</div>
<form th:action="@{/login}" method="post">
<form th:action="@{/logout}" method="post">
<button type="submit">ログアウト</button>
</form>
<form th:action="@{/aaa}" method="post">
<button type="submit">脱退</button>
<form th:action="@{/withdraw}" method="post"
onsubmit="return confirm('本当に脱退しますか?');">
<button type="submit">脱退</button>
</form>
</main>
<div th:replace="~{footer :: footer}">
</div>
</body>
</html>

View File

@@ -4,8 +4,9 @@
<meta charset="UTF-8">
<title>新規会員登録</title>
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>新規会員登録</h1>

View File

@@ -4,8 +4,9 @@
<meta charset="UTF-8">
<title>新規会員登録確認</title>
</head>
<body>
<header></header>
<body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main>
<h1>新規会員登録確認</h1>