[EDIT] デフォルトカテゴリ・カスタムカテゴリ両方取得できるように変更しました。
This commit is contained in:
@@ -3,6 +3,7 @@ package com.example.demo.app.presentation.controller;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -185,8 +186,9 @@ public class TransactionController {
|
||||
@GetMapping("/transaction/create")
|
||||
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
|
||||
Long fixedCostId,
|
||||
Model model) {
|
||||
Model model, HttpSession session) {
|
||||
|
||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||
if (today == null) {
|
||||
today = LocalDate.now();
|
||||
}
|
||||
@@ -196,11 +198,21 @@ public class TransactionController {
|
||||
FixedCostForm fixedCostForm = FixedCostForm.convertFrom(fixedCostService.findById(fixedCostId));
|
||||
transactionForm.setCategoryId(fixedCostForm.getCategoryId());
|
||||
transactionForm.setAmount(fixedCostForm.getAmount());
|
||||
transactionForm.setTransactionType(CategoryForm.convertFrom(categoryService.findOne(fixedCostForm.getCategoryId())).getTransactionType());
|
||||
transactionForm.setTransactionType(CategoryForm
|
||||
.convertFrom(categoryService.findOne(fixedCostForm.getCategoryId())).getTransactionType());
|
||||
}
|
||||
|
||||
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
||||
List<CategoryForm> categoryFormList = new ArrayList<>(
|
||||
CategoryForm.convertFrom(categoryService.findAllExceptCustom()));
|
||||
|
||||
List<CategoryForm> categoryFormCustomList = CategoryForm
|
||||
.convertFrom(categoryService.findAllByuserId(loginUser.getUserId()));
|
||||
|
||||
if (!categoryFormCustomList.isEmpty()) {
|
||||
for (CategoryForm form : categoryFormCustomList) {
|
||||
categoryFormList.add(form);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount());
|
||||
|
||||
@@ -232,13 +244,24 @@ public class TransactionController {
|
||||
@SessionCheck
|
||||
@GetMapping("/transaction/update")
|
||||
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
|
||||
Model model) {
|
||||
Model model, HttpSession session) {
|
||||
|
||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||
if (today == null) {
|
||||
today = LocalDate.now();
|
||||
}
|
||||
|
||||
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
||||
List<CategoryForm> categoryFormList = new ArrayList<>(
|
||||
CategoryForm.convertFrom(categoryService.findAllExceptCustom()));
|
||||
|
||||
List<CategoryForm> categoryFormCustomList = CategoryForm
|
||||
.convertFrom(categoryService.findAllByuserId(loginUser.getUserId()));
|
||||
|
||||
if (!categoryFormCustomList.isEmpty()) {
|
||||
for (CategoryForm form : categoryFormCustomList) {
|
||||
categoryFormList.add(form);
|
||||
}
|
||||
}
|
||||
|
||||
TransactionForm transactionForm = TransactionForm.convertFrom(
|
||||
transactionService.findByTransactionId(transactionId),
|
||||
@@ -348,19 +371,19 @@ public class TransactionController {
|
||||
model.addAttribute("totalIncome", totalIncome);
|
||||
model.addAttribute("totalExpense", totalExpense);
|
||||
|
||||
// List<GoalForm> goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
|
||||
// List<GoalForm> goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
|
||||
|
||||
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
|
||||
|
||||
// model.addAttribute("achievementRate", goalForm.getAchievementRate());
|
||||
//
|
||||
// model.addAttribute("currentAmount", goalForm.getCurrentAmount());
|
||||
//
|
||||
// model.addAttribute("targetAmount", goalForm.getTargetAmount());
|
||||
// model.addAttribute("achievementRate", goalForm.getAchievementRate());
|
||||
//
|
||||
// model.addAttribute("currentAmount", goalForm.getCurrentAmount());
|
||||
//
|
||||
// model.addAttribute("targetAmount", goalForm.getTargetAmount());
|
||||
|
||||
model.addAttribute("saving", userForm.getSaving());
|
||||
|
||||
// model.addAttribute("deadline", goalForm.getDeadline());
|
||||
// model.addAttribute("deadline", goalForm.getDeadline());
|
||||
|
||||
return "menu";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user