Compare commits
12 Commits
1b6193082d
...
db7fc1d16d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db7fc1d16d | ||
| 192191d352 | |||
| 646c37ea57 | |||
| 3d3177bbfa | |||
| 0b336dcf5a | |||
| 68fbe40385 | |||
| 9ae0669739 | |||
| f03638b347 | |||
| 867926391f | |||
| b0e675d32e | |||
| 86c6910c4a | |||
| cef08f1663 |
@@ -5,10 +5,6 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AllocationModel {
|
public class AuthenticationModel {
|
||||||
|
private Long userId;
|
||||||
private Long categoryId;
|
|
||||||
private Long courseId;
|
|
||||||
private Integer allocationRatio;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.example.demo.app.domain.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.example.demo.app.infra.entity.CourseEntity;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class CourseModel {
|
|
||||||
|
|
||||||
private Long courseId;
|
|
||||||
private String courseName;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
public static CourseModel convertFrom(CourseEntity courseEntity) {
|
|
||||||
return new CourseModel(
|
|
||||||
courseEntity.getCourseId(),
|
|
||||||
courseEntity.getCourseName(),
|
|
||||||
courseEntity.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CourseModel> convertFrom(List<CourseEntity> courseEntityList) {
|
|
||||||
return courseEntityList.stream().map(CourseModel::convertFrom).toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,10 +8,9 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class UserModel {
|
public class UserModel {
|
||||||
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
private String emailAddress;
|
private String mailAddress;
|
||||||
private String password;
|
private String password;
|
||||||
private Integer secretQuestionId;
|
private Integer secretQuestionId;
|
||||||
private String secretAnswer;
|
private String secretAnswer;
|
||||||
@@ -19,7 +18,7 @@ public class UserModel {
|
|||||||
private Integer saving;
|
private Integer saving;
|
||||||
private Integer annualIncome;
|
private Integer annualIncome;
|
||||||
private Integer monthlyBudget;
|
private Integer monthlyBudget;
|
||||||
private Integer goalId;
|
private Long goalId;
|
||||||
private Integer courseId;
|
private Long courseId;
|
||||||
private Integer deleteFlag;
|
private Integer deleteFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||||
|
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||||
|
|
||||||
|
public interface AuthenticationService {
|
||||||
|
|
||||||
|
AuthenticationModel authenticate(AuthenticationForm authenticationForm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
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,8 @@
|
|||||||
|
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,42 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||||
|
import com.example.demo.app.domain.service.AuthenticationService;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthenticationServiceImpl implements AuthenticationService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthenticationModel authenticate(AuthenticationForm authenticationForm) {
|
||||||
|
|
||||||
|
UserEntity userEntity = userRepository.findByMailAddress(
|
||||||
|
authenticationForm.getMailAddress())
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (userEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userEntity.getQuestionEntity().getSecretQuestionId()
|
||||||
|
.equals(authenticationForm.getSecretQuestionId())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userEntity.getSecretQuestionAnswer()
|
||||||
|
.equals(authenticationForm.getSecretAnswer())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AuthenticationModel(userEntity.getUserId());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.PasswordResetService;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PasswordResetServiceImpl implements PasswordResetService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean resetPassword(
|
||||||
|
Long userId,
|
||||||
|
PasswordResetForm passwordResetForm) {
|
||||||
|
|
||||||
|
if (!passwordResetForm.getPassword()
|
||||||
|
.equals(passwordResetForm.getPasswordConfirm())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserEntity userEntity =
|
||||||
|
userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
|
if (userEntity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
userEntity.setPassword(passwordResetForm.getPassword());
|
||||||
|
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.UserService;
|
||||||
|
import com.example.demo.app.infra.entity.CourseEntity;
|
||||||
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
|
import com.example.demo.app.infra.entity.QuestionEntity;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.CourseRepository;
|
||||||
|
import com.example.demo.app.infra.repository.GoalRepository;
|
||||||
|
import com.example.demo.app.infra.repository.QuestionRepository;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
private final QuestionRepository questionRepository;
|
||||||
|
private final GoalRepository goalRepository;
|
||||||
|
private final CourseRepository courseRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(UserForm userForm) {
|
||||||
|
|
||||||
|
UserEntity userEntity = new UserEntity();
|
||||||
|
|
||||||
|
userEntity.setUserName(userForm.getUserName());
|
||||||
|
userEntity.setMailAddress(userForm.getMailAddress());
|
||||||
|
userEntity.setPassword(userForm.getPassword());
|
||||||
|
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
|
||||||
|
userEntity.setBirthDate(userForm.getBirthDate());
|
||||||
|
userEntity.setSaving(userForm.getSaving());
|
||||||
|
userEntity.setAnnualIncome(userForm.getAnnualIncome());
|
||||||
|
userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
|
||||||
|
|
||||||
|
QuestionEntity questionEntity =
|
||||||
|
questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
|
||||||
|
|
||||||
|
GoalEntity goalEntity =
|
||||||
|
goalRepository.findById(userForm.getGoalId()).orElse(null);
|
||||||
|
|
||||||
|
CourseEntity courseEntity =
|
||||||
|
courseRepository.findById(userForm.getCourseId()).orElse(null);
|
||||||
|
|
||||||
|
userEntity.setQuestionEntity(questionEntity);
|
||||||
|
userEntity.setGoalEntity(goalEntity);
|
||||||
|
userEntity.setCourseEntity(courseEntity);
|
||||||
|
|
||||||
|
userEntity.setDeleteFlag(0);
|
||||||
|
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,20 @@
|
|||||||
package com.example.demo.app.infra.entity;
|
package com.example.demo.app.infra.entity;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.IdClass;
|
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.AllocationModel;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@IdClass(AllocationId.class)
|
@Table(name = "allocation")
|
||||||
@Table(name = "allocation_m")
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -38,16 +32,5 @@ public class AllocationEntity {
|
|||||||
|
|
||||||
@Column(name = "allocation_ratio", nullable = false)
|
@Column(name = "allocation_ratio", nullable = false)
|
||||||
private Integer allocationRatio;
|
private Integer allocationRatio;
|
||||||
|
|
||||||
|
|
||||||
public static List<AllocationModel> createAllocationModelList(List<AllocationEntity> allocationEntityList) {
|
|
||||||
|
|
||||||
return allocationEntityList
|
|
||||||
.stream()
|
|
||||||
.map(allocationEntity -> new AllocationModel(
|
|
||||||
allocationEntity.getCategoryEntity().getCategoryId(),
|
|
||||||
allocationEntity.getCourseEntity().getCourseId(),
|
|
||||||
allocationEntity.getAllocationRatio()
|
|
||||||
)).toList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.example.demo.app.infra.entity;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AllocationId implements Serializable {
|
|
||||||
private Long categoryEntity;
|
|
||||||
|
|
||||||
private Long courseEntity;
|
|
||||||
}
|
|
||||||
@@ -6,19 +6,18 @@ import jakarta.persistence.Column;
|
|||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.CourseModel;
|
import org.springframework.data.annotation.Id;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "course_m")
|
@Table(name = "course")
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -40,18 +39,6 @@ public class CourseEntity {
|
|||||||
private List<UserEntity> userEntity;
|
private List<UserEntity> userEntity;
|
||||||
|
|
||||||
@OneToOne(mappedBy = "courseEntity")
|
@OneToOne(mappedBy = "courseEntity")
|
||||||
private AllocationEntity allocationEntity;
|
private List<AllocationEntity> allocationEntity;
|
||||||
|
|
||||||
|
|
||||||
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
|
|
||||||
|
|
||||||
return courseEntityList
|
|
||||||
.stream()
|
|
||||||
.map(courseEntity -> new CourseModel(
|
|
||||||
courseEntity.getCourseId(),
|
|
||||||
courseEntity.getCourseName(),
|
|
||||||
courseEntity.getDescription()
|
|
||||||
)).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class QuestionEntity {
|
|||||||
@Column(name = "question_text", nullable = false)
|
@Column(name = "question_text", nullable = false)
|
||||||
private String questionText;
|
private String questionText;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "questionEntity")
|
@OneToMany(mappedBy = "QuestionEntity")
|
||||||
private List<UserEntity> userEntity;
|
private List<UserEntity> userEntity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.Query;
|
|||||||
|
|
||||||
import com.example.demo.app.domain.model.CourseInfoModel;
|
import com.example.demo.app.domain.model.CourseInfoModel;
|
||||||
import com.example.demo.app.infra.entity.AllocationEntity;
|
import com.example.demo.app.infra.entity.AllocationEntity;
|
||||||
import com.example.demo.app.infra.entity.AllocationId;
|
|
||||||
|
|
||||||
public interface AllocationRepository extends JpaRepository<AllocationEntity, AllocationId>{
|
public interface AllocationRepository extends JpaRepository<AllocationEntity, AllocationId>{
|
||||||
|
|
||||||
@@ -28,5 +27,5 @@ public interface AllocationRepository extends JpaRepository<AllocationEntity, Al
|
|||||||
+ " ORDER BY a.courseEntity.courseId ASC, "
|
+ " ORDER BY a.courseEntity.courseId ASC, "
|
||||||
+ " a.categoryEntity.categoryId ASC ")
|
+ " a.categoryEntity.categoryId ASC ")
|
||||||
List<CourseInfoModel> findAllJoinedAllocation();
|
List<CourseInfoModel> findAllJoinedAllocation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
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.PostMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||||
|
import com.example.demo.app.domain.service.AuthenticationService;
|
||||||
|
import com.example.demo.app.infra.repository.QuestionRepository;
|
||||||
|
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthenticationController {
|
||||||
|
|
||||||
|
private final AuthenticationService authenticationService;
|
||||||
|
private final QuestionRepository questionRepository;
|
||||||
|
|
||||||
|
@GetMapping("/authentication")
|
||||||
|
public String showAuthentication(Model model) {
|
||||||
|
|
||||||
|
model.addAttribute("authenticationForm", new AuthenticationForm());
|
||||||
|
model.addAttribute("questionList", questionRepository.findAll());
|
||||||
|
|
||||||
|
return "authentication";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/authentication")
|
||||||
|
public String authenticate(
|
||||||
|
AuthenticationForm authenticationForm,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
AuthenticationModel authenticationModel =
|
||||||
|
authenticationService.authenticate(authenticationForm);
|
||||||
|
|
||||||
|
if (authenticationModel == null) {
|
||||||
|
model.addAttribute("errorMessage", "認証情報が正しくありません。");
|
||||||
|
model.addAttribute("questionList", questionRepository.findAll());
|
||||||
|
|
||||||
|
return "authentication";
|
||||||
|
}
|
||||||
|
|
||||||
|
session.setAttribute(
|
||||||
|
"passwordResetUserId",
|
||||||
|
authenticationModel.getUserId());
|
||||||
|
|
||||||
|
return "password_reset";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
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.PostMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.PasswordResetService;
|
||||||
|
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PasswordResetController {
|
||||||
|
|
||||||
|
private final PasswordResetService passwordResetService;
|
||||||
|
|
||||||
|
@GetMapping("/password_reset")
|
||||||
|
public String showPasswordReset(Model model) {
|
||||||
|
|
||||||
|
model.addAttribute(
|
||||||
|
"passwordResetForm",
|
||||||
|
new PasswordResetForm());
|
||||||
|
|
||||||
|
return "password_reset";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/password_reset")
|
||||||
|
public String resetPassword(
|
||||||
|
PasswordResetForm passwordResetForm,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
Long userId =
|
||||||
|
(Long) session.getAttribute("passwordResetUserId");
|
||||||
|
|
||||||
|
if (userId == null) {
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isReset =
|
||||||
|
passwordResetService.resetPassword(
|
||||||
|
userId,
|
||||||
|
passwordResetForm);
|
||||||
|
|
||||||
|
if (!isReset) {
|
||||||
|
model.addAttribute(
|
||||||
|
"errorMessage",
|
||||||
|
"パスワードが一致していません。");
|
||||||
|
|
||||||
|
return "password_reset";
|
||||||
|
}
|
||||||
|
|
||||||
|
session.removeAttribute("passwordResetUserId");
|
||||||
|
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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) {
|
||||||
|
model.addAttribute("userForm", new UserForm());
|
||||||
|
return "user_register";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/register/confirm")
|
||||||
|
public String confirmRegister(
|
||||||
|
@ModelAttribute UserForm userForm,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
session.setAttribute("userForm", userForm);
|
||||||
|
|
||||||
|
return "user_register_confirm";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class AuthenticationForm {
|
||||||
|
private String mailAddress;
|
||||||
|
private Integer secretQuestionId;
|
||||||
|
private String secretAnswer;
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.example.demo.app.presentation.form;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.CourseModel;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CourseForm {
|
|
||||||
|
|
||||||
private Long courseId;
|
|
||||||
private String courseName;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
|
|
||||||
public static CourseForm convertFrom(CourseModel courseModel) {
|
|
||||||
return new CourseForm(
|
|
||||||
courseModel.getCourseId(),
|
|
||||||
courseModel.getCourseName(),
|
|
||||||
courseModel.getDescription()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CourseForm> convertFrom(List<CourseModel> courseModelList){
|
|
||||||
return courseModelList.stream().map(CourseForm::convertFrom).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.example.demo.app.presentation.form;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.CourseInfoModel;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CourseInfoForm {
|
|
||||||
|
|
||||||
private Long courseId;
|
|
||||||
|
|
||||||
private String courseName;
|
|
||||||
|
|
||||||
private Long categoryId;
|
|
||||||
|
|
||||||
private String categoryName;
|
|
||||||
|
|
||||||
private Integer allocationRatio;
|
|
||||||
|
|
||||||
|
|
||||||
public static CourseInfoForm convertFrom(CourseInfoModel courseInfoModel ) {
|
|
||||||
return new CourseInfoForm(courseInfoModel.getCategoryId(), courseInfoModel.getCourseName(), courseInfoModel.getCategoryId(), courseInfoModel.getCategoryName(), courseInfoModel.getAllocationRatio());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CourseInfoForm> convertFrom(List<CourseInfoModel> courseInfoModelList ) {
|
|
||||||
return courseInfoModelList.stream().map(CourseInfoForm::convertFrom).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CourseInfoModel convertTo(CourseInfoForm courseInfoForm) {
|
|
||||||
return new CourseInfoModel(
|
|
||||||
courseInfoForm.getCourseId(),
|
|
||||||
courseInfoForm.getCourseName(),
|
|
||||||
courseInfoForm.getCategoryId(),
|
|
||||||
courseInfoForm.getCategoryName(),
|
|
||||||
courseInfoForm.getAllocationRatio());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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,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;
|
||||||
|
}
|
||||||
53
src/main/resources/templates/Authentication.html
Normal file
53
src/main/resources/templates/Authentication.html
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>認証</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<h1>本人認証確認</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/authentication}" th:object="${authenticationForm}" method="post">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="mailAddress">メールアドレス</label>
|
||||||
|
<input type="email" id="mailAddress" th:field="*{mailAddress}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="secretQuestionId">秘密の質問</label>
|
||||||
|
<select id="secretQuestionId" th:field="*{secretQuestionId}">
|
||||||
|
|
||||||
|
<option value="">選択してください</option>
|
||||||
|
|
||||||
|
<option th:each="question : ${questionList}" th:value="${question.secretQuestionId}"
|
||||||
|
th:text="${question.questionText}">
|
||||||
|
</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="secretAnswer">秘密の質問の回答</label>
|
||||||
|
<input type="text" id="secretAnswer" th:field="*{secretAnswer}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit">確認</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form th:action="@{/login}" method="get">
|
||||||
|
<button type="submit">戻る</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script th:if="${errorMessage}" th:inline="javascript">
|
||||||
|
alert(/*[[${errorMessage}]]*/);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
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:obiect="${passwordResteForm"} 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>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>新規会員登録確認</title>
|
<title>新規会員登録確認</title>
|
||||||
|
|||||||
Reference in New Issue
Block a user