Merge remote-tracking branch 'origin/n-kawahito' into s-choi

# Conflicts:
#	src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java
This commit is contained in:
s-choi
2026-09-17 16:18:45 +09:00
28 changed files with 587 additions and 219 deletions

View File

@@ -5,6 +5,10 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public class AuthenticationModel {
private Long userId;
public class AllocationModel {
private Long categoryId;
private Long courseId;
private Integer allocationRatio;
}

View File

@@ -13,7 +13,7 @@ public class CategoryAnalysisModel {
private Integer previousMonthAmount;
private Integer previousMonthDifferenceAmount;
private Integer monthDifferenceAmount;
private Integer courseLimitAmount;

View File

@@ -0,0 +1,28 @@
package com.example.demo.app.domain.model;
import java.util.List;
import com.example.demo.app.infra.entity.CourseEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public class CourseModel {
private Long courseId;
private String courseName;
private String description;
public static CourseModel convertFrom(CourseEntity courseEntity) {
return new CourseModel(
courseEntity.getCourseId(),
courseEntity.getCourseName(),
courseEntity.getDescription());
}
public static List<CourseModel> convertFrom(List<CourseEntity> courseEntityList) {
return courseEntityList.stream().map(CourseModel::convertFrom).toList();
}
}

View File

@@ -8,9 +8,10 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public class UserModel {
private Long userId;
private String userName;
private String mailAddress;
private String emailAddress;
private String password;
private Integer secretQuestionId;
private String secretAnswer;
@@ -18,7 +19,7 @@ public class UserModel {
private Integer saving;
private Integer annualIncome;
private Integer monthlyBudget;
private Long goalId;
private Long courseId;
private Integer goalId;
private Integer courseId;
private Integer deleteFlag;
}

View File

@@ -1,9 +0,0 @@
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);
}

View File

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

View File

@@ -0,0 +1,11 @@
package com.example.demo.app.domain.service;
import java.util.List;
import com.example.demo.app.domain.model.CourseModel;
public interface CourseService {
public List<CourseModel> findAll();
}

View File

@@ -1,9 +1,21 @@
package com.example.demo.app.domain.service.impl;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.AnalysisModel;
import com.example.demo.app.domain.model.CategoryAnalysisModel;
import com.example.demo.app.domain.service.AnalysisService;
import com.example.demo.app.infra.entity.AllocationEntity;
import com.example.demo.app.infra.entity.CategoryEntity;
import com.example.demo.app.infra.entity.UserEntity;
import com.example.demo.app.infra.repository.AllocationRepository;
import com.example.demo.app.infra.repository.CategoryRepository;
import com.example.demo.app.infra.repository.TransactionRepository;
import com.example.demo.app.infra.repository.UserRepository;
import lombok.RequiredArgsConstructor;
@@ -12,29 +24,119 @@ import lombok.RequiredArgsConstructor;
public class AnalysisServiceImpl implements AnalysisService {
//Repositoryの呼び出し
// private final TransactionRepository transactionRepository;
// private final AllocationRepository allocationRepository;
// private final UserRepository userRepository;
// private final CategoryRepository categoryRepository;
private final TransactionRepository transactionRepository;
private final AllocationRepository allocationRepository;
private final UserRepository userRepository;
private final CategoryRepository categoryRepository;
@Override
public AnalysisModel getAnalysis(Long userId) {
// ユーザー情報取得、月別使用可能資金取得
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
// コースID取得
Long courseId = userEntity.getCourseEntity().getCourseId();
// 月別使用可能資金取得
Integer monthlyBudget =userEntity.getMonthlyBudget();
// 今月の期間取得
LocalDate currentMonthStartDate = LocalDate.now().withDayOfMonth(1);
LocalDate currentMonthEndDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
// 前月の期間取得
LocalDate previousMonthStartDate = LocalDate.now().minusMonths(1).withDayOfMonth(1);
LocalDate previousMonthEndDate = LocalDate.now().minusMonths(1).withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth());
// 今月の支出取得
Integer currentMonthTotalAmount = transactionRepository.findTotalExpense(currentMonthStartDate, currentMonthEndDate, userId);
if (currentMonthTotalAmount == null) {
currentMonthTotalAmount = 0;
}
// 前月の支出取得
Integer previousMonthTotalAmount = transactionRepository.findTotalExpense(previousMonthStartDate, previousMonthEndDate, userId);
if (previousMonthTotalAmount == null) {
previousMonthTotalAmount = 0;
}
//総支出差額算出
Integer totalDifferenceAmount = currentMonthTotalAmount - previousMonthTotalAmount;
//カテゴリ一覧取得
List<CategoryAnalysisModel> categoryAnalysisModelList = new ArrayList<>();
List<CategoryEntity> categoryEntityList = categoryRepository.findAll();
List<AllocationEntity> allocationEntityList = allocationRepository.findByCourseEntity_CourseId(courseId);
//取得ループ
for (CategoryEntity categoryEntity : categoryEntityList) {
if (categoryEntity.getTransactionType() != 0) {
continue;
}
// カテゴリ別今月金額取得
Integer currentMonthAmount =
transactionRepository.findCategoryExpense(currentMonthStartDate,
currentMonthEndDate,
userId,
categoryEntity.getCategoryId());
// カテゴリ別前月金額取得
Integer previousMonthAmount =
transactionRepository.findCategoryExpense(previousMonthStartDate,
previousMonthEndDate,
userId,
categoryEntity.getCategoryId());
if (currentMonthAmount == null) {
currentMonthAmount = 0;
}
if (previousMonthAmount == null) {
previousMonthAmount = 0;
}
// カテゴリ別前月差額算出
Integer monthDifferenceAmount = currentMonthAmount - previousMonthAmount;
// コース配分取得
// カテゴリ別集計
// 前月との差額集計
//総支出算出
// コース限度額算出、コース別差額算出
AllocationEntity allocationEntity = allocationEntityList.stream().filter(allocation ->
allocation.getCategoryEntity()
.getCategoryId()
.equals(categoryEntity.getCategoryId()))
.findFirst()
.orElse(null);
Integer allocationRatio = 0;
if (allocationEntity != null) {
allocationRatio =
allocationEntity.getAllocationRatio();
}
// コース限度額算出
Integer courseLimitAmount = monthlyBudget * allocationRatio / 100;
// コース差額算出
Integer courseDifferenceAmount = currentMonthAmount - courseLimitAmount;
// CategoryAnalysisModel生成
CategoryAnalysisModel categoryAnalysisModel = new CategoryAnalysisModel(
categoryEntity.getCategoryName(),
currentMonthAmount,
previousMonthAmount,
monthDifferenceAmount,
courseLimitAmount,
courseDifferenceAmount);
categoryAnalysisModelList.add(categoryAnalysisModel);
}
// AnalysisModelの生成
return null;
return new AnalysisModel(currentMonthTotalAmount, previousMonthTotalAmount, totalDifferenceAmount, categoryAnalysisModelList);
}
}

View File

@@ -1,42 +0,0 @@
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());
}
}

View File

@@ -0,0 +1,23 @@
package com.example.demo.app.domain.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.example.demo.app.domain.model.CourseInfoModel;
import com.example.demo.app.domain.service.CourseInfoService;
import com.example.demo.app.infra.repository.AllocationRepository;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class CourseInfoServiceImpl implements CourseInfoService {
private final AllocationRepository allocationRepository;
@Override
public List<CourseInfoModel> findAll() {
return allocationRepository.findAllJoinedAllocation();
}
}

View File

@@ -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.CourseModel;
import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.infra.entity.CourseEntity;
import com.example.demo.app.infra.repository.CourseRepository;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class CourseServiceImpl implements CourseService {
private final CourseRepository courseRepository;
public List<CourseModel> findAll(){
return CourseEntity.createCourseModelList(courseRepository.findAll());
}
}

View File

@@ -1,20 +1,26 @@
package com.example.demo.app.infra.entity;
import java.util.List;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.IdClass;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import com.example.demo.app.domain.model.AllocationModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "allocation")
@IdClass(AllocationId.class)
@Table(name = "allocation_m")
@Data
@NoArgsConstructor
@AllArgsConstructor
@@ -33,4 +39,15 @@ public class AllocationEntity {
@Column(name = "allocation_ratio", nullable = false)
private Integer allocationRatio;
public static List<AllocationModel> createAllocationModelList(List<AllocationEntity> allocationEntityList) {
return allocationEntityList
.stream()
.map(allocationEntity -> new AllocationModel(
allocationEntity.getCategoryEntity().getCategoryId(),
allocationEntity.getCourseEntity().getCourseId(),
allocationEntity.getAllocationRatio()
)).toList();
}
}

View File

@@ -0,0 +1,16 @@
package com.example.demo.app.infra.entity;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AllocationId implements Serializable {
private Long categoryEntity;
private Long courseEntity;
}

View File

@@ -6,18 +6,19 @@ import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import org.springframework.data.annotation.Id;
import com.example.demo.app.domain.model.CourseModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "course")
@Table(name = "course_m")
@Data
@NoArgsConstructor
@AllArgsConstructor
@@ -39,6 +40,18 @@ public class CourseEntity {
private List<UserEntity> userEntity;
@OneToOne(mappedBy = "courseEntity")
private List<AllocationEntity> allocationEntity;
private AllocationEntity allocationEntity;
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
return courseEntityList
.stream()
.map(courseEntity -> new CourseModel(
courseEntity.getCourseId(),
courseEntity.getCourseName(),
courseEntity.getDescription()
)).toList();
}
}

View File

@@ -29,7 +29,7 @@ public class QuestionEntity {
@Column(name = "question_text", nullable = false)
private String questionText;
@OneToMany(mappedBy = "QuestionEntity")
@OneToMany(mappedBy = "questionEntity")
private List<UserEntity> userEntity;
}

View File

@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query;
import com.example.demo.app.domain.model.CourseInfoModel;
import com.example.demo.app.infra.entity.AllocationEntity;
import com.example.demo.app.infra.entity.AllocationId;
public interface AllocationRepository extends JpaRepository<AllocationEntity, AllocationId>{

View File

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

View File

@@ -1,10 +1,15 @@
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 com.example.demo.app.domain.model.AnalysisModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.AnalysisService;
import com.example.demo.app.presentation.form.AnalysisForm;
import lombok.RequiredArgsConstructor;
@@ -16,13 +21,18 @@ public class AnalysisController {
private final AnalysisService analysisService;
@GetMapping("/analysis")
public String showAnalysis(Model model) {
public String showAnalysis(Model model, HttpSession session) {
//ログインユーザーの取得(セッション)
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
//分析結果の取得(Service)
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
//model格納
model.addAttribute("analysisForm", analysisForm);
return "analysis";
}

View File

@@ -1,56 +0,0 @@
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";
}
}

View File

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

View File

@@ -0,0 +1,32 @@
package com.example.demo.app.presentation.form;
import java.util.List;
import com.example.demo.app.domain.model.AnalysisModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnalysisForm {
private Integer currentMonthTotalAmount;
private Integer previousMonthTotalAmount;
private Integer totalDifferenceAmount;
private List<CategoryAnalysisForm> categoryAnalysisFormList;
public static AnalysisForm convertFrom(
AnalysisModel analysisModel) {
return new AnalysisForm(
analysisModel.getCurrentMonthTotalAmount(),
analysisModel.getPreviousMonthTotalAmount(),
analysisModel.getTotalDifferenceAmount(),
CategoryAnalysisForm.convertFrom(
analysisModel.getCategoryAnalysisModelList()));
}
}

View File

@@ -1,14 +0,0 @@
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;
}

View File

@@ -0,0 +1,48 @@
package com.example.demo.app.presentation.form;
import java.util.List;
import com.example.demo.app.domain.model.CategoryAnalysisModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CategoryAnalysisForm {
private String categoryName;
private Integer currentMonthAmount;
private Integer previousMonthAmount;
private Integer monthDifferenceAmount;
private Integer courseLimitAmount;
private Integer courseDifferenceAmount;
public static CategoryAnalysisForm convertFrom(
CategoryAnalysisModel categoryAnalysisModel) {
return new CategoryAnalysisForm(
categoryAnalysisModel.getCategoryName(),
categoryAnalysisModel.getCurrentMonthAmount(),
categoryAnalysisModel.getPreviousMonthAmount(),
categoryAnalysisModel.getMonthDifferenceAmount(),
categoryAnalysisModel.getCourseLimitAmount(),
categoryAnalysisModel.getCourseDifferenceAmount());
}
public static List<CategoryAnalysisForm> convertFrom(
List<CategoryAnalysisModel> categoryAnalysisModelList) {
return categoryAnalysisModelList.stream()
.map(CategoryAnalysisForm::convertFrom)
.toList();
}
}

View File

@@ -0,0 +1,33 @@
package com.example.demo.app.presentation.form;
import java.util.List;
import com.example.demo.app.domain.model.CourseModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CourseForm {
private Long courseId;
private String courseName;
private String description;
public static CourseForm convertFrom(CourseModel courseModel) {
return new CourseForm(
courseModel.getCourseId(),
courseModel.getCourseName(),
courseModel.getDescription()
);
}
public static List<CourseForm> convertFrom(List<CourseModel> courseModelList){
return courseModelList.stream().map(CourseForm::convertFrom).toList();
}
}

View File

@@ -0,0 +1,44 @@
package com.example.demo.app.presentation.form;
import java.util.List;
import com.example.demo.app.domain.model.CourseInfoModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CourseInfoForm {
private Long courseId;
private String courseName;
private Long categoryId;
private String categoryName;
private Integer allocationRatio;
public static CourseInfoForm convertFrom(CourseInfoModel courseInfoModel ) {
return new CourseInfoForm(courseInfoModel.getCategoryId(), courseInfoModel.getCourseName(), courseInfoModel.getCategoryId(), courseInfoModel.getCategoryName(), courseInfoModel.getAllocationRatio());
}
public static List<CourseInfoForm> convertFrom(List<CourseInfoModel> courseInfoModelList ) {
return courseInfoModelList.stream().map(CourseInfoForm::convertFrom).toList();
}
public static CourseInfoModel convertTo(CourseInfoForm courseInfoForm) {
return new CourseInfoModel(
courseInfoForm.getCourseId(),
courseInfoForm.getCourseName(),
courseInfoForm.getCategoryId(),
courseInfoForm.getCategoryName(),
courseInfoForm.getAllocationRatio());
}
}

View File

@@ -1,53 +0,0 @@
<!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>

View File

@@ -12,7 +12,7 @@
<table class="table text-center">
<thead>
<tr>
<th scope="col">カテゴリ別</th>
<th scope="col"></th>
<th scope="col">支出</th>
<th scope="col">前月比</th>
</tr>
@@ -20,8 +20,17 @@
<tbody>
<tr>
<th scope="row">総支出</th>
<td>¥234,000</td>
<td>+¥38,000</td>
<td th:text="'¥' + ${analysisForm.currentMonthTotalAmount}">
0
</td>
<td th:text="${analysisForm.totalDifferenceAmount >= 0}
? '+' + ${analysisForm.totalDifferenceAmount}
: '-' + ${analysisForm.totalDifferenceAmount}"
th:class="${analysisForm.totalDifferenceAmount >= 0}
? 'color-danger;'
: 'color-primary;'">
0
</td>
</tr>
</tbody>
</table>
@@ -33,24 +42,42 @@
<tr>
<th scope="col">カテゴリ別</th>
<th scope="col">支出</th>
<th scope="col">前月比<br>コース比</th>
<th scope="col">
前月比
<br>
コース比
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">食費</th>
<td>¥34,000</td>
<td>+¥8,000<br>+¥1,100</td>
</tr>
<tr>
<th scope="row">交通費</th>
<td>¥14,000</td>
<td>+¥8,000<br>+¥1,100</td>
</tr>
<tr>
<th scope="row">日用品</th>
<td>¥4,000</td>
<td>+¥8,000<br>+¥1,100</td>
<tr th:each="category : ${analysisForm.categoryAnalysisFormList}">
<th scope="row"
th:text="${category.categoryName}">
食費
</th>
<td th:text="'¥' + ${category.currentMonthAmount}">
0
</td>
<td>
<span th:text="${category.monthDifferenceAmount >= 0}
? '+' + ${category.monthDifferenceAmount}
: '-' + ${category.monthDifferenceAmount}"
th:class="${category.monthDifferenceAmount >= 0}
? 'color-danger;'
: 'color-primary;'">
</span>
<br>
<span th:text="${category.courseDifferenceAmount >= 0}
? '+' + ${category.courseDifferenceAmount}
: '-' + ${category.courseDifferenceAmount}"
th:class="${category.courseDifferenceAmount >= 0}
? 'color-danger;'
: 'color-primary;'">
</span>
</td>
</tr>
</tbody>
</table>

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