Compare commits
3 Commits
9259a53bad
...
31a6ce44a4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31a6ce44a4 | ||
| 254286f14e | |||
| dfcc49ad94 |
@@ -10,8 +10,8 @@ import lombok.Getter;
|
|||||||
public class ProfileModel {
|
public class ProfileModel {
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
private String emailAddress;
|
private String mailAddress;
|
||||||
private LocalDate brithDate;
|
private LocalDate birthDate;
|
||||||
private Integer saving;
|
private Integer saving;
|
||||||
private Integer annualIncome;
|
private Integer annualIncome;
|
||||||
private Integer monthlyBudget;
|
private Integer monthlyBudget;
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ public interface CourseService {
|
|||||||
|
|
||||||
public List<CourseModel> findAll();
|
public List<CourseModel> findAll();
|
||||||
|
|
||||||
|
public CourseModel findById(Long courseId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,8 @@ public class CourseServiceImpl implements CourseService {
|
|||||||
|
|
||||||
return CourseEntity.createCourseModelList(courseRepository.findAll());
|
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;
|
package com.example.demo.app.infra.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
import com.example.demo.app.infra.entity.CourseEntity;
|
import com.example.demo.app.infra.entity.CourseEntity;
|
||||||
|
|
||||||
public interface CourseRepository extends JpaRepository<CourseEntity, Long> {
|
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.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.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.LoginModel;
|
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.CourseInfoService;
|
||||||
import com.example.demo.app.domain.service.CourseService;
|
import com.example.demo.app.domain.service.CourseService;
|
||||||
import com.example.demo.app.domain.service.UserService;
|
import com.example.demo.app.domain.service.UserService;
|
||||||
import com.example.demo.app.presentation.form.CourseForm;
|
import com.example.demo.app.presentation.form.CourseForm;
|
||||||
import com.example.demo.app.presentation.form.CourseInfoForm;
|
import com.example.demo.app.presentation.form.CourseInfoForm;
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/course")
|
//@RequestMapping("/course")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CourseController {
|
public class CourseController {
|
||||||
|
|
||||||
@@ -39,15 +39,18 @@ public class CourseController {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/select/register")
|
@GetMapping("/course/select/register")
|
||||||
public String showSelectCourse(@ModelAttribute UserModel userModel, Model model) {
|
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
|
||||||
|
|
||||||
try {
|
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("courseList", CourseForm.convertFrom(courseService.findAll()));
|
||||||
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
||||||
|
|
||||||
|
|
||||||
return "select_course";
|
return "select_course";
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -63,7 +66,7 @@ public class CourseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/select/change")
|
@GetMapping("/select/change")
|
||||||
public String showChangeCourse(Model model) {
|
public String showChangeCourse(Model model) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ 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.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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 com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -16,15 +18,33 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
|
private final CourseService courseService;
|
||||||
|
|
||||||
@GetMapping("/user/register")
|
@GetMapping("/user/register")
|
||||||
public String showRegister(Model model, HttpSession session) {
|
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");
|
UserForm userForm = (UserForm) session.getAttribute("userForm");
|
||||||
|
|
||||||
if(userForm == null) {
|
if(userForm == null) {
|
||||||
userForm = new UserForm();
|
userForm = new UserForm();
|
||||||
|
userForm.setCourseId(courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(courseId != null) {
|
||||||
|
model.addAttribute("selectedCourseName", courseService.findById(courseId).getCourseName());
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("courseId", courseId);
|
||||||
model.addAttribute("userForm", userForm);
|
model.addAttribute("userForm", userForm);
|
||||||
|
|
||||||
return "user_register";
|
return "user_register";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import lombok.NoArgsConstructor;
|
|||||||
public class ProfileForm {
|
public class ProfileForm {
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
private String emailAddress;
|
private String mailAddress;
|
||||||
private LocalDate brithDate;
|
private LocalDate birthDate;
|
||||||
private Integer saving;
|
private Integer saving;
|
||||||
private Integer annualIncome;
|
private Integer annualIncome;
|
||||||
private Integer monthlyBudget;
|
private Integer monthlyBudget;
|
||||||
@@ -24,8 +24,8 @@ public class ProfileForm {
|
|||||||
return new ProfileForm(
|
return new ProfileForm(
|
||||||
profileModel.getUserId(),
|
profileModel.getUserId(),
|
||||||
profileModel.getUserName(),
|
profileModel.getUserName(),
|
||||||
profileModel.getEmailAddress(),
|
profileModel.getMailAddress(),
|
||||||
profileModel.getBrithDate(),
|
profileModel.getBirthDate(),
|
||||||
profileModel.getSaving(),
|
profileModel.getSaving(),
|
||||||
profileModel.getAnnualIncome(),
|
profileModel.getAnnualIncome(),
|
||||||
profileModel.getMonthlyBudget());
|
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,42 +9,34 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>コース選択</h1>
|
<h1>コース選択</h1>
|
||||||
<form th:action="@{/user/register}" th:object="${userForm}" method="post">
|
|
||||||
<input type="hidden" th:field="*{userName}">
|
|
||||||
<input type="hidden" th:field="*{mailAddress}">
|
<form th:action="${mode == 'regist'} ? @{/user/register/return}: @{/change}" method="post">
|
||||||
<input type="hidden" th:field="*{birthDate}">
|
<button type="submit">確定</button>
|
||||||
<input type="hidden" th:field="*{password}">
|
<div class="accordion" id="accordionExample">
|
||||||
<input type="hidden" th:field="*{secretQuestionId}">
|
<div class="accordion-item" th:each="course:${courseList}">
|
||||||
<input type="hidden" th:field="*{secretAnswer}">
|
<h2 class="accordion-header d-flex align-items-center">
|
||||||
<input type="hidden" th:field="*{saving}">
|
<input type="radio" name="courseId" th:value="${course.courseId}" class="form-check-input ms-3 me-2">
|
||||||
<input type="hidden" th:field="*{annualIncome}">
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#collapse' + ${course.courseId}" aria-expanded="false" aria-controls="'collapse' + ${course.courseId}">
|
||||||
<input type="hidden" th:field="*{monthlyBudget}">
|
<span th:text="${course.courseName}"></span>
|
||||||
<input type="hidden" th:field="*{targetAmount}">
|
</button>
|
||||||
<button type="submit">確定</button>
|
</h2>
|
||||||
<div class="accordion" id="accordionExample">
|
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
|
||||||
<div class="accordion-item" th:each="course:${courseList}">
|
<div class="accordion-body">
|
||||||
<h2 class="accordion-header d-flex align-items-center">
|
<span th:text="${course.description}"></span>
|
||||||
<input type="radio" name="courseId" th:value="${course.courseId}" class="form-check-input ms-3 me-2">
|
<table border="1">
|
||||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#collapse' + ${course.courseId}" aria-expanded="false" aria-controls="'collapse' + ${course.courseId}">
|
<tr>
|
||||||
<span th:text="${course.courseName}"></span>
|
<th>カテゴリ名</th><th>配分(%)</th>
|
||||||
</button>
|
</tr>
|
||||||
</h2>
|
<tr th:each="courseInfo:${courseInfoList}" th:if="${course.courseId == courseInfo.courseId}">
|
||||||
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
|
<td th:text="${courseInfo.categoryName}"></td>
|
||||||
<div class="accordion-body">
|
<td th:text="${courseInfo.allocationRatio}"></td>
|
||||||
<span th:text="${course.description}"></span>
|
</tr>
|
||||||
<table border="1">
|
</table>
|
||||||
<tr>
|
</div>
|
||||||
<th>カテゴリ名</th><th>配分(%)</th>
|
</div>
|
||||||
</tr>
|
</div>
|
||||||
<tr th:each="courseInfo:${courseInfoList}" th:if="${course.courseId == courseInfo.courseId}">
|
</div>
|
||||||
<td th:text="${courseInfo.categoryName}"></td>
|
|
||||||
<td th:text="${courseInfo.allocationRatio}"></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@
|
|||||||
<label>コース</label>
|
<label>コース</label>
|
||||||
<input type="hidden" th:field="*{courseId}">
|
<input type="hidden" th:field="*{courseId}">
|
||||||
<span th:text="${selectedCourseName}">未選択</span>
|
<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>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -12,17 +12,17 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>氏名</p>
|
<p>氏名</p>
|
||||||
<p th:text="${session.userForm.userName}" readonly></p>
|
<p th:text="${user.userName}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>メールアドレス</p>
|
<p>メールアドレス</p>
|
||||||
<p th:text="${session.userForm.mailAddress}" readonly></p>
|
<p th:text="${user.mailAddress}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>生年月日</p>
|
<p>生年月日</p>
|
||||||
<p th:text="${session.userForm.barthDate}" readonly></p>
|
<p th:text="${user.birthDate}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -32,37 +32,37 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>秘密の質問</p>
|
<p>秘密の質問</p>
|
||||||
<p th:text="${session.userForm.secretQuestionId}" readonly></p>
|
<p th:text="${user.secretQuestionId}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>秘密の質問の回答</p>
|
<p>秘密の質問の回答</p>
|
||||||
<p th:text="${session.userForm.secretAnswer}" readonly></p>
|
<p th:text="${user.secretAnswer}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>貯蓄金</p>
|
<p>貯蓄金</p>
|
||||||
<p th:text="${session.userForm.saving}" readonly></p>
|
<p th:text="${user.saving}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>年収</p>
|
<p>年収</p>
|
||||||
<p th:text="${session.userForm.annualIncome}" readonly></p>
|
<p th:text="${user.annualIncome}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>月別使用可能額</p>
|
<p>月別使用可能額</p>
|
||||||
<p th:text="${session.userForm.monthlyBudget}" readonly></p>
|
<p th:text="${user.monthlyBudget}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>目標</p>
|
<p>目標</p>
|
||||||
<p th:text="${session.userForm.goalId}" readonly></p>
|
<p th:text="${user.goalId}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>コース</p>
|
<p>コース</p>
|
||||||
<p th:text="${session.userForm.courseId}" readonly></p>
|
<p th:text="${user.courseId}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user