diff --git a/src/main/java/com/example/demo/app/presentation/controller/CourseController.java b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java index 5a5e2cd..b4e34f8 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/CourseController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java @@ -1,8 +1,5 @@ package com.example.demo.app.presentation.controller; -import java.util.logging.Level; -import java.util.logging.Logger; - import jakarta.servlet.http.HttpSession; import org.springframework.stereotype.Controller; @@ -25,74 +22,53 @@ import lombok.RequiredArgsConstructor; @Controller -//@RequestMapping("/course") @RequiredArgsConstructor public class CourseController { - - private final static Logger LOGGER = Logger.getLogger(CourseController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - private final HttpSession httpSession; private final CourseService courseService; private final CourseInfoService courseInfoService; private final UserService userService; - @PostMapping("/course/select/register") + @PostMapping("/user/register/course") public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) { - try { + - session.setAttribute("userForm", userForm); - model.addAttribute("mode", "regist"); - model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll())); - model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll())); + session.setAttribute("userForm", userForm); + model.addAttribute("mode", "regist"); + model.addAttribute("currentCourseId", 4); + model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll())); + model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll())); + return "select_course"; - return "select_course"; - - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); - - e.printStackTrace(); - - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return null; - } + } @SessionCheck - @GetMapping("/select/change") - public String showChangeCourse(Model model) { + @GetMapping("/course") + public String showChangeCourse(Model model, HttpSession session) { - try { - - model.addAttribute("mode", "change"); - model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll())); - model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll())); - - return "select_course"; - - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); + Long userId = loginUser.getUserId(); + + Long currentCourseId = userService.findByUserId(userId).getCourseId(); + model.addAttribute("mode", "change"); + model.addAttribute("currentCourseId", currentCourseId); + model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll())); + model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll())); + - e.printStackTrace(); - - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return null; - } + return "select_course"; + + } @SessionCheck @PostMapping("/change") - public String changeCourse(@RequestParam Long courseId) { + public String changeCourse(@RequestParam Long courseId, HttpSession httpSession) { LoginModel loginUser = (LoginModel) httpSession.getAttribute("loginUser"); diff --git a/src/main/resources/templates/authentication.html b/src/main/resources/templates/authentication.html index d99335e..4ea2f8e 100644 --- a/src/main/resources/templates/authentication.html +++ b/src/main/resources/templates/authentication.html @@ -4,6 +4,8 @@ 認証 + + @@ -52,8 +54,6 @@ alert(/*[[${errorMessage}]]*/); -
-
diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index b49f376..472e628 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -3,6 +3,8 @@ ログイン + +
diff --git a/src/main/resources/templates/password_reset.html b/src/main/resources/templates/password_reset.html index b2abc42..07d4ffb 100644 --- a/src/main/resources/templates/password_reset.html +++ b/src/main/resources/templates/password_reset.html @@ -3,6 +3,8 @@ パスワード再設定 + + diff --git a/src/main/resources/templates/profile.html b/src/main/resources/templates/profile.html index 0fe082b..8a9c72b 100644 --- a/src/main/resources/templates/profile.html +++ b/src/main/resources/templates/profile.html @@ -3,6 +3,8 @@ プロフィール + + diff --git a/src/main/resources/templates/profile_edit.html b/src/main/resources/templates/profile_edit.html index d82c709..ec7d81e 100644 --- a/src/main/resources/templates/profile_edit.html +++ b/src/main/resources/templates/profile_edit.html @@ -3,6 +3,8 @@ プロフィール編集 + + diff --git a/src/main/resources/templates/select_course.html b/src/main/resources/templates/select_course.html index 7fbda20..6f3aa5c 100644 --- a/src/main/resources/templates/select_course.html +++ b/src/main/resources/templates/select_course.html @@ -7,6 +7,7 @@ コース選択 +

コース選択

@@ -17,7 +18,7 @@

- + @@ -40,6 +41,10 @@

+ +
+
+ \ No newline at end of file diff --git a/src/main/resources/templates/user_register.html b/src/main/resources/templates/user_register.html index c6ec36b..1bdb65c 100644 --- a/src/main/resources/templates/user_register.html +++ b/src/main/resources/templates/user_register.html @@ -3,6 +3,8 @@ 新規会員登録 + +
@@ -11,7 +13,7 @@

新規会員登録

-
+
新規会員登録確認 + + diff --git a/src/main/resources/templates/user_register_return.html b/src/main/resources/templates/user_register_return.html index 4ecd680..04fb234 100644 --- a/src/main/resources/templates/user_register_return.html +++ b/src/main/resources/templates/user_register_return.html @@ -3,6 +3,8 @@ 新規会員登録 + +