Merge branch 'k-kobayashi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-oshita
# Conflicts: # src/main/java/com/example/demo/app/domain/model/GoalModel.java # src/main/java/com/example/demo/app/domain/service/CourseInfoService.java
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
package com.example.demo.app.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AuthenticationModel {
|
||||||
|
private Long userId;
|
||||||
|
}
|
||||||
@@ -2,9 +2,12 @@ package com.example.demo.app.domain.model;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
import com.example.demo.app.infra.entity.GoalEntity;
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
import com.example.demo.app.presentation.form.GoalForm;
|
import com.example.demo.app.presentation.form.GoalForm;
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> f955667682040961a972b0107053018dccd41543
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -24,6 +27,7 @@ public class GoalModel {
|
|||||||
|
|
||||||
private Integer goalComplete;
|
private Integer goalComplete;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
public static GoalModel convertFrom(GoalEntity goalEntity) {
|
public static GoalModel convertFrom(GoalEntity goalEntity) {
|
||||||
return new GoalModel(
|
return new GoalModel(
|
||||||
goalEntity.getGoalId(),
|
goalEntity.getGoalId(),
|
||||||
@@ -55,4 +59,6 @@ public class GoalModel {
|
|||||||
goalForm.getGoalComplete());
|
goalForm.getGoalComplete());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> f955667682040961a972b0107053018dccd41543
|
||||||
}
|
}
|
||||||
@@ -8,10 +8,9 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class UserModel {
|
public class UserModel {
|
||||||
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
private String emailAddress;
|
private String mailAddress;
|
||||||
private String password;
|
private String password;
|
||||||
private Integer secretQuestionId;
|
private Integer secretQuestionId;
|
||||||
private String secretAnswer;
|
private String secretAnswer;
|
||||||
@@ -19,7 +18,7 @@ public class UserModel {
|
|||||||
private Integer saving;
|
private Integer saving;
|
||||||
private Integer annualIncome;
|
private Integer annualIncome;
|
||||||
private Integer monthlyBudget;
|
private Integer monthlyBudget;
|
||||||
private Integer goalId;
|
private Long goalId;
|
||||||
private Integer courseId;
|
private Long courseId;
|
||||||
private Integer deleteFlag;
|
private Integer deleteFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AllocationModel;
|
||||||
|
|
||||||
|
public interface AllocationService {
|
||||||
|
|
||||||
|
public List<AllocationModel> findAll();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||||
|
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||||
|
|
||||||
|
public interface AuthenticationService {
|
||||||
|
|
||||||
|
AuthenticationModel authenticate(AuthenticationForm authenticationForm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.CourseInfoModel;
|
||||||
|
|
||||||
|
public interface CourseInfoService {
|
||||||
|
//
|
||||||
|
public List<CourseInfoModel> findAll();
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AllocationModel;
|
||||||
|
import com.example.demo.app.domain.service.AllocationService;
|
||||||
|
import com.example.demo.app.infra.entity.AllocationEntity;
|
||||||
|
import com.example.demo.app.infra.repository.AllocationRepository;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AllocationServiceImpl implements AllocationService {
|
||||||
|
|
||||||
|
AllocationRepository allocationRepository;
|
||||||
|
|
||||||
|
public List<AllocationModel> findAll(){
|
||||||
|
return AllocationEntity.createAllocationModelList(allocationRepository.findAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||||
|
import com.example.demo.app.domain.service.AuthenticationService;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthenticationServiceImpl implements AuthenticationService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthenticationModel authenticate(AuthenticationForm authenticationForm) {
|
||||||
|
|
||||||
|
UserEntity userEntity = userRepository.findByMailAddress(
|
||||||
|
authenticationForm.getMailAddress())
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (userEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userEntity.getQuestionEntity().getSecretQuestionId()
|
||||||
|
.equals(authenticationForm.getSecretQuestionId())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userEntity.getSecretQuestionAnswer()
|
||||||
|
.equals(authenticationForm.getSecretAnswer())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AuthenticationModel(userEntity.getUserId());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
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.PostMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||||
|
import com.example.demo.app.domain.service.AuthenticationService;
|
||||||
|
import com.example.demo.app.infra.repository.QuestionRepository;
|
||||||
|
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthenticationController {
|
||||||
|
|
||||||
|
private final AuthenticationService authenticationService;
|
||||||
|
private final QuestionRepository questionRepository;
|
||||||
|
|
||||||
|
@GetMapping("/authentication")
|
||||||
|
public String showAuthentication(Model model) {
|
||||||
|
|
||||||
|
model.addAttribute("authenticationForm", new AuthenticationForm());
|
||||||
|
model.addAttribute("questionList", questionRepository.findAll());
|
||||||
|
|
||||||
|
return "authentication";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/authentication")
|
||||||
|
public String authenticate(
|
||||||
|
AuthenticationForm authenticationForm,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
AuthenticationModel authenticationModel =
|
||||||
|
authenticationService.authenticate(authenticationForm);
|
||||||
|
|
||||||
|
if (authenticationModel == null) {
|
||||||
|
model.addAttribute("errorMessage", "認証情報が正しくありません。");
|
||||||
|
model.addAttribute("questionList", questionRepository.findAll());
|
||||||
|
|
||||||
|
return "authentication";
|
||||||
|
}
|
||||||
|
|
||||||
|
session.setAttribute(
|
||||||
|
"passwordResetUserId",
|
||||||
|
authenticationModel.getUserId());
|
||||||
|
|
||||||
|
return "password_reset";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AllocationModel;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class AllocationForm {
|
||||||
|
|
||||||
|
private Long categoryId;
|
||||||
|
private Long courseId;
|
||||||
|
private Integer allocationRatio;
|
||||||
|
|
||||||
|
public static AllocationForm convertFrom(AllocationModel allocationModel) {
|
||||||
|
return new AllocationForm(allocationModel.getCategoryId(), allocationModel.getCourseId(), allocationModel.getAllocationRatio());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<AllocationForm> convertFrom(List<AllocationModel> allocationModelList){
|
||||||
|
return allocationModelList.stream().map(AllocationForm::convertFrom).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class AuthenticationForm {
|
||||||
|
private String mailAddress;
|
||||||
|
private Integer secretQuestionId;
|
||||||
|
private String secretAnswer;
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ public class CourseInfoForm {
|
|||||||
|
|
||||||
|
|
||||||
public static CourseInfoForm convertFrom(CourseInfoModel courseInfoModel ) {
|
public static CourseInfoForm convertFrom(CourseInfoModel courseInfoModel ) {
|
||||||
return new CourseInfoForm(courseInfoModel.getCategoryId(), courseInfoModel.getCourseName(), courseInfoModel.getCategoryId(), courseInfoModel.getCategoryName(), courseInfoModel.getAllocationRatio());
|
return new CourseInfoForm(courseInfoModel.getCourseId(), courseInfoModel.getCourseName(), courseInfoModel.getCategoryId(), courseInfoModel.getCategoryName(), courseInfoModel.getAllocationRatio());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<CourseInfoForm> convertFrom(List<CourseInfoModel> courseInfoModelList ) {
|
public static List<CourseInfoForm> convertFrom(List<CourseInfoModel> courseInfoModelList ) {
|
||||||
|
|||||||
53
src/main/resources/templates/Authentication.html
Normal file
53
src/main/resources/templates/Authentication.html
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>認証</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<h1>本人認証確認</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/authentication}" th:object="${authenticationForm}" method="post">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="mailAddress">メールアドレス</label>
|
||||||
|
<input type="email" id="mailAddress" th:field="*{mailAddress}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="secretQuestionId">秘密の質問</label>
|
||||||
|
<select id="secretQuestionId" th:field="*{secretQuestionId}">
|
||||||
|
|
||||||
|
<option value="">選択してください</option>
|
||||||
|
|
||||||
|
<option th:each="question : ${questionList}" th:value="${question.secretQuestionId}"
|
||||||
|
th:text="${question.questionText}">
|
||||||
|
</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="secretAnswer">秘密の質問の回答</label>
|
||||||
|
<input type="text" id="secretAnswer" th:field="*{secretAnswer}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit">確認</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form th:action="@{/login}" method="get">
|
||||||
|
<button type="submit">戻る</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script th:if="${errorMessage}" th:inline="javascript">
|
||||||
|
alert(/*[[${errorMessage}]]*/);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -12,10 +12,12 @@
|
|||||||
|
|
||||||
<input type="hidden" th:field="*{goalId}">
|
<input type="hidden" th:field="*{goalId}">
|
||||||
|
|
||||||
|
<!--
|
||||||
<div>
|
<div>
|
||||||
<label>目標名</label>
|
<label>目標名</label>
|
||||||
<input type="text" th:field="*{goalTitle}">
|
<input type="text" th:field="*{goalTitle}">
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label>目標補足説明</label>
|
<label>目標補足説明</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user