# Conflicts:
#	src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java
#	src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java
This commit is contained in:
2026-09-18 11:04:06 +09:00
5 changed files with 92 additions and 14 deletions

View File

@@ -24,15 +24,15 @@ public class AnalysisController {
public String showAnalysis(Model model, HttpSession session) {
//ログインユーザーの取得(セッション)
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
//分析結果の取得(Service)
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
//model格納
model.addAttribute("analysisForm", analysisForm);
model.addAttribute("analysisForm", analysisForm);
return "analysis";
}

View File

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

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

@@ -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>
@@ -42,11 +42,7 @@
<tr>
<th scope="col">カテゴリ別</th>
<th scope="col">支出</th>
<th scope="col">
前月比
<br>
コース比
</th>
<th scope="col">前月比<br>コース比</th>
</tr>
</thead>
<tbody>

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
<html>
<head>
<meta charset="UTF-8">
<title>新規会員登録確認</title>