[FIX]プッシュエラーのため、コミットリセット
This commit is contained in:
@@ -33,7 +33,9 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|||||||
public AnalysisModel getAnalysis(Long userId) {
|
public AnalysisModel getAnalysis(Long userId) {
|
||||||
|
|
||||||
// ユーザー情報取得、月別使用可能資金取得
|
// ユーザー情報取得、月別使用可能資金取得
|
||||||
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
|
UserEntity userEntity = userRepository.findById(userId).orElseThrow(() ->
|
||||||
|
new RuntimeException(
|
||||||
|
"User not found."));
|
||||||
|
|
||||||
// コースID取得
|
// コースID取得
|
||||||
Long courseId = userEntity.getCourseEntity().getCourseId();
|
Long courseId = userEntity.getCourseEntity().getCourseId();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import jakarta.persistence.GeneratedValue;
|
|||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.OneToOne;
|
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import com.example.demo.app.domain.model.CourseModel;
|
import com.example.demo.app.domain.model.CourseModel;
|
||||||
@@ -39,10 +38,6 @@ public class CourseEntity {
|
|||||||
@OneToMany(mappedBy = "courseEntity")
|
@OneToMany(mappedBy = "courseEntity")
|
||||||
private List<UserEntity> userEntity;
|
private List<UserEntity> userEntity;
|
||||||
|
|
||||||
@OneToOne(mappedBy = "courseEntity")
|
|
||||||
private AllocationEntity allocationEntity;
|
|
||||||
|
|
||||||
|
|
||||||
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
|
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
|
||||||
|
|
||||||
return courseEntityList
|
return courseEntityList
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ public interface AllocationRepository extends JpaRepository<AllocationEntity, Al
|
|||||||
+ " ORDER BY a.courseEntity.courseId ASC, "
|
+ " ORDER BY a.courseEntity.courseId ASC, "
|
||||||
+ " a.categoryEntity.categoryId ASC ")
|
+ " a.categoryEntity.categoryId ASC ")
|
||||||
List<CourseInfoModel> findAllJoinedAllocation();
|
List<CourseInfoModel> findAllJoinedAllocation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.example.demo.app.infra.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface GoalRepository extends JpaRepository<GoalEntity, Long> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,5 +16,6 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
|||||||
String mailAddress,
|
String mailAddress,
|
||||||
String password);
|
String password);
|
||||||
|
|
||||||
|
Optional<UserEntity> findByMailAddress(String mailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import com.example.demo.app.domain.model.AnalysisModel;
|
import com.example.demo.app.domain.model.AnalysisModel;
|
||||||
import com.example.demo.app.domain.model.LoginModel;
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
import com.example.demo.app.domain.service.AnalysisService;
|
import com.example.demo.app.domain.service.AnalysisService;
|
||||||
import com.example.demo.app.presentation.form.AnalysisForm;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@@ -24,15 +23,15 @@ public class AnalysisController {
|
|||||||
public String showAnalysis(Model model, HttpSession session) {
|
public String showAnalysis(Model model, HttpSession session) {
|
||||||
|
|
||||||
//ログインユーザーの取得(セッション)
|
//ログインユーザーの取得(セッション)
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
//分析結果の取得(Service)
|
//分析結果の取得(Service)
|
||||||
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
|
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
|
||||||
|
|
||||||
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
|
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
|
||||||
|
|
||||||
//model格納
|
//model格納
|
||||||
model.addAttribute("analysisForm", analysisForm);
|
model.addAttribute("analysisForm", analysisForm);
|
||||||
|
|
||||||
return "analysis";
|
return "analysis";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.CourseInfoService;
|
||||||
|
import com.example.demo.app.domain.service.CourseService;
|
||||||
|
import com.example.demo.app.presentation.form.CourseForm;
|
||||||
|
import com.example.demo.app.presentation.form.CourseInfoForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/select-course")
|
||||||
|
public String select(Model model) {
|
||||||
|
|
||||||
|
//try {
|
||||||
|
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
||||||
|
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
||||||
|
|
||||||
|
return "select_course";
|
||||||
|
|
||||||
|
//} catch (Exception e) {
|
||||||
|
// // ログイン情報の破棄
|
||||||
|
// httpSession.invalidate();
|
||||||
|
//
|
||||||
|
// e.printStackTrace();
|
||||||
|
//
|
||||||
|
// // エラーログ出力
|
||||||
|
// LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
// // エラー画面遷移
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<table class="table text-center">
|
<table class="table text-center">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col"></th>
|
<th scope="col">カテゴリ別</th>
|
||||||
<th scope="col">支出</th>
|
<th scope="col">支出</th>
|
||||||
<th scope="col">前月比</th>
|
<th scope="col">前月比</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
0
|
0
|
||||||
</td>
|
</td>
|
||||||
<td th:text="${analysisForm.totalDifferenceAmount >= 0}
|
<td th:text="${analysisForm.totalDifferenceAmount >= 0}
|
||||||
? '+' + ${analysisForm.totalDifferenceAmount}
|
? '+' + ${analysisForm.totalDifferenceAmount}
|
||||||
: '-' + ${analysisForm.totalDifferenceAmount}"
|
: ${analysisForm.totalDifferenceAmount}"
|
||||||
th:class="${analysisForm.totalDifferenceAmount >= 0}
|
th:class="${analysisForm.totalDifferenceAmount >= 0}
|
||||||
? 'color-danger;'
|
? 'color-danger;'
|
||||||
: 'color-primary;'">
|
: 'color-primary;'">
|
||||||
@@ -42,11 +42,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col">カテゴリ別</th>
|
<th scope="col">カテゴリ別</th>
|
||||||
<th scope="col">支出</th>
|
<th scope="col">支出</th>
|
||||||
<th scope="col">
|
<th scope="col">前月比<br>コース比</th>
|
||||||
前月比
|
|
||||||
<br>
|
|
||||||
コース比
|
|
||||||
</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -63,16 +59,16 @@
|
|||||||
|
|
||||||
<td>
|
<td>
|
||||||
<span th:text="${category.monthDifferenceAmount >= 0}
|
<span th:text="${category.monthDifferenceAmount >= 0}
|
||||||
? '+' + ${category.monthDifferenceAmount}
|
? '+' + ${category.monthDifferenceAmount}
|
||||||
: '-' + ${category.monthDifferenceAmount}"
|
: ${category.monthDifferenceAmount}"
|
||||||
th:class="${category.monthDifferenceAmount >= 0}
|
th:class="${category.monthDifferenceAmount >= 0}
|
||||||
? 'color-danger;'
|
? 'color-danger;'
|
||||||
: 'color-primary;'">
|
: 'color-primary;'">
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
<span th:text="${category.courseDifferenceAmount >= 0}
|
<span th:text="${category.courseDifferenceAmount >= 0}
|
||||||
? '+' + ${category.courseDifferenceAmount}
|
? '+' + ${category.courseDifferenceAmount}
|
||||||
: '-' + ${category.courseDifferenceAmount}"
|
: ${category.courseDifferenceAmount}"
|
||||||
th:class="${category.courseDifferenceAmount >= 0}
|
th:class="${category.courseDifferenceAmount >= 0}
|
||||||
? 'color-danger;'
|
? 'color-danger;'
|
||||||
: 'color-primary;'">
|
: 'color-primary;'">
|
||||||
|
|||||||
35
src/main/resources/templates/select_course.html
Normal file
35
src/main/resources/templates/select_course.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>コース選択</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="accordion" id="accordionExample">
|
||||||
|
<div class="accordion-item" th:each="course:${courseList}">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
||||||
|
<span th:text="${course.courseName}"></span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#accordionExample">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<span th:text="${course.description}"></span>
|
||||||
|
<table border="1">
|
||||||
|
<tr>
|
||||||
|
<th>カテゴリ名</th><tr>配分(%)</tr>
|
||||||
|
</tr>
|
||||||
|
<tr th:each="courseInfo:${courseInfoList}" th:if="course.courseId == courseInfo.courseId">
|
||||||
|
<td th:text="${courseInfo.categoryName}"></td>
|
||||||
|
<td th:text="${courseInfo.allocationRatio}"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user