3 Commits

Author SHA1 Message Date
kkazuya
31a6ce44a4 [EDIT] コース選択機能を修正しました 2026-09-18 16:04:53 +09:00
254286f14e [EDIT]新規会員登録のコース選択の修正 2026-09-18 14:41:17 +09:00
dfcc49ad94 [ADD]プロフィールの作成 2026-09-18 14:22:50 +09:00
11 changed files with 149 additions and 60 deletions

View File

@@ -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;

View File

@@ -8,4 +8,6 @@ public interface CourseService {
public List<CourseModel> findAll(); public List<CourseModel> findAll();
public CourseModel findById(Long courseId);
} }

View File

@@ -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));
}
} }

View File

@@ -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);
} }

View File

@@ -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 {

View File

@@ -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";
} }

View File

@@ -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());

View 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>

View File

@@ -9,17 +9,9 @@
<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}">
<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}">
<button type="submit">確定</button> <button type="submit">確定</button>
<div class="accordion" id="accordionExample"> <div class="accordion" id="accordionExample">
<div class="accordion-item" th:each="course:${courseList}"> <div class="accordion-item" th:each="course:${courseList}">

View File

@@ -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>

View File

@@ -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>