Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita
This commit is contained in:
@@ -16,7 +16,6 @@ import com.example.demo.app.presentation.form.UserForm;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
@@ -24,58 +23,53 @@ public class UserServiceImpl implements UserService {
|
|||||||
private final QuestionRepository questionRepository;
|
private final QuestionRepository questionRepository;
|
||||||
private final GoalRepository goalRepository;
|
private final GoalRepository goalRepository;
|
||||||
private final CourseRepository courseRepository;
|
private final CourseRepository courseRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(UserForm userForm, Long courseId) {
|
public void register(UserForm userForm, Long courseId) {
|
||||||
|
|
||||||
UserEntity userEntity = new UserEntity();
|
UserEntity userEntity = new UserEntity();
|
||||||
|
|
||||||
userEntity.setUserName(userForm.getUserName());
|
userEntity.setUserName(userForm.getUserName());
|
||||||
userEntity.setMailAddress(userForm.getMailAddress());
|
userEntity.setMailAddress(userForm.getMailAddress());
|
||||||
userEntity.setPassword(userForm.getPassword());
|
userEntity.setPassword(userForm.getPassword());
|
||||||
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
|
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
|
||||||
userEntity.setBirthDate(userForm.getBirthDate());
|
userEntity.setBirthDate(userForm.getBirthDate());
|
||||||
userEntity.setSaving(userForm.getSaving());
|
userEntity.setSaving(userForm.getSaving());
|
||||||
userEntity.setBirthDate(userForm. getBirthDate());
|
userEntity.setBirthDate(userForm.getBirthDate());
|
||||||
userEntity.setSaving(userForm.getSaving());
|
userEntity.setSaving(userForm.getSaving());
|
||||||
userEntity.setAnnualIncome(userForm.getAnnualIncome());
|
userEntity.setAnnualIncome(userForm.getAnnualIncome());
|
||||||
userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
|
userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
|
||||||
|
|
||||||
QuestionEntity questionEntity =
|
QuestionEntity questionEntity = questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
|
||||||
questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
|
|
||||||
|
|
||||||
GoalEntity goalEntity =
|
GoalEntity goalEntity = new GoalEntity();
|
||||||
goalRepository.findById(userForm.getGoalId()).orElse(null);
|
goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId())));
|
||||||
|
|
||||||
CourseEntity courseEntity =
|
CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null);
|
||||||
courseRepository.findById(courseId).orElse(null);
|
|
||||||
|
|
||||||
userEntity.setQuestionEntity(questionEntity);
|
userEntity.setQuestionEntity(questionEntity);
|
||||||
userEntity.setGoalEntity(goalEntity);
|
userEntity.setGoalEntity(goalRepository.save(
|
||||||
userEntity.setCourseEntity(courseEntity);
|
goalEntity));
|
||||||
|
userEntity.setCourseEntity(courseEntity);
|
||||||
|
|
||||||
userEntity.setDeleteFlag(0);
|
userEntity.setDeleteFlag(0);
|
||||||
|
|
||||||
userRepository.save(userEntity);
|
userRepository.save(userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCourse(Long userId, Long courseId) {
|
public void updateCourse(Long userId, Long courseId) {
|
||||||
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
|
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
|
||||||
|
|
||||||
CourseEntity courseEntity = courseRepository.findById(courseId).orElseThrow();
|
CourseEntity courseEntity = courseRepository.findById(courseId).orElseThrow();
|
||||||
|
|
||||||
userEntity.setCourseEntity(courseEntity);
|
userEntity.setCourseEntity(courseEntity);
|
||||||
|
|
||||||
userRepository.save(userEntity);
|
userRepository.save(userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UserModel findByUserId(Long userId) {
|
public UserModel findByUserId(Long userId) {
|
||||||
|
|
||||||
return UserModel.convertFrom(userRepository.findById(userId).get());
|
return UserModel.convertFrom(userRepository.findById(userId).get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,14 +32,14 @@ public class GoalEntity {
|
|||||||
@Column(name = "goal_subtitle", nullable = true)
|
@Column(name = "goal_subtitle", nullable = true)
|
||||||
private String goalSubtitle;
|
private String goalSubtitle;
|
||||||
|
|
||||||
@Column(name = "target_amount", nullable = false)
|
@Column(name = "target_amount", nullable = true)
|
||||||
private Integer targetAmount;
|
private Integer targetAmount;
|
||||||
|
|
||||||
@Column(name = "deadline", nullable = false)
|
@Column(name = "deadline", nullable = true)
|
||||||
private LocalDate deadline;
|
private LocalDate deadline = LocalDate.now().plusYears(1L);
|
||||||
|
|
||||||
@Column(name = "goal_complete", nullable = true)
|
@Column(name = "goal_complete", nullable = false)
|
||||||
private Integer goalComplete;
|
private Integer goalComplete = 0;
|
||||||
|
|
||||||
@OneToOne(mappedBy = "goalEntity")
|
@OneToOne(mappedBy = "goalEntity")
|
||||||
private UserEntity userEntity;
|
private UserEntity userEntity;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package com.example.demo.app.presentation.controller;
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpSession;
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@@ -25,74 +22,53 @@ import lombok.RequiredArgsConstructor;
|
|||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
//@RequestMapping("/course")
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CourseController {
|
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 CourseService courseService;
|
||||||
private final CourseInfoService courseInfoService;
|
private final CourseInfoService courseInfoService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/course/select/register")
|
@PostMapping("/user/register/course")
|
||||||
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
|
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
session.setAttribute("userForm", userForm);
|
session.setAttribute("userForm", userForm);
|
||||||
model.addAttribute("mode", "regist");
|
model.addAttribute("mode", "regist");
|
||||||
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
model.addAttribute("currentCourseId", 4);
|
||||||
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
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
|
@SessionCheck
|
||||||
@GetMapping("/select/change")
|
@GetMapping("/course")
|
||||||
public String showChangeCourse(Model model) {
|
public String showChangeCourse(Model model, HttpSession session) {
|
||||||
|
|
||||||
try {
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
model.addAttribute("mode", "change");
|
Long userId = loginUser.getUserId();
|
||||||
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
|
||||||
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
Long currentCourseId = userService.findByUserId(userId).getCourseId();
|
||||||
|
model.addAttribute("mode", "change");
|
||||||
return "select_course";
|
model.addAttribute("currentCourseId", currentCourseId);
|
||||||
|
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
||||||
} catch (Exception e) {
|
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
||||||
// ログイン情報の破棄
|
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
return "select_course";
|
||||||
|
|
||||||
// エラーログ出力
|
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@PostMapping("/change")
|
@PostMapping("/change")
|
||||||
public String changeCourse(@RequestParam Long courseId) {
|
public String changeCourse(@RequestParam Long courseId, HttpSession httpSession) {
|
||||||
|
|
||||||
LoginModel loginUser = (LoginModel) httpSession.getAttribute("loginUser");
|
LoginModel loginUser = (LoginModel) httpSession.getAttribute("loginUser");
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>認証</title>
|
<title>認証</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="pb-5 pt-5">
|
<body class="pb-5 pt-5">
|
||||||
@@ -52,8 +54,6 @@
|
|||||||
alert(/*[[${errorMessage}]]*/);
|
alert(/*[[${errorMessage}]]*/);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div th:replace="~{footer :: footer}">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>ログイン</title>
|
<title>ログイン</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="pb-5 pt-5">
|
<body class="pb-5 pt-5">
|
||||||
<div th:replace="~{header :: header}">
|
<div th:replace="~{header :: header}">
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>パスワード再設定</title>
|
<title>パスワード再設定</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!--<body class="pb-5 pt-5">-->
|
<!--<body class="pb-5 pt-5">-->
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>プロフィール</title>
|
<title>プロフィール</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="pb-5 pt-5">
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>プロフィール編集</title>
|
<title>プロフィール編集</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="pb-5 pt-5">
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<title>コース選択</title>
|
<title>コース選択</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
|
|
||||||
<h1>コース選択</h1>
|
<h1>コース選択</h1>
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
<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}">
|
||||||
<h2 class="accordion-header d-flex align-items-center">
|
<h2 class="accordion-header d-flex align-items-center">
|
||||||
<input type="radio" name="courseId" th:value="${course.courseId}" class="form-check-input ms-3 me-2">
|
<input type="radio" name="courseId" th:value="${course.courseId}" th:checked="${course.courseId==currentCourseId}" class="form-check-input ms-3 me-2">
|
||||||
<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}">
|
<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}">
|
||||||
<span th:text="${course.courseName}"></span>
|
<span th:text="${course.courseName}"></span>
|
||||||
</button>
|
</button>
|
||||||
@@ -40,6 +41,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<th:block th:if="${mode=='change'}">
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
</th:block>
|
||||||
|
|
||||||
<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>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>新規会員登録</title>
|
<title>新規会員登録</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="pb-5 pt-5">
|
<body class="pb-5 pt-5">
|
||||||
<div th:replace="~{header :: header}">
|
<div th:replace="~{header :: header}">
|
||||||
@@ -11,7 +13,7 @@
|
|||||||
<main>
|
<main>
|
||||||
<h1>新規会員登録</h1>
|
<h1>新規会員登録</h1>
|
||||||
|
|
||||||
<form th:action="@{/course/select/register}" th:object="${userForm}" method="post">
|
<form th:action="@{/user/register/course}" th:object="${userForm}" method="post">
|
||||||
<div>
|
<div>
|
||||||
<label for="userName">氏名</label>
|
<label for="userName">氏名</label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>新規会員登録確認</title>
|
<title>新規会員登録確認</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="pb-5 pt-5">
|
<body class="pb-5 pt-5">
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>新規会員登録</title>
|
<title>新規会員登録</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="pb-5 pt-5">
|
<body class="pb-5 pt-5">
|
||||||
<div th:replace="~{header :: header}">
|
<div th:replace="~{header :: header}">
|
||||||
|
|||||||
Reference in New Issue
Block a user