4 Commits

12 changed files with 78 additions and 18 deletions

View File

@@ -4,4 +4,5 @@ import com.example.demo.app.domain.model.ProfileModel;
public interface ProfileService { 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.getAnnualIncome(),
userEntity.getMonthlyBudget()); 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.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; 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.LoginModel;
import com.example.demo.app.domain.model.ProfileModel; import com.example.demo.app.domain.model.ProfileModel;
@@ -29,4 +30,28 @@ public class ProfileController {
model.addAttribute("profileForm", profileForm); model.addAttribute("profileForm", profileForm);
return "profile"; 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> <title>認証</title>
</head> </head>
<body> <body class="pb-5 pt-5">
<div th:replace="~{header :: header}">
</div>
<main> <main>
<h1>本人認証確認</h1> <h1>本人認証確認</h1>
@@ -48,6 +52,9 @@
alert(/*[[${errorMessage}]]*/); alert(/*[[${errorMessage}]]*/);
</script> </script>
<div th:replace="~{footer :: footer}">
</div>
</body> </body>
</html> </html>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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