Merge branch 'n-kawahito' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into k-kobayashi
This commit is contained in:
@@ -1,10 +1,15 @@
|
|||||||
package com.example.demo.app.presentation.controller;
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.domain.service.AnalysisService;
|
||||||
|
import com.example.demo.app.presentation.form.AnalysisForm;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@@ -16,13 +21,18 @@ public class AnalysisController {
|
|||||||
private final AnalysisService analysisService;
|
private final AnalysisService analysisService;
|
||||||
|
|
||||||
@GetMapping("/analysis")
|
@GetMapping("/analysis")
|
||||||
public String showAnalysis(Model model) {
|
public String showAnalysis(Model model, HttpSession session) {
|
||||||
|
|
||||||
//ログインユーザーの取得(セッション)
|
//ログインユーザーの取得(セッション)
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
//分析結果の取得(Service)
|
//分析結果の取得(Service)
|
||||||
|
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
|
||||||
|
|
||||||
|
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
|
||||||
|
|
||||||
//model格納
|
//model格納
|
||||||
|
model.addAttribute("analysisForm", analysisForm);
|
||||||
|
|
||||||
return "analysis";
|
return "analysis";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">総支出</th>
|
<th scope="row">総支出</th>
|
||||||
<td>¥234,000</td>
|
<td th:text="'¥' + ${analysisForm.currentMonthTotalAmount}">0</td>
|
||||||
<td>+¥38,000</td>
|
<td th:text="'¥' + ${analysisForm.totalDifferenceAmount}">0</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -33,24 +33,32 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col">カテゴリ別</th>
|
<th scope="col">カテゴリ別</th>
|
||||||
<th scope="col">支出</th>
|
<th scope="col">支出</th>
|
||||||
<th scope="col">前月比<br>コース比</th>
|
<th scope="col">
|
||||||
|
前月比
|
||||||
|
<br>
|
||||||
|
コース比
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr th:each="category : ${analysisForm.categoryAnalysisFormList}">
|
||||||
<th scope="row">食費</th>
|
|
||||||
<td>¥34,000</td>
|
<th scope="row"
|
||||||
<td>+¥8,000<br>+¥1,100</td>
|
th;text="${category.categoryName}">
|
||||||
</tr>
|
食費
|
||||||
<tr>
|
</th>
|
||||||
<th scope="row">交通費</th>
|
|
||||||
<td>¥14,000</td>
|
<td th:text="'¥' + ${category.currentMonthAmount}">
|
||||||
<td>+¥8,000<br>+¥1,100</td>
|
0
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
|
||||||
<th scope="row">日用品</th>
|
<td>
|
||||||
<td>¥4,000</td>
|
<span th:text="'¥' + ${category.monthDifferenceAmount}">
|
||||||
<td>+¥8,000<br>+¥1,100</td>
|
</span>
|
||||||
|
<br>
|
||||||
|
<span th:text="'¥' + ${category.courseDifferenceAmount}">
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user