Compare commits
3 Commits
9259a53bad
...
31a6ce44a4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31a6ce44a4 | ||
| 254286f14e | |||
| dfcc49ad94 |
@@ -10,8 +10,8 @@ import lombok.Getter;
|
||||
public class ProfileModel {
|
||||
private Long userId;
|
||||
private String userName;
|
||||
private String emailAddress;
|
||||
private LocalDate brithDate;
|
||||
private String mailAddress;
|
||||
private LocalDate birthDate;
|
||||
private Integer saving;
|
||||
private Integer annualIncome;
|
||||
private Integer monthlyBudget;
|
||||
|
||||
@@ -8,4 +8,6 @@ public interface CourseService {
|
||||
|
||||
public List<CourseModel> findAll();
|
||||
|
||||
public CourseModel findById(Long courseId);
|
||||
|
||||
}
|
||||
|
||||
@@ -21,4 +21,8 @@ public class CourseServiceImpl implements CourseService {
|
||||
|
||||
return CourseEntity.createCourseModelList(courseRepository.findAll());
|
||||
}
|
||||
|
||||
public CourseModel findById(Long courseId) {
|
||||
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import com.example.demo.app.infra.entity.CourseEntity;
|
||||
|
||||
public interface CourseRepository extends JpaRepository<CourseEntity, Long> {
|
||||
|
||||
@Query("SELECT c FROM CourseEntity c WHERE c.courseId = :courseId ")
|
||||
public CourseEntity findByCourseId(Long courseId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,24 +7,24 @@ 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 org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.example.demo.app.domain.model.LoginModel;
|
||||
import com.example.demo.app.domain.model.UserModel;
|
||||
import com.example.demo.app.domain.service.CourseInfoService;
|
||||
import com.example.demo.app.domain.service.CourseService;
|
||||
import com.example.demo.app.domain.service.UserService;
|
||||
import com.example.demo.app.presentation.form.CourseForm;
|
||||
import com.example.demo.app.presentation.form.CourseInfoForm;
|
||||
import com.example.demo.app.presentation.form.UserForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/course")
|
||||
//@RequestMapping("/course")
|
||||
@RequiredArgsConstructor
|
||||
public class CourseController {
|
||||
|
||||
@@ -39,15 +39,18 @@ public class CourseController {
|
||||
|
||||
|
||||
|
||||
@PostMapping("/select/register")
|
||||
public String showSelectCourse(@ModelAttribute UserModel userModel, Model model) {
|
||||
@GetMapping("/course/select/register")
|
||||
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
|
||||
|
||||
try {
|
||||
System.out.println(userForm.getMailAddress());
|
||||
|
||||
model.addAttribute("mode", "select");
|
||||
session.setAttribute("userForm", userForm);
|
||||
model.addAttribute("mode", "regist");
|
||||
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
||||
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
||||
|
||||
|
||||
return "select_course";
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -63,7 +66,7 @@ public class CourseController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/select/change")
|
||||
@GetMapping("/select/change")
|
||||
public String showChangeCourse(Model model) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -7,7 +7,9 @@ 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 org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.example.demo.app.domain.service.CourseService;
|
||||
import com.example.demo.app.presentation.form.UserForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -16,15 +18,33 @@ import lombok.RequiredArgsConstructor;
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
private final CourseService courseService;
|
||||
|
||||
@GetMapping("/user/register")
|
||||
public String showRegister(Model model, HttpSession session) {
|
||||
UserForm userForm = new UserForm();
|
||||
|
||||
model.addAttribute("userForm", userForm);
|
||||
return "user_register";
|
||||
}
|
||||
|
||||
@PostMapping("/user/register/return")
|
||||
public String showRegisterReturn(@RequestParam(required = false) Long courseId, Model model, HttpSession session) {
|
||||
|
||||
UserForm userForm = (UserForm) session.getAttribute("userForm");
|
||||
|
||||
if(userForm == null) {
|
||||
userForm = new UserForm();
|
||||
userForm.setCourseId(courseId);
|
||||
}
|
||||
|
||||
if(courseId != null) {
|
||||
model.addAttribute("selectedCourseName", courseService.findById(courseId).getCourseName());
|
||||
}
|
||||
|
||||
model.addAttribute("courseId", courseId);
|
||||
model.addAttribute("userForm", userForm);
|
||||
|
||||
return "user_register";
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import lombok.NoArgsConstructor;
|
||||
public class ProfileForm {
|
||||
private Long userId;
|
||||
private String userName;
|
||||
private String emailAddress;
|
||||
private LocalDate brithDate;
|
||||
private String mailAddress;
|
||||
private LocalDate birthDate;
|
||||
private Integer saving;
|
||||
private Integer annualIncome;
|
||||
private Integer monthlyBudget;
|
||||
@@ -24,8 +24,8 @@ public class ProfileForm {
|
||||
return new ProfileForm(
|
||||
profileModel.getUserId(),
|
||||
profileModel.getUserName(),
|
||||
profileModel.getEmailAddress(),
|
||||
profileModel.getBrithDate(),
|
||||
profileModel.getMailAddress(),
|
||||
profileModel.getBirthDate(),
|
||||
profileModel.getSaving(),
|
||||
profileModel.getAnnualIncome(),
|
||||
profileModel.getMonthlyBudget());
|
||||
|
||||
63
src/main/resources/templates/profile.html
Normal file
63
src/main/resources/templates/profile.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>プロフィール</title>
|
||||
</head>
|
||||
<body>
|
||||
<header></header>
|
||||
|
||||
<main>
|
||||
<div>
|
||||
<p>氏名</p>
|
||||
<p th:text="${profileForm.userName}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>メールアドレス</p>
|
||||
<p th:text="${profileForm.mailAddress}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>生年月日</p>
|
||||
<p th:text="${profileForm.birthDate}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>パスワード</p>
|
||||
<form th:action="@{/password/reset}" method="get">
|
||||
<button type="submit">パスワード再設定</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>貯蓄金</p>
|
||||
<p th:text="${profileForm.saving}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>年収</p>
|
||||
<p th:text="${profileForm.annualIncome}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>月別使用可能額</p>
|
||||
<p th:text="${profileForm.monthlyBudget}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form th:action="@{/profile/edit}" method="get">
|
||||
<button type="submit">編集</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form th:action="@{/login}" method="post">
|
||||
<button type="submit">ログアウト</button>
|
||||
</form>
|
||||
|
||||
<form th:action="@{/aaa}" method="post">
|
||||
<button type="submit">脱退</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,17 +9,9 @@
|
||||
<body>
|
||||
|
||||
<h1>コース選択</h1>
|
||||
<form th:action="@{/user/register}" th:object="${userForm}" method="post">
|
||||
<input type="hidden" th:field="*{userName}">
|
||||
<input type="hidden" th:field="*{mailAddress}">
|
||||
<input type="hidden" th:field="*{birthDate}">
|
||||
<input type="hidden" th:field="*{password}">
|
||||
<input type="hidden" th:field="*{secretQuestionId}">
|
||||
<input type="hidden" th:field="*{secretAnswer}">
|
||||
<input type="hidden" th:field="*{saving}">
|
||||
<input type="hidden" th:field="*{annualIncome}">
|
||||
<input type="hidden" th:field="*{monthlyBudget}">
|
||||
<input type="hidden" th:field="*{targetAmount}">
|
||||
|
||||
|
||||
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
|
||||
<button type="submit">確定</button>
|
||||
<div class="accordion" id="accordionExample">
|
||||
<div class="accordion-item" th:each="course:${courseList}">
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
<label>コース</label>
|
||||
<input type="hidden" th:field="*{courseId}">
|
||||
<span th:text="${selectedCourseName}">未選択</span>
|
||||
<button type="button"onclick="location.href='/select-course'">コース選択</button>
|
||||
<button type="submit"onclick="location.href='/course/select/register'">コース選択</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -12,17 +12,17 @@
|
||||
|
||||
<div>
|
||||
<p>氏名</p>
|
||||
<p th:text="${session.userForm.userName}" readonly></p>
|
||||
<p th:text="${user.userName}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>メールアドレス</p>
|
||||
<p th:text="${session.userForm.mailAddress}" readonly></p>
|
||||
<p th:text="${user.mailAddress}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>生年月日</p>
|
||||
<p th:text="${session.userForm.barthDate}" readonly></p>
|
||||
<p th:text="${user.birthDate}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -32,37 +32,37 @@
|
||||
|
||||
<div>
|
||||
<p>秘密の質問</p>
|
||||
<p th:text="${session.userForm.secretQuestionId}" readonly></p>
|
||||
<p th:text="${user.secretQuestionId}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>秘密の質問の回答</p>
|
||||
<p th:text="${session.userForm.secretAnswer}" readonly></p>
|
||||
<p th:text="${user.secretAnswer}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>貯蓄金</p>
|
||||
<p th:text="${session.userForm.saving}" readonly></p>
|
||||
<p th:text="${user.saving}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>年収</p>
|
||||
<p th:text="${session.userForm.annualIncome}" readonly></p>
|
||||
<p th:text="${user.annualIncome}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>月別使用可能額</p>
|
||||
<p th:text="${session.userForm.monthlyBudget}" readonly></p>
|
||||
<p th:text="${user.monthlyBudget}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>目標</p>
|
||||
<p th:text="${session.userForm.goalId}" readonly></p>
|
||||
<p th:text="${user.goalId}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>コース</p>
|
||||
<p th:text="${session.userForm.courseId}" readonly></p>
|
||||
<p th:text="${user.courseId}"></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user