Compare commits
11 Commits
7719c002ff
...
603d0d083a
| Author | SHA1 | Date | |
|---|---|---|---|
| 603d0d083a | |||
| cbd5aa6a7d | |||
| 43740691b5 | |||
|
|
61da5163b0 | ||
| 30a2ef3e21 | |||
| 938574654f | |||
| e43028c0ee | |||
| 7ddebf7a4a | |||
| b48b3ae0bd | |||
| 57749b6354 | |||
| a8c46cc9db |
@@ -0,0 +1,18 @@
|
|||||||
|
package com.example.demo.app.domain.model;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ProfileModel {
|
||||||
|
private Long userId;
|
||||||
|
private String userName;
|
||||||
|
private String emailAddress;
|
||||||
|
private LocalDate brithDate;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||||
|
|
||||||
|
public interface PasswordResetService {
|
||||||
|
boolean resetPassword(Long userId, PasswordResetForm passwordResetForm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
|
||||||
|
public interface ProfileService {
|
||||||
|
ProfileModel findOne(Long userId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
void register(UserForm userForm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
import com.example.demo.app.domain.service.ProfileService;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ProfileServiceImpl implements ProfileService{
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProfileModel findOne(Long userId) {
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
|
if(userEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ProfileModel(
|
||||||
|
userEntity.getUserId(),
|
||||||
|
userEntity.getUserName(),
|
||||||
|
userEntity.getMailAddress(),
|
||||||
|
userEntity.getBirthDate(),
|
||||||
|
userEntity.getSaving(),
|
||||||
|
userEntity.getAnnualIncome(),
|
||||||
|
userEntity.getMonthlyBudget());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
import com.example.demo.app.domain.service.ProfileService;
|
||||||
|
import com.example.demo.app.presentation.form.ProfileForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ProfileController {
|
||||||
|
private final ProfileService profileService;
|
||||||
|
|
||||||
|
@GetMapping("/profile")
|
||||||
|
public String profile(Model model, HttpSession session) {
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
ProfileModel profileModel = profileService.findOne(loginUser.getUserId());
|
||||||
|
|
||||||
|
ProfileForm profileForm = ProfileForm.convertForm(profileModel);
|
||||||
|
|
||||||
|
model.addAttribute("profileForm", profileForm);
|
||||||
|
return "profile";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
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.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
@GetMapping("/user/register")
|
||||||
|
public String showRegister(Model model, HttpSession session) {
|
||||||
|
UserForm userForm = (UserForm) session.getAttribute("userForm");
|
||||||
|
|
||||||
|
if(userForm == null) {
|
||||||
|
userForm = new UserForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("userForm", userForm);
|
||||||
|
return "user_register";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/register/confirm")
|
||||||
|
public String confirmRegister(
|
||||||
|
@ModelAttribute UserForm userForm,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
session.setAttribute("userForm", userForm);
|
||||||
|
|
||||||
|
return "user_register_confirm";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/register/complete")
|
||||||
|
public String completeRegister(HttpSession session) {
|
||||||
|
|
||||||
|
UserForm userForm =
|
||||||
|
(UserForm) session.getAttribute("userForm");
|
||||||
|
|
||||||
|
// DBへの登録処理
|
||||||
|
|
||||||
|
session.removeAttribute("userForm");
|
||||||
|
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PasswordResetForm{
|
||||||
|
private String password;
|
||||||
|
private String passwordConfirm;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ProfileForm {
|
||||||
|
private Long userId;
|
||||||
|
private String userName;
|
||||||
|
private String emailAddress;
|
||||||
|
private LocalDate brithDate;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
|
||||||
|
public static ProfileForm convertForm(ProfileModel profileModel) {
|
||||||
|
return new ProfileForm(
|
||||||
|
profileModel.getUserId(),
|
||||||
|
profileModel.getUserName(),
|
||||||
|
profileModel.getEmailAddress(),
|
||||||
|
profileModel.getBrithDate(),
|
||||||
|
profileModel.getSaving(),
|
||||||
|
profileModel.getAnnualIncome(),
|
||||||
|
profileModel.getMonthlyBudget());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserForm {
|
||||||
|
private String userName;
|
||||||
|
private String mailAddress;
|
||||||
|
private String password;
|
||||||
|
private Long secretQuestionId;
|
||||||
|
private String SecretAnswer;
|
||||||
|
private LocalDate birthDate;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
private Long goalId;
|
||||||
|
private Long courseId;
|
||||||
|
}
|
||||||
@@ -13,9 +13,10 @@
|
|||||||
<div th:if="${errorMessage}" th:text="${errorMessage}"></div>
|
<div th:if="${errorMessage}" th:text="${errorMessage}"></div>
|
||||||
<form th:action="@{/login}" th:object="${loginForm}" method="post">
|
<form th:action="@{/login}" th:object="${loginForm}" method="post">
|
||||||
<div>
|
<div>
|
||||||
<label for="emailAddress">メールアドレス</label>
|
<label for="mailAddress">メールアドレス</label>
|
||||||
|
|
||||||
<input type="email"
|
<input type="email"
|
||||||
|
id="mailAddress"
|
||||||
th:field="*{mailAddress}"
|
th:field="*{mailAddress}"
|
||||||
required>
|
required>
|
||||||
</div>
|
</div>
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
<label for="password">パスワード</label>
|
<label for="password">パスワード</label>
|
||||||
|
|
||||||
<input type="password"
|
<input type="password"
|
||||||
|
id="password"
|
||||||
th:field="*{password}"
|
th:field="*{password}"
|
||||||
required>
|
required>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,11 +36,11 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="@{user/register}">新規会員登録</a>
|
<a th:href="@{user/register}">新規会員登録</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="@{password/authentication}">パスワードを忘れた方</a>
|
<a th:href="@{/authentication}">パスワードを忘れた方</a>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
42
src/main/resources/templates/password_reset.html
Normal file
42
src/main/resources/templates/password_reset.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>パスワード再設定</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header></header>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h1>パスワード再設定</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/password_reset}" th:object="${passwordResetForm}" method="post">
|
||||||
|
<div>
|
||||||
|
<label for="password">新しいパスワード</label>
|
||||||
|
<input type="password"
|
||||||
|
id="password"
|
||||||
|
th:field="*{password}"
|
||||||
|
minlength="8"
|
||||||
|
maxlength="255"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="passwordConfirm">パスワード確認</label>
|
||||||
|
<input type="password"
|
||||||
|
id="passwordConfirm"
|
||||||
|
th:field="*{passwordConfirm}"
|
||||||
|
minlength="8"
|
||||||
|
maxlength="255"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit">再設定</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div th:if="${errorMessage}">
|
||||||
|
<p th:text="${errorMessage}"></p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -98,28 +98,18 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="goalId">目標</label>
|
<label for="goalId">目標</label>
|
||||||
<select id="goalId"
|
<input type="number"
|
||||||
|
id="goalId"
|
||||||
th:field="*{goalId}"
|
th:field="*{goalId}"
|
||||||
|
min="0"
|
||||||
required>
|
required>
|
||||||
<option value="">選択してください</option>
|
|
||||||
<option th:each="goal : ${goalList}"
|
|
||||||
th:value="${goal.goalId}"
|
|
||||||
th:text="${goal.goalTitle}">
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="courseId">コース</label>
|
<label>コース</label>
|
||||||
<select id="courseId"
|
<input type="hidden" th:field="*{courseId}">
|
||||||
th:field="*{courseId}"
|
<span th:text="${selectedCourseName}">未選択</span>
|
||||||
required>
|
<button type="button"onclick="location.href='/select-course'">コース選択</button>
|
||||||
<option value="">選択してください</option>
|
|
||||||
<option th:each="course : ${courseList}"
|
|
||||||
th:value="${course.courseId}"
|
|
||||||
th:text="${course.courseName}">
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user