diff --git a/src/main/java/com/example/demo/app/domain/service/GoalService.java b/src/main/java/com/example/demo/app/domain/service/GoalService.java
index 05e9e89..ce3bf35 100644
--- a/src/main/java/com/example/demo/app/domain/service/GoalService.java
+++ b/src/main/java/com/example/demo/app/domain/service/GoalService.java
@@ -18,6 +18,8 @@ public interface GoalService {
public void updateGoalComplete(Long userId);
+ public int getCurrentAmount(Long userId);
+
// void deleteGoal(Long goalId);
}
\ No newline at end of file
diff --git a/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java
index 5e30fed..3f60f9e 100644
--- a/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java
+++ b/src/main/java/com/example/demo/app/domain/service/impl/GoalServiceImpl.java
@@ -47,7 +47,7 @@ public class GoalServiceImpl implements GoalService {
// 現在の資産 = 貯蓄金 + 収支合計
int currentAmount = userEntity.getSaving() + transactionTotal;
-
+
// 達成率(%) = 現在の資産 ÷ 目標金額 × 100
List goalModelList = new ArrayList();
@@ -59,13 +59,28 @@ public class GoalServiceImpl implements GoalService {
: (int) ((currentAmount * 100.0) / goalEntity.getTargetAmount()),
currentAmount)));
-
return goalModelList;
}
@Override
public GoalModel createGoal(GoalModel goalModel, Long userId) {
+ UserEntity userEntity = userRepository.findById(userId).orElseThrow();
+
+ int transactionTotal = userEntity.getTransactionEntityList().stream()
+ .mapToInt(t -> {
+ int sign = t.getCategoryEntity().getTransactionType() == 1 ? 1 : -1;
+ return sign * t.getAmount();
+ })
+ .sum();
+
+ // 現在の資産 = 貯蓄金 + 収支合計
+ int currentAmount = userEntity.getSaving() + transactionTotal;
+
+ if (currentAmount >= goalModel.getTargetAmount()) {
+ return null;
+ }
+
GoalEntity goalEntity = GoalModel.convertTo(goalModel, userRepository.findById(userId).get());
GoalEntity savedGoalEntity = goalRepository.save(goalEntity);
@@ -82,7 +97,7 @@ public class GoalServiceImpl implements GoalService {
return GoalModel.convertFrom(updatedGoalEntity, 0, 0);
}
-
+
public void delete(Long goalId) {
goalRepository.deleteById(goalId);
}
@@ -100,12 +115,29 @@ public class GoalServiceImpl implements GoalService {
.sum();
int currentAmount = userEntity.getSaving() + transactionTotal;
-
+
goalEntityList.stream().forEach(goalEntity -> {
if (goalEntity.getTargetAmount() <= currentAmount) {
goalRepository.updateCompleteByGoalId(goalEntity.getGoalId());
}
});
}
+
+ public int getCurrentAmount(Long userId) {
+
+ UserEntity userEntity = userRepository.findById(userId).orElseThrow();
+
+ int transactionTotal = userEntity.getTransactionEntityList().stream()
+ .mapToInt(t -> {
+ int sign = t.getCategoryEntity().getTransactionType() == 1 ? 1 : -1;
+ return sign * t.getAmount();
+ })
+ .sum();
+
+ int currentAmount = userEntity.getSaving() + transactionTotal;
+
+ return currentAmount;
+
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/example/demo/app/presentation/controller/CategoryController.java b/src/main/java/com/example/demo/app/presentation/controller/CategoryController.java
index 5576a9e..ba55b94 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/CategoryController.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/CategoryController.java
@@ -12,6 +12,9 @@ import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.CategoryService;
+import com.example.demo.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
+import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
+import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.CategoryForm;
import lombok.RequiredArgsConstructor;
@@ -23,64 +26,64 @@ public class CategoryController {
private final CategoryService categoryService;
- @GetMapping("/category/list")
+ @GetMapping(TransitionTargetPageNameKeyword.CATEGORY_LIST)
public String categoryListGet(Model model, HttpSession session) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
List categoryFormList = CategoryForm.convertFrom(categoryService.findAllByuserId(loginUser.getUserId()));
- model.addAttribute("categoryFormList", categoryFormList);
+ model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList);
- return "category-list";
+ return TransitionTargetPageNameKeyword.CATEGORY_LIST_HTML;
}
- @GetMapping("/category/create")
+ @GetMapping(TransitionTargetPageNameKeyword.CATEGORY_CREATE)
public String categoryCreateGet(@ModelAttribute CategoryForm categoryForm) {
- return "category-create";
+ return TransitionTargetPageNameKeyword.CATEGORY_CREATE_HTML;
}
- @PostMapping("/category/create")
+ @PostMapping(TransitionTargetPageNameKeyword.CATEGORY_CREATE)
public String categoryCreatePost(@ModelAttribute CategoryForm categoryForm, HttpSession session) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
categoryService.save(CategoryForm.convertTo(categoryForm), loginUser.getUserId());
- return "redirect:/category/list";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.CATEGORY_LIST;
}
- @GetMapping("/category/update")
+ @GetMapping(TransitionTargetPageNameKeyword.CATEGORY_UPDATE)
public String categoryUpdateGet(Model model, Long categoryId) {
CategoryForm categoryForm = CategoryForm.convertFrom(categoryService.findOne(categoryId));
- model.addAttribute("categoryId", categoryId);
- model.addAttribute("categoryForm", categoryForm);
+ model.addAttribute(PageReturnAttributeKeyword.CATEGORY_ID, categoryId);
+ model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM, categoryForm);
- return "category-update";
+ return TransitionTargetPageNameKeyword.CATEGORY_UPDATE_HTML;
}
- @PostMapping("/category/update")
+ @PostMapping(TransitionTargetPageNameKeyword.CATEGORY_UPDATE)
public String categoryUpdatePost(@ModelAttribute CategoryForm categoryForm, HttpSession session, Long categoryId) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
categoryForm.setCategoryId(categoryId);
categoryService.save(CategoryForm.convertTo(categoryForm), loginUser.getUserId());
- return "redirect:/category/list";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.CATEGORY_LIST;
}
- @PostMapping("/category/delete")
+ @PostMapping(TransitionTargetPageNameKeyword.CATEGORY_DELETE)
public String categoryDeletePost(Long categoryId) {
categoryService.delete(categoryId);
- return "redirect:/category/list";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.CATEGORY_LIST;
}
diff --git a/src/main/java/com/example/demo/app/presentation/controller/CourseController.java b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java
index 8d98405..cd2f770 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/CourseController.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java
@@ -88,60 +88,60 @@ public class CourseController {
}
@SessionCheck
- @GetMapping("/course/create")
+ @GetMapping(TransitionTargetPageNameKeyword.COURSE_CREATE)
public String createCourseGet(@ModelAttribute CourseForm courseForm, HttpSession session) {
- return "course_create";
+ return TransitionTargetPageNameKeyword.COURSE_CREATE_HTML;
}
@SessionCheck
- @PostMapping("/course/create/ratio")
+ @PostMapping(TransitionTargetPageNameKeyword.COURSE_CREATE_RATIO)
public String createCourse(@ModelAttribute CourseForm courseForm,
@ModelAttribute AllocationFormList allocationFormList,
HttpSession session, Model model) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
CourseForm form = CourseForm
.convertFrom(courseService.save(CourseForm.convertTo(courseForm), loginUser.getUserId()));
- session.setAttribute("courseId", form.getCourseId());
+ session.setAttribute(PageReturnAttributeKeyword.COURSE_ID, form.getCourseId());
- return "course_create_ratio";
+ return TransitionTargetPageNameKeyword.COURSE_CREATE_RATIO_HTML;
}
@SessionCheck
- @PostMapping("/course/create")
+ @PostMapping(TransitionTargetPageNameKeyword.COURSE_CREATE)
public String createCoursePost(@ModelAttribute AllocationFormList allocationFormList, HttpSession session) {
List allocationModelList = new ArrayList<>();
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId1(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio1()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio1()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId2(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio2()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio2()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId3(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio3()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio3()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId4(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio4()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio4()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId5(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio5()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio5()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId6(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio6()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio6()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId7(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio7()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio7()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId8(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio8()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio8()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId9(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio9()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio9()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId10(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio10()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio10()));
allocationModelList.add(new AllocationModel(allocationFormList.getCategoryId11(),
- (Long) session.getAttribute("courseId"), allocationFormList.getAllocationRatio11()));
+ (Long) session.getAttribute(PageReturnAttributeKeyword.COURSE_ID), allocationFormList.getAllocationRatio11()));
allocationService.save(allocationModelList);
- return "redirect:/course";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.COURSE;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/example/demo/app/presentation/controller/FixedCostController.java b/src/main/java/com/example/demo/app/presentation/controller/FixedCostController.java
index 5a0809b..7e76238 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/FixedCostController.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/FixedCostController.java
@@ -16,6 +16,9 @@ import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.CategoryService;
import com.example.demo.app.domain.service.FixedCostService;
+import com.example.demo.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
+import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword;
+import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.demo.app.presentation.form.CategoryForm;
import com.example.demo.app.presentation.form.FixedCostForm;
@@ -29,30 +32,30 @@ public class FixedCostController {
private final CategoryService categoryService;
@SessionCheck
- @GetMapping("/fixed-cost/list")
+ @GetMapping(TransitionTargetPageNameKeyword.FIXED_COST_LIST)
public String getFixedCostList(
HttpSession session, Model model, LocalDate today) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (today == null) {
- today = (LocalDate) session.getAttribute("today");
+ today = (LocalDate) session.getAttribute(PageReturnAttributeKeyword.TODAY);
}
List fixedCostFormList = FixedCostForm.convertFrom(fixedCostService.findAllByUserId(loginUser.getUserId()));
fixedCostFormList.forEach(fixedCostForm -> fixedCostForm.setCategoryName(categoryService.findOne(fixedCostForm.getCategoryId()).getCategoryName()));
- model.addAttribute("fixedCostFormList", fixedCostFormList);
+ model.addAttribute(PageReturnAttributeKeyword.FIXED_COST_FORM_LIST, fixedCostFormList);
- model.addAttribute("today", today);
+ model.addAttribute(PageReturnAttributeKeyword.TODAY, today);
- return "fixed_cost";
+ return TransitionTargetPageNameKeyword.FIXED_COST_HTML;
}
@SessionCheck
- @GetMapping("/fixed-cost/create")
+ @GetMapping(TransitionTargetPageNameKeyword.FIXED_COST_CREATE)
public String getFixedCostCreate(
HttpSession session, @ModelAttribute FixedCostForm fixedCostForm, Model model, LocalDate today) {
@@ -72,42 +75,42 @@ public class FixedCostController {
}
- model.addAttribute("expenseList", expenseList);
- model.addAttribute("incomeList", incomeList);
- model.addAttribute("today", today);
+ model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
+ model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
+ model.addAttribute(PageReturnAttributeKeyword.TODAY, today);
- return "fixed_cost_create";
+ return TransitionTargetPageNameKeyword.FIXED_COST_CREATE_HTML;
}
@SessionCheck
- @PostMapping("/fixed-cost/create")
+ @PostMapping(TransitionTargetPageNameKeyword.FIXED_COST_CREATE)
public String postFixedCostCreate(
HttpSession session, @ModelAttribute FixedCostForm fixedCostForm, Model model, LocalDate today) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
fixedCostForm.setUserId(loginUser.getUserId());
fixedCostService.save(FixedCostForm.convertTo(fixedCostForm));
- session.setAttribute("today", today);
+ session.setAttribute(PageReturnAttributeKeyword.TODAY, today);
- return "redirect:/fixed-cost/list";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.FIXED_COST_LIST;
}
@SessionCheck
- @PostMapping("/fixed-cost/delete")
+ @PostMapping(TransitionTargetPageNameKeyword.FIXED_COST_DELETE)
public String postFixedCostDelete(Long fixedCostId, LocalDate today, HttpSession session) {
fixedCostService.delete(fixedCostId);
- session.setAttribute("today", today);
+ session.setAttribute(PageReturnAttributeKeyword.TODAY, today);
- return "redirect:/fixed-cost/list";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.FIXED_COST_LIST;
}
diff --git a/src/main/java/com/example/demo/app/presentation/controller/GoalController.java b/src/main/java/com/example/demo/app/presentation/controller/GoalController.java
index 4985491..cb7ee49 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/GoalController.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/GoalController.java
@@ -53,7 +53,7 @@ public class GoalController {
HttpSession session,
Long goalId) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
@@ -68,15 +68,15 @@ public class GoalController {
.collect(Collectors.toList());
model.addAttribute(
- "goalFormList",
+ PageReturnAttributeKeyword.GOAL_FORM_LIST,
goalFormList);
model.addAttribute(
- "achievementList",
+ PageReturnAttributeKeyword.ACHIEVEMENT_LIST,
new ArrayList());
if (goalFormList.isEmpty()) {
- return "goal_view";
+ return TransitionTargetPageNameKeyword.GOAL_VIEW_HTML;
}
GoalForm graphGoal;
@@ -95,7 +95,7 @@ public class GoalController {
}
model.addAttribute(
- "graphGoal",
+ PageReturnAttributeKeyword.GRAPH_GOAL,
graphGoal);
int currentAmount = graphGoal.getCurrentAmount();
@@ -223,7 +223,7 @@ public class GoalController {
}
model.addAttribute(
- "achievementList",
+ PageReturnAttributeKeyword.ACHIEVEMENT_LIST,
achievementList);
return TransitionTargetPageNameKeyword.GOAL_VIEW_HTML;
@@ -266,44 +266,55 @@ public class GoalController {
}
@SessionCheck
- @GetMapping("/create")
- public String createGoalGet(@ModelAttribute GoalForm goalForm, HttpSession session) {
+ @GetMapping(TransitionTargetPageNameKeyword.CREATE)
+ public String createGoalGet(@ModelAttribute GoalForm goalForm, HttpSession session, Model model) {
- return "goal_create";
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
+
+ Long userId = loginUser.getUserId();
+
+ int currentAmount = goalService.getCurrentAmount(userId);
+
+ model.addAttribute("currentAmount", currentAmount);
+
+ return TransitionTargetPageNameKeyword.GOAL_CREATE_HTML;
}
@SessionCheck
- @PostMapping("/create")
- public String createGoalPost(@ModelAttribute GoalForm goalForm, HttpSession session) {
+ @PostMapping(TransitionTargetPageNameKeyword.CREATE)
+ public String createGoalPost(@ModelAttribute GoalForm goalForm, HttpSession session, Model model) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
- goalService.createGoal(GoalModel.convertFrom(goalForm), userId);
+ if (goalService.createGoal(GoalModel.convertFrom(goalForm), userId) == null) {
+ model.addAttribute(PageReturnAttributeKeyword.MESSAGE, "現在所持金より高い金額を設定してください。");
+ return TransitionTargetPageNameKeyword.GOAL_CREATE_HTML;
+ }
- return "redirect:/goal";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL;
}
@SessionCheck
- @PostMapping("/delete") // フラグ考慮してないため、今度修正必要
+ @PostMapping(TransitionTargetPageNameKeyword.DELETE) // フラグ考慮してないため、今度修正必要
public String deleteGoal(Long goalId, Long record) {
goalService.delete(goalId);
if (record == null) {
- return "redirect:/goal";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL;
} else {
- return "redirect:/goal/record";
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.GOAL + TransitionTargetPageNameKeyword.RECORD;
}
}
@SessionCheck
- @GetMapping("/record")
+ @GetMapping(TransitionTargetPageNameKeyword.RECORD)
public String getRecord(HttpSession session, Model model) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
Long userId = loginUser.getUserId();
goalService.updateGoalComplete(userId);
@@ -320,10 +331,10 @@ public class GoalController {
});
model.addAttribute(
- "goalCompleteFormList",
+ PageReturnAttributeKeyword.GOAL_COMPLETE_FORM_LIST,
goalCompleteFormList);
- return "goal_record";
+ return TransitionTargetPageNameKeyword.GOAL_RECORD_HTML;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/example/demo/app/presentation/controller/LoginController.java b/src/main/java/com/example/demo/app/presentation/controller/LoginController.java
index 099f47d..47d26a3 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/LoginController.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/LoginController.java
@@ -26,8 +26,8 @@ public class LoginController {
@GetMapping(TransitionTargetPageNameKeyword.LOGIN)
public String showLogin(@ModelAttribute LoginForm loginForm, HttpSession session) {
- if (session.getAttribute("loginUser") != null) {
- return "redirect:/menu";
+ if (session.getAttribute(SessionKeyword.LOGIN_USER) != null) {
+ return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.MENU;
}
return TransitionTargetPageNameKeyword.LOGIN_HTML;
diff --git a/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java b/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java
index eb2cc95..009acc8 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/TransactionController.java
@@ -192,7 +192,7 @@ public class TransactionController {
Long fixedCostId,
Model model, HttpSession session) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (today == null) {
today = LocalDate.now();
}
@@ -218,6 +218,24 @@ public class TransactionController {
}
}
+
+ List expenseList = new ArrayList();
+
+ List incomeList = new ArrayList();
+
+ for (CategoryForm categoryForm : categoryFormList) {
+
+ if (categoryForm.getTransactionType() == 0) {
+ expenseList.add(categoryForm);
+ } else {
+ incomeList.add(categoryForm);
+ }
+
+ }
+
+ model.addAttribute(PageReturnAttributeKeyword.EXPENSE_LIST, expenseList);
+ model.addAttribute(PageReturnAttributeKeyword.INCOME_LIST, incomeList);
+
model.addAttribute(PageReturnAttributeKeyword.TRANSACTION_FORM, transactionForm);
model.addAttribute(PageReturnAttributeKeyword.CATEGORY_FORM_LIST, categoryFormList);
@@ -253,7 +271,7 @@ public class TransactionController {
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
Model model, HttpSession session) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
if (today == null) {
today = LocalDate.now();
}
@@ -295,7 +313,7 @@ public class TransactionController {
@RequestParam LocalDate today, Model model,
HttpSession session) {
- LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
+ LoginModel loginUser = (LoginModel) session.getAttribute(SessionKeyword.LOGIN_USER);
transactionForm.setUserId(loginUser.getUserId());
transactionForm.setTransactionId(transactionId);
@@ -407,15 +425,17 @@ public class TransactionController {
model.addAttribute(PageReturnAttributeKeyword.DEADLINE, result.getDeadline());
} else {
- model.addAttribute(PageReturnAttributeKeyword.ACHIEVEMENT_RATE, "目標を設定してください");
+ final String MESSAGE = "目標を設定してください";
- model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, "目標を設定してください");
+ model.addAttribute(PageReturnAttributeKeyword.ACHIEVEMENT_RATE, MESSAGE);
- model.addAttribute(PageReturnAttributeKeyword.TARGET_AMOUNT, "目標を設定してください");
+ model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, MESSAGE);
+
+ model.addAttribute(PageReturnAttributeKeyword.TARGET_AMOUNT, MESSAGE);
model.addAttribute(PageReturnAttributeKeyword.SAVING, userForm.getSaving());
- model.addAttribute(PageReturnAttributeKeyword.DEADLINE, "目標を設定してください");
+ model.addAttribute(PageReturnAttributeKeyword.DEADLINE, MESSAGE);
}
return TransitionTargetPageNameKeyword.MENU_HTML;
diff --git a/src/main/java/com/example/demo/app/presentation/controller/UserController.java b/src/main/java/com/example/demo/app/presentation/controller/UserController.java
index ebfc930..2c3eb8e 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/UserController.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/UserController.java
@@ -59,7 +59,7 @@ public class UserController {
}
session.setAttribute(PageReturnAttributeKeyword.SELECTED_COURSE_NAME, courseService.findById(courseId).getCourseName());
- model.addAttribute(PageReturnAttributeKeyword.COURESE_ID, courseId);
+ model.addAttribute(PageReturnAttributeKeyword.COURSE_ID, courseId);
model.addAttribute(PageReturnAttributeKeyword.USER_FORM, userForm);
return TransitionTargetPageNameKeyword.USER_RESISTER_RETURN_HTML;
@@ -71,6 +71,11 @@ public class UserController {
HttpSession session) {
model.addAttribute(PageReturnAttributeKeyword.SELECTED_COURSE_NAME, (String) session.getAttribute("selectedCourseName"));
+
+ session.setAttribute("questionId", userForm.getSecretQuestionId());
+
+ System.out.println("return questionId: ****************************:" + userForm.getSecretQuestionId());
+
return TransitionTargetPageNameKeyword.USER_RESISTER_CONFIRM_HTML;
}
@@ -83,6 +88,12 @@ public class UserController {
Long courseId = courseService.findByName((String) session.getAttribute(PageReturnAttributeKeyword.SELECTED_COURSE_NAME));
+ Long questionId = (Long) session.getAttribute("questionId");
+
+ System.out.println("confirm questionId: ****************************:" + questionId);
+
+ userForm.setSecretQuestionId(questionId);
+
userService.register(userForm, courseId);
return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.LOGIN;
diff --git a/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java b/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java
index c5b6eea..3b0a32a 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java
@@ -9,7 +9,7 @@ public class PageReturnAttributeKeyword {
public static final String QUESTION_LIST = "questionList";
public static final String USER_FORM = "userForm";
public static final String SELECTED_COURSE_NAME = "selectedCourseName";
- public static final String COURESE_ID = "courseId";
+ public static final String COURSE_ID = "courseId";
public static final String PASSWOR_RESET_FORM = "passwordResetForm";
public static final String PASSWOR_RESET_USER_ID = "passwordResetUserId";
@@ -52,5 +52,14 @@ public class PageReturnAttributeKeyword {
public static final String ANALYSIS_FORM = "analysisForm";
public static final String GOAL_FORM = "goalForm";
+ public static final String GOAL_FORM_LIST = "goalFormList";
+ public static final String ACHIEVEMENT_LIST = "achievementList";
+ public static final String GRAPH_GOAL = "graphGoal";
+ public static final String GOAL_COMPLETE_FORM_LIST = "goalCompleteFormList";
+
+ public static final String CATEGORY_ID = "categoryId";
+ public static final String CATEGORY_FORM = "categoryForm";
+
+ public static final String FIXED_COST_FORM_LIST = "fixedCostFormList";
}
diff --git a/src/main/java/com/example/demo/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java b/src/main/java/com/example/demo/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java
index 3249dee..98f7bde 100644
--- a/src/main/java/com/example/demo/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java
+++ b/src/main/java/com/example/demo/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java
@@ -21,6 +21,8 @@ public class TransitionTargetPageNameKeyword {
public static final String PROFILE_EDIT_HTML = "profile_edit";
public static final String SELECT_COURSE_HTML = "select_course";
+ public static final String COURSE_CREATE_HTML = "course_create";
+ public static final String COURSE_CREATE_RATIO_HTML = "course_create_ratio";
public static final String TRANSACTION_LIST_HTML = "transaction_list";
public static final String TRANSACTION_DETAIL_HTML = "transaction_detail";
@@ -31,6 +33,15 @@ public class TransitionTargetPageNameKeyword {
public static final String GOAL_VIEW_HTML = "goal_view";
public static final String GOAL_EDIT_HTML = "goal_edit";
+ public static final String GOAL_CREATE_HTML = "goal_create";
+ public static final String GOAL_RECORD_HTML = "goal_record";
+
+ public static final String CATEGORY_LIST_HTML = "category_list";
+ public static final String CATEGORY_CREATE_HTML = "category_create";
+ public static final String CATEGORY_UPDATE_HTML = "category_update";
+
+ public static final String FIXED_COST_HTML = "fixed_cost";
+ public static final String FIXED_COST_CREATE_HTML = "fixed_cost_create";
// Countroller
public static final String ERROR = "/error";
@@ -58,6 +69,9 @@ public class TransitionTargetPageNameKeyword {
public static final String SHOW_SELECT_COURSE = "/user/register/course";
public static final String COURSE = "/course";
public static final String CHANGE = "/change";
+ public static final String COURSE_CREATE = "/course/create";
+ public static final String COURSE_CREATE_RATIO = "/course/create/ratio";
+
public static final String INTERROGATION = "?";
public static final String EQUAL = "=";
@@ -73,5 +87,18 @@ public class TransitionTargetPageNameKeyword {
public static final String GOAL = "/goal";
public static final String EDIT = "/edit";
public static final String UPDATE = "/update";
+ public static final String CREATE = "/create";
+ public static final String DELETE = "/delete";
+ public static final String RECORD = "/record";
+
+ public static final String CATEGORY_LIST = "/category/list";
+ public static final String CATEGORY_CREATE = "/category/create";
+ public static final String CATEGORY_UPDATE = "/category/update";
+ public static final String CATEGORY_DELETE = "/category/delete";
+
+ public static final String FIXED_COST_LIST = "/fixed-cost/list";
+ public static final String FIXED_COST_CREATE = "/fixed-cost/create";
+ public static final String FIXED_COST_DELETE = "/fixed-cost/delete";
+
}
diff --git a/src/main/resources/templates/category-create.html b/src/main/resources/templates/category_create.html
similarity index 100%
rename from src/main/resources/templates/category-create.html
rename to src/main/resources/templates/category_create.html
diff --git a/src/main/resources/templates/category-list.html b/src/main/resources/templates/category_list.html
similarity index 100%
rename from src/main/resources/templates/category-list.html
rename to src/main/resources/templates/category_list.html
diff --git a/src/main/resources/templates/category-update.html b/src/main/resources/templates/category_update.html
similarity index 100%
rename from src/main/resources/templates/category-update.html
rename to src/main/resources/templates/category_update.html
diff --git a/src/main/resources/templates/goal_create.html b/src/main/resources/templates/goal_create.html
index a97384f..2057470 100644
--- a/src/main/resources/templates/goal_create.html
+++ b/src/main/resources/templates/goal_create.html
@@ -37,6 +37,10 @@
+
+
+
+
@@ -44,7 +48,7 @@
-
+
diff --git a/src/main/resources/templates/goal_view.html b/src/main/resources/templates/goal_view.html
index 26ecdd4..5249f82 100644
--- a/src/main/resources/templates/goal_view.html
+++ b/src/main/resources/templates/goal_view.html
@@ -112,7 +112,7 @@
- -
+
-
diff --git a/src/main/resources/templates/password_reset.html b/src/main/resources/templates/password_reset.html
index 453a9db..4206bc9 100644
--- a/src/main/resources/templates/password_reset.html
+++ b/src/main/resources/templates/password_reset.html
@@ -59,6 +59,10 @@
required>
+
+
+
+
diff --git a/src/main/resources/templates/transaction_create.html b/src/main/resources/templates/transaction_create.html
index 8ad421c..115ae4f 100644
--- a/src/main/resources/templates/transaction_create.html
+++ b/src/main/resources/templates/transaction_create.html
@@ -15,127 +15,149 @@
+
+
-
-
+
+
-
+
-
- 新規会員登録
-
+
+ 新規会員登録
+
-
-
-
+
+
+
+
-
-
+
+
-
+
新規会員登録
-
+
-
-
+
-
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/templates/user_register.html b/src/main/resources/templates/user_register.html
index b8067b4..cdc4f99 100644
--- a/src/main/resources/templates/user_register.html
+++ b/src/main/resources/templates/user_register.html
@@ -2,229 +2,192 @@
diff --git a/src/main/resources/templates/user_register_confirm.html b/src/main/resources/templates/user_register_confirm.html
index 6d39145..fedad18 100644
--- a/src/main/resources/templates/user_register_confirm.html
+++ b/src/main/resources/templates/user_register_confirm.html
@@ -44,14 +44,14 @@
diff --git a/src/main/resources/templates/user_register_return.html b/src/main/resources/templates/user_register_return.html
index 272432d..93569ea 100644
--- a/src/main/resources/templates/user_register_return.html
+++ b/src/main/resources/templates/user_register_return.html
@@ -1,153 +1,145 @@
-
+
+