Compare commits
33 Commits
a2b1922548
...
9259a53bad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9259a53bad | ||
|
|
ad1121d694 | ||
|
|
6ca5a9eeec | ||
| 709f5e14da | |||
| 6197b12ac4 | |||
| 18faec044e | |||
|
|
b49c9156a1 | ||
| 6b4ae5bd96 | |||
|
|
9cdf7b7767 | ||
|
|
6dd182ed0b | ||
|
|
04d62956f7 | ||
|
|
a5c9ab9abe | ||
|
|
200ebe2a61 | ||
|
|
2300aa3644 | ||
|
|
d415bf1ad5 | ||
|
|
12550c5b1d | ||
| 15bf2949bc | |||
| be9abffeaa | |||
| cb7a3f542b | |||
| 702dd24d2e | |||
| d71194659b | |||
| 44ceb0ca07 | |||
| 614533e2b0 | |||
| 2da75305fd | |||
| f55ece4dc7 | |||
| 0a63c81712 | |||
| 571fcc6d90 | |||
| 15185672c4 | |||
| 3833689759 | |||
| 0bec7b3b3b | |||
| 662e3433d2 | |||
| 60d4ebd74f | |||
| 49af15f939 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,3 +31,4 @@ build/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
/bin/
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package com.example.demo.app.domain.model;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
|
import com.example.demo.app.presentation.form.GoalForm;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -21,4 +24,35 @@ public class GoalModel {
|
|||||||
|
|
||||||
private Integer goalComplete;
|
private Integer goalComplete;
|
||||||
|
|
||||||
|
public static GoalModel convertFrom(GoalEntity goalEntity) {
|
||||||
|
return new GoalModel(
|
||||||
|
goalEntity.getGoalId(),
|
||||||
|
goalEntity.getGoalTitle(),
|
||||||
|
goalEntity.getGoalSubtitle(),
|
||||||
|
goalEntity.getTargetAmount(),
|
||||||
|
goalEntity.getDeadline(),
|
||||||
|
goalEntity.getGoalComplete());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GoalEntity convertTo(GoalModel goalModel) {
|
||||||
|
return new GoalEntity(
|
||||||
|
goalModel.getGoalId(),
|
||||||
|
goalModel.getGoalTitle(),
|
||||||
|
goalModel.getGoalSubtitle(),
|
||||||
|
goalModel.getTargetAmount(),
|
||||||
|
goalModel.getDeadline(),
|
||||||
|
goalModel.getGoalComplete(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GoalModel convertFrom(GoalForm goalForm) {
|
||||||
|
return new GoalModel(
|
||||||
|
goalForm.getGoalId(),
|
||||||
|
goalForm.getGoalTitle(),
|
||||||
|
goalForm.getGoalSubtitle(),
|
||||||
|
goalForm.getTargetAmount(),
|
||||||
|
goalForm.getDeadline(),
|
||||||
|
goalForm.getGoalComplete());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,4 +11,6 @@ public interface CategoryService {
|
|||||||
public CategoryModel findOne(Long categoryId);
|
public CategoryModel findOne(Long categoryId);
|
||||||
|
|
||||||
public CategoryModel findOneByCategoryName(String categoryName);
|
public CategoryModel findOneByCategoryName(String categoryName);
|
||||||
|
|
||||||
|
public CategoryModel findByTransactionId(Long transactionId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
|
||||||
|
public interface GoalService {
|
||||||
|
|
||||||
|
GoalModel getGoalById(Long goalId);
|
||||||
|
|
||||||
|
GoalModel getGoalByUserId(Long userId);
|
||||||
|
|
||||||
|
GoalModel createGoal(GoalModel goalModel);
|
||||||
|
|
||||||
|
GoalModel updateGoal(GoalModel goalModel);
|
||||||
|
|
||||||
|
// void deleteGoal(Long goalId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import com.example.demo.app.presentation.form.Income;
|
|||||||
|
|
||||||
public interface TransactionService {
|
public interface TransactionService {
|
||||||
|
|
||||||
|
public TransactionModel findByTransactionId(Long transactionId);
|
||||||
|
|
||||||
public Map<LocalDate, List<TransactionModel>> findAllByDate(LocalDate startDate, LocalDate endDate, Long userId);
|
public Map<LocalDate, List<TransactionModel>> findAllByDate(LocalDate startDate, LocalDate endDate, Long userId);
|
||||||
|
|
||||||
public List<TransactionModel> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
public List<TransactionModel> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
||||||
@@ -18,6 +20,8 @@ public interface TransactionService {
|
|||||||
|
|
||||||
public int findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId);
|
public int findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId);
|
||||||
|
|
||||||
|
public int findMoneyRecord(Long transactionId);
|
||||||
|
|
||||||
public int createTransaction(TransactionModel transactionModel);
|
public int createTransaction(TransactionModel transactionModel);
|
||||||
|
|
||||||
public int updateTransaction(TransactionModel transactionModel);
|
public int updateTransaction(TransactionModel transactionModel);
|
||||||
|
|||||||
@@ -3,5 +3,8 @@ package com.example.demo.app.domain.service;
|
|||||||
import com.example.demo.app.presentation.form.UserForm;
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
void register(UserForm userForm);
|
|
||||||
|
void register(UserForm userForm);
|
||||||
|
|
||||||
|
public void updateCourse(Long userId, Long courseId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,4 +48,9 @@ public class CategoryServiceImpl implements CategoryService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CategoryModel findByTransactionId(Long transactionId) {
|
||||||
|
return CategoryModel.convertFrom(categoryRepository.findByTransactionId(transactionId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
import com.example.demo.app.domain.service.GoalService;
|
||||||
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.GoalRepository;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GoalServiceImpl implements GoalService {
|
||||||
|
|
||||||
|
private final GoalRepository goalRepository;
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel getGoalById(Long goalId) {
|
||||||
|
GoalEntity goalEntity = goalRepository.findById(goalId).orElse(null);
|
||||||
|
return GoalModel.convertFrom(goalEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel getGoalByUserId(Long userId) {
|
||||||
|
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
|
||||||
|
GoalEntity goalEntity = userEntity.getGoalEntity();
|
||||||
|
return GoalModel.convertFrom(goalEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel createGoal(GoalModel goalModel) {
|
||||||
|
|
||||||
|
GoalEntity goalEntity = GoalModel.convertTo(goalModel);
|
||||||
|
|
||||||
|
GoalEntity savedGoalEntity = goalRepository.save(goalEntity);
|
||||||
|
|
||||||
|
return GoalModel.convertFrom(savedGoalEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel updateGoal(GoalModel goalModel) {
|
||||||
|
|
||||||
|
GoalEntity goalEntity = GoalModel.convertTo(goalModel);
|
||||||
|
|
||||||
|
GoalEntity updatedGoalEntity = goalRepository.save(goalEntity);
|
||||||
|
|
||||||
|
return GoalModel.convertFrom(updatedGoalEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,13 @@ public class TransactionServiceImpl implements TransactionService {
|
|||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final CategoryRepository categoryRepository;
|
private final CategoryRepository categoryRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public TransactionModel findByTransactionId(Long transactionId) {
|
||||||
|
|
||||||
|
return TransactionModel.convertFrom(transactionRepository.findById(transactionId).get());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Map<LocalDate, List<TransactionModel>> findAllByDate(
|
public Map<LocalDate, List<TransactionModel>> findAllByDate(
|
||||||
LocalDate startDate,
|
LocalDate startDate,
|
||||||
LocalDate endDate,
|
LocalDate endDate,
|
||||||
@@ -92,6 +99,11 @@ public class TransactionServiceImpl implements TransactionService {
|
|||||||
return TransactionModel.convertFrom(transactionRepository.findByUserIdAndDate(todayDate, userId));
|
return TransactionModel.convertFrom(transactionRepository.findByUserIdAndDate(todayDate, userId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int findMoneyRecord(Long transactionId) {
|
||||||
|
return transactionRepository.findMoneyRecord(transactionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int createTransaction(TransactionModel transactionModel) {
|
public int createTransaction(TransactionModel transactionModel) {
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,18 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
userRepository.save(userEntity);
|
userRepository.save(userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCourse(Long userId, Long courseId) {
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
|
||||||
|
|
||||||
|
CourseEntity courseEntity = courseRepository.findById(courseId).orElseThrow();
|
||||||
|
|
||||||
|
userEntity.setCourseEntity(courseEntity);
|
||||||
|
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class GoalEntity {
|
|||||||
@Column(name = "deadline", nullable = false)
|
@Column(name = "deadline", nullable = false)
|
||||||
private LocalDate deadline;
|
private LocalDate deadline;
|
||||||
|
|
||||||
@Column(name = "goal_complete", nullable = false)
|
@Column(name = "goal_complete", nullable = true)
|
||||||
private Integer goalComplete;
|
private Integer goalComplete;
|
||||||
|
|
||||||
@OneToOne(mappedBy = "goalEntity")
|
@OneToOne(mappedBy = "goalEntity")
|
||||||
|
|||||||
@@ -12,4 +12,7 @@ public interface CategoryRepository extends JpaRepository<CategoryEntity, Long>
|
|||||||
@Query("select c from CategoryEntity c where c.categoryName = :categoryName")
|
@Query("select c from CategoryEntity c where c.categoryName = :categoryName")
|
||||||
public CategoryEntity findByCategoryName(@Param("categoryName") String categoryName);
|
public CategoryEntity findByCategoryName(@Param("categoryName") String categoryName);
|
||||||
|
|
||||||
|
@Query("select c from CategoryEntity c inner join TransactionEntity t on c.categoryId = t.categoryEntity.categoryId where t.transactionId = :transactionId")
|
||||||
|
public CategoryEntity findByTransactionId(Long transactionId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,5 +33,7 @@ public interface TransactionRepository extends JpaRepository<TransactionEntity,
|
|||||||
@Query("select new com.example.demo.app.presentation.form.Income(t.transactionDate, coalesce(sum(t.amount), 0)) from TransactionEntity t inner join CategoryEntity c on t.categoryEntity.categoryId = c.categoryId where (t.userEntity.userId = :userId and t.transactionDate between :startDate and :endDate) and c.transactionType = 1 group by t.transactionDate order by t.transactionDate asc")
|
@Query("select new com.example.demo.app.presentation.form.Income(t.transactionDate, coalesce(sum(t.amount), 0)) from TransactionEntity t inner join CategoryEntity c on t.categoryEntity.categoryId = c.categoryId where (t.userEntity.userId = :userId and t.transactionDate between :startDate and :endDate) and c.transactionType = 1 group by t.transactionDate order by t.transactionDate asc")
|
||||||
public List<Income> findTotalIncomeList(LocalDate startDate, LocalDate endDate, Long userId);
|
public List<Income> findTotalIncomeList(LocalDate startDate, LocalDate endDate, Long userId);
|
||||||
|
|
||||||
|
@Query("select coalesce(t.amount, 0) from TransactionEntity t where t.transactionId = :transactionId")
|
||||||
|
public Integer findMoneyRecord(Long transactionId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
package com.example.demo.app.presentation.controller;
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
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.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
import com.example.demo.app.domain.model.UserModel;
|
||||||
import com.example.demo.app.domain.service.CourseInfoService;
|
import com.example.demo.app.domain.service.CourseInfoService;
|
||||||
import com.example.demo.app.domain.service.CourseService;
|
import com.example.demo.app.domain.service.CourseService;
|
||||||
|
import com.example.demo.app.domain.service.UserService;
|
||||||
import com.example.demo.app.presentation.form.CourseForm;
|
import com.example.demo.app.presentation.form.CourseForm;
|
||||||
import com.example.demo.app.presentation.form.CourseInfoForm;
|
import com.example.demo.app.presentation.form.CourseInfoForm;
|
||||||
|
|
||||||
@@ -15,6 +24,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequestMapping("/course")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CourseController {
|
public class CourseController {
|
||||||
|
|
||||||
@@ -22,31 +32,70 @@ public class CourseController {
|
|||||||
// エラーメッセージ用の定数フィールド
|
// エラーメッセージ用の定数フィールド
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
// private final HttpSession httpSession;
|
private final HttpSession httpSession;
|
||||||
private final CourseService courseService;
|
private final CourseService courseService;
|
||||||
private final CourseInfoService courseInfoService;
|
private final CourseInfoService courseInfoService;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/select-course")
|
@PostMapping("/select/register")
|
||||||
public String select(Model model) {
|
public String showSelectCourse(@ModelAttribute UserModel userModel, Model model) {
|
||||||
|
|
||||||
//try {
|
try {
|
||||||
|
|
||||||
|
model.addAttribute("mode", "select");
|
||||||
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
||||||
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
||||||
|
|
||||||
return "select_course";
|
return "select_course";
|
||||||
|
|
||||||
//} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// // ログイン情報の破棄
|
// ログイン情報の破棄
|
||||||
// httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
//
|
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
//
|
|
||||||
// // エラーログ出力
|
// エラーログ出力
|
||||||
// LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// // エラー画面遷移
|
// エラー画面遷移
|
||||||
// return null;
|
return null;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/select/change")
|
||||||
|
public String showChangeCourse(Model model) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
model.addAttribute("mode", "change");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/change")
|
||||||
|
public String changeCourse(@RequestParam Long courseId) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) httpSession.getAttribute("loginUser");
|
||||||
|
|
||||||
|
userService.updateCourse(loginUser.getUserId(), courseId);
|
||||||
|
|
||||||
|
return "redirect:/menu";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
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.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
import com.example.demo.app.domain.service.GoalService;
|
||||||
|
import com.example.demo.app.presentation.form.GoalForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/goal")
|
||||||
|
public class GoalController {
|
||||||
|
|
||||||
|
private final GoalService goalService;
|
||||||
|
|
||||||
|
@GetMapping("")
|
||||||
|
public String getGoal(Model model, HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
//テスト用
|
||||||
|
// Long userId = 1L;
|
||||||
|
|
||||||
|
GoalModel goalModel = goalService.getGoalByUserId(userId);
|
||||||
|
GoalForm goalForm = GoalForm.convertFrom(goalModel);
|
||||||
|
|
||||||
|
model.addAttribute("goalForm", goalForm);
|
||||||
|
return "goal_view";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/edit")
|
||||||
|
public String editGoal(Model model, HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
|
||||||
|
//テスト用
|
||||||
|
// Long userId = 1L;
|
||||||
|
|
||||||
|
GoalModel goalModel = goalService.getGoalByUserId(userId);
|
||||||
|
GoalForm goalForm = GoalForm.convertFrom(goalModel);
|
||||||
|
|
||||||
|
model.addAttribute("goalForm", goalForm);
|
||||||
|
return "goal_edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
//テスト用
|
||||||
|
// Long userId = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
// 本人の目標かどうかを確認してから更新する
|
||||||
|
GoalModel currentGoal = goalService.getGoalByUserId(userId);
|
||||||
|
|
||||||
|
if (!currentGoal.getGoalId().equals(goalForm.getGoalId())) {
|
||||||
|
return "redirect:/goal"; // 他人のデータを更新しようとしたら弾く
|
||||||
|
}
|
||||||
|
|
||||||
|
GoalModel goalModel = GoalModel.convertFrom(goalForm);
|
||||||
|
goalService.updateGoal(goalModel);
|
||||||
|
|
||||||
|
return "redirect:/goal";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.example.demo.app.presentation.controller;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -65,9 +66,7 @@ public class TransactionController {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
transactionFormMap.put(date, transactionFormList);
|
transactionFormMap.put(date, transactionFormList);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
model.addAttribute("transactionFormMap", transactionFormMap);
|
model.addAttribute("transactionFormMap", transactionFormMap);
|
||||||
|
|
||||||
return "transaction_list";
|
return "transaction_list";
|
||||||
@@ -78,21 +77,45 @@ public class TransactionController {
|
|||||||
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
|
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
|
||||||
|
|
||||||
LocalDate todayDate = (todayDates == null) ? LocalDate.now() : todayDates;
|
LocalDate todayDate = (todayDates == null) ? LocalDate.now() : todayDates;
|
||||||
|
|
||||||
|
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
List<TransactionForm> transactionFormList = transactionService
|
List<TransactionForm> transactionFormList = transactionService
|
||||||
.findByUserIdAndDate(todayDate, loginUser.getUserId()).stream()
|
.findByUserIdAndDate(todayDate, loginUser.getUserId()).stream()
|
||||||
.map(transaction -> {
|
.map(transaction -> {
|
||||||
TransactionForm transactionForm = TransactionForm.convertFrom(
|
|
||||||
transaction,
|
int type = CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
.getTransactionType();
|
||||||
.getCategoryName(),
|
|
||||||
transactionService.findTotalExpense(todayDate, todayDate, loginUser.getUserId()),
|
TransactionForm transactionForm;
|
||||||
transactionService.findTotalIncome(todayDate, todayDate, loginUser.getUserId()),
|
if (type == 1) {
|
||||||
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
|
||||||
.getTransactionType());
|
transactionForm = TransactionForm.convertFrom(
|
||||||
|
transaction,
|
||||||
|
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
|
.getCategoryName(),
|
||||||
|
0,
|
||||||
|
transactionService.findMoneyRecord(transaction.getTransactionId()),
|
||||||
|
type);
|
||||||
|
|
||||||
|
} else if (type == 0) {
|
||||||
|
transactionForm = TransactionForm.convertFrom(
|
||||||
|
transaction,
|
||||||
|
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
|
.getCategoryName(),
|
||||||
|
transactionService.findMoneyRecord(transaction.getTransactionId()),
|
||||||
|
0,
|
||||||
|
type);
|
||||||
|
} else {
|
||||||
|
transactionForm = TransactionForm.convertFrom(
|
||||||
|
transaction,
|
||||||
|
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
|
.getCategoryName(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
type);
|
||||||
|
}
|
||||||
|
|
||||||
return transactionForm;
|
return transactionForm;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
@@ -103,102 +126,146 @@ public class TransactionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/transaction/create")
|
@GetMapping("/transaction/create")
|
||||||
public String createOneGet(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model) {
|
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
|
||||||
|
Model model) {
|
||||||
|
|
||||||
|
if (today == null) {
|
||||||
|
today = LocalDate.now();
|
||||||
|
}
|
||||||
|
|
||||||
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
||||||
|
|
||||||
|
TransactionForm transactionForm = new TransactionForm();
|
||||||
|
transactionForm.setTransactionDate(today);
|
||||||
|
|
||||||
|
System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount());
|
||||||
|
|
||||||
|
model.addAttribute("transactionForm", transactionForm);
|
||||||
|
|
||||||
model.addAttribute("categoryFormList", categoryFormList);
|
model.addAttribute("categoryFormList", categoryFormList);
|
||||||
model.addAttribute("today", today);
|
|
||||||
|
model.addAttribute("today", today.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
|
||||||
return "transaction_create";
|
return "transaction_create";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/transaction/create")
|
@PostMapping("/transaction/create")
|
||||||
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model, HttpSession session) {
|
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
transactionForm.setUserId(loginUser.getUserId());
|
transactionForm.setUserId(loginUser.getUserId());
|
||||||
transactionForm.setTransactionDate(today);
|
|
||||||
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "redirect:/transaction/detail?todayDates=" + today;
|
return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/transaction/update")
|
@GetMapping("/transaction/update")
|
||||||
public String updateOneGet(@ModelAttribute TransactionForm transactionForm) {
|
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
|
||||||
|
Model model) {
|
||||||
|
|
||||||
|
if (today == null) {
|
||||||
|
today = LocalDate.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
||||||
|
|
||||||
|
TransactionForm transactionForm = TransactionForm.convertFrom(
|
||||||
|
transactionService.findByTransactionId(transactionId),
|
||||||
|
CategoryForm.convertFrom(categoryService.findByTransactionId(transactionId)).getCategoryName(),
|
||||||
|
transactionService.findMoneyRecord(transactionId),
|
||||||
|
transactionService.findMoneyRecord(transactionId),
|
||||||
|
CategoryForm.convertFrom(categoryService.findByTransactionId(transactionId)).getTransactionType());
|
||||||
|
|
||||||
|
System.out.println("category: " + transactionForm.getCategoryId() + "金額: " + transactionForm.getAmount());
|
||||||
|
|
||||||
|
|
||||||
|
model.addAttribute("transactionId", transactionId);
|
||||||
|
|
||||||
|
model.addAttribute("transactionForm", transactionForm);
|
||||||
|
|
||||||
|
model.addAttribute("categoryFormList", categoryFormList);
|
||||||
|
|
||||||
|
model.addAttribute("today", today);
|
||||||
|
|
||||||
|
return "transaction_update";
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/transaction/update")
|
@PostMapping("/transaction/update")
|
||||||
public String updateOnePost(@ModelAttribute TransactionForm transactionForm, Model model) {
|
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
transactionForm.setUserId(loginUser.getUserId());
|
||||||
|
transactionForm.setTransactionId(transactionId);
|
||||||
|
|
||||||
if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/transaction/delete")
|
@PostMapping("/transaction/delete")
|
||||||
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
|
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
|
||||||
|
|
||||||
transactionService.deleteTransaction(transactionId);
|
transactionService.deleteTransaction(transactionId);
|
||||||
return "redirect:/transaction/detail?todayDates=" + today;
|
return "redirect:/transaction/detail?todayDates=" + today;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/menu")
|
@GetMapping("/menu")
|
||||||
public String menu(HttpSession session, Model model, @RequestParam(required = false, defaultValue = "0") String years, @RequestParam(required = false, defaultValue = "0") String months) {
|
public String menu(HttpSession session, Model model,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") String years,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") String months) {
|
||||||
|
|
||||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
|
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
|
||||||
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
|
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
|
||||||
|
|
||||||
System.out.println("year : " + year + "month : " + month);
|
System.out.println("year : " + year + "month : " + month);
|
||||||
|
|
||||||
YearMonth yearMonth = YearMonth.of(year, month);
|
|
||||||
|
|
||||||
int lastDay = yearMonth.lengthOfMonth();
|
|
||||||
|
|
||||||
int firstDayOfWeek =
|
YearMonth yearMonth = YearMonth.of(year, month);
|
||||||
yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
|
||||||
|
|
||||||
model.addAttribute("year", year);
|
int lastDay = yearMonth.lengthOfMonth();
|
||||||
model.addAttribute("month", month);
|
|
||||||
model.addAttribute("day", today.getDayOfMonth());
|
|
||||||
|
|
||||||
model.addAttribute("lastDay", lastDay);
|
int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
||||||
model.addAttribute("firstDayOfWeek", firstDayOfWeek);
|
|
||||||
|
|
||||||
LocalDate startDate = LocalDate.now().withDayOfMonth(1);
|
model.addAttribute("year", year);
|
||||||
|
model.addAttribute("month", month);
|
||||||
|
model.addAttribute("day", today.getDayOfMonth());
|
||||||
|
|
||||||
|
model.addAttribute("lastDay", lastDay);
|
||||||
|
model.addAttribute("firstDayOfWeek", firstDayOfWeek);
|
||||||
|
|
||||||
|
LocalDate startDate = LocalDate.now().withDayOfMonth(1);
|
||||||
|
|
||||||
LocalDate endDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
|
LocalDate endDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
|
||||||
|
|
||||||
|
|
||||||
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
|
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
|
||||||
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
|
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
|
||||||
|
|
||||||
model.addAttribute("incomeList", incomeList);
|
model.addAttribute("incomeList", incomeList);
|
||||||
|
|
||||||
model.addAttribute("expenseList", expenseList);
|
model.addAttribute("expenseList", expenseList);
|
||||||
|
|
||||||
|
|
||||||
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
|
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
|
||||||
|
|
||||||
int totalExpense= transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
|
int totalExpense = transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
|
||||||
|
|
||||||
model.addAttribute("totalIncome", totalIncome);
|
model.addAttribute("totalIncome", totalIncome);
|
||||||
model.addAttribute("totalExpense", totalExpense);
|
model.addAttribute("totalExpense", totalExpense);
|
||||||
|
|
||||||
|
return "menu";
|
||||||
return "menu";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GoalForm {
|
||||||
|
|
||||||
|
private Long goalId;
|
||||||
|
|
||||||
|
private String goalTitle;
|
||||||
|
|
||||||
|
private String goalSubtitle;
|
||||||
|
|
||||||
|
private Integer targetAmount;
|
||||||
|
|
||||||
|
private LocalDate deadline;
|
||||||
|
|
||||||
|
private Integer goalComplete;
|
||||||
|
|
||||||
|
public static GoalForm convertFrom(GoalModel goalModel) {
|
||||||
|
return new GoalForm(
|
||||||
|
goalModel.getGoalId(),
|
||||||
|
goalModel.getGoalTitle(),
|
||||||
|
goalModel.getGoalSubtitle(),
|
||||||
|
goalModel.getTargetAmount(),
|
||||||
|
goalModel.getDeadline(),
|
||||||
|
goalModel.getGoalComplete());
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static List<GoalForm> convertFrom(List<GoalModel> goalModelList) {
|
||||||
|
// return goalModelList.stream().map(GoalForm::convertFrom).toList();
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,15 +1,80 @@
|
|||||||
table, th, td {border: 1px solid black; border-collapse: collapse;}
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
td:hover{background-color: lightblue;}
|
#calendar {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
th{font-weight: bold; height: 50px;}
|
#calendar th,
|
||||||
|
#calendar td {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
td{text-align: left; vertical-align: text-top; width: 200px; height: 100px; padding: 10px}
|
th {
|
||||||
|
font-weight: bold;
|
||||||
|
height: 35px;
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.holiday{color: red;}
|
td {
|
||||||
|
width: 14.28%;
|
||||||
|
height: 70px;
|
||||||
|
padding: 5px;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
#today{font-weight: bold; background-color: bisque;}
|
td:hover {
|
||||||
|
background-color: lightblue;
|
||||||
|
}
|
||||||
|
|
||||||
.year{font-size: 30px;}
|
.holiday {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
.month{font-size: 50px; font-weight: bold;}
|
#today {
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: bisque;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.month {
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-title {
|
||||||
|
margin: 15px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.income {
|
||||||
|
color: blue;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expense {
|
||||||
|
color: red;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.total {
|
||||||
|
margin: 15px 10px;
|
||||||
|
padding: 10px;
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
|
||||||
|
font-size: 16px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|||||||
15
src/main/resources/static/css/transaction_detail.css
Normal file
15
src/main/resources/static/css/transaction_detail.css
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
.transaction-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transaction-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transaction-buttons form {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
@@ -5,11 +5,12 @@
|
|||||||
<title>分析画面</title>
|
<title>分析画面</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
<div th:replace="~{header :: header}">
|
<div th:replace="~{header :: header}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
<h2 class="text-center">支出分析</h2>
|
<h2 class="text-center">支出分析</h2>
|
||||||
|
|
||||||
<table class="table text-center">
|
<table class="table text-center">
|
||||||
@@ -81,6 +82,8 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div th:replace="~{footer :: footer}">
|
<div th:replace="~{footer :: footer}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
38
src/main/resources/templates/goal_edit.html
Normal file
38
src/main/resources/templates/goal_edit.html
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>目標編集</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>目標編集</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/goal/update}" th:object="${goalForm}" method="post">
|
||||||
|
<input type="hidden" th:field="*{goalId}">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標名</label>
|
||||||
|
<input type="text" th:field="*{goalTitle}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標説明</label>
|
||||||
|
<textarea th:field="*{goalSubtitle}"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標金額</label>
|
||||||
|
<input type="number" th:field="*{targetAmount}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標達成期限</label>
|
||||||
|
<input type="date" th:field="*{deadline}">
|
||||||
|
</div>
|
||||||
|
<button type="submit">更新する</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
35
src/main/resources/templates/goal_view.html
Normal file
35
src/main/resources/templates/goal_view.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>目標詳細</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>目標詳細</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>目標名</th>
|
||||||
|
<td th:text="${goalForm.goalTitle}"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>目標説明</th>
|
||||||
|
<td th:text="${goalForm.goalSubtitle}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>目標金額</th>
|
||||||
|
<td th:text="${goalForm.targetAmount}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>目標達成期限</th>
|
||||||
|
<td th:text="${goalForm.deadline}"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<a th:href="@{/goal/edit}">編集する</a>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<header th:fragment="header">
|
<header th:fragment="header" class="fixed-top">
|
||||||
|
|
||||||
<nav class="navbar" style="background-color: #e3f2fd;" data-bs-theme="light">
|
<nav class="navbar" style="background-color: #e3f2fd;" data-bs-theme="light">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
|||||||
@@ -2,71 +2,107 @@
|
|||||||
<html xmlns:th="http://www.thymeleaf.org">
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Calendar</title>
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" th:href="@{/css/menu.css}">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<title>Calendar</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" th:href="@{/css/menu.css}">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<span class="year" th:text="|${year}年|"></span>
|
<div th:replace="~{header :: header}"></div>
|
||||||
<span class="month" th:text="|${month}月|"></span>
|
|
||||||
|
|
||||||
<table id="calendar">
|
|
||||||
|
|
||||||
<thead>
|
<div class="calendar-title">
|
||||||
<tr>
|
|
||||||
<th class="holiday">日</th>
|
|
||||||
<th>月</th>
|
|
||||||
<th>火</th>
|
|
||||||
<th>水</th>
|
|
||||||
<th>木</th>
|
|
||||||
<th>金</th>
|
|
||||||
<th>土</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
<span class="year" th:text="|${year}年|">
|
||||||
|
</span>
|
||||||
|
|
||||||
<tr th:each="week : ${#numbers.sequence(0, 5)}">
|
<span class="month" th:text="|${month}月|">
|
||||||
|
</span>
|
||||||
|
|
||||||
<td th:each="weekDay : ${#numbers.sequence(0, 6)}">
|
</div>
|
||||||
|
|
||||||
<div th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1 and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}">
|
|
||||||
|
|
||||||
<div class="date" th:text="${week * 7 + weekDay - firstDayOfWeek + 1}">
|
<table id="calendar">
|
||||||
</div>
|
|
||||||
|
|
||||||
<div th:each="income : ${incomeList}"
|
<thead>
|
||||||
th:if="${income.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}"
|
|
||||||
class="income"
|
|
||||||
th:text="|収入 +${income.amount}円|"
|
|
||||||
style="color: blue;">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div th:each="expense : ${expenseList}"
|
<tr>
|
||||||
th:if="${expense.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}"
|
<th class="holiday">日</th>
|
||||||
class="expense"
|
<th>月</th>
|
||||||
th:text="|支出 -${expense.amount}円|"
|
<th>火</th>
|
||||||
style="color: red;">
|
<th>水</th>
|
||||||
</div>
|
<th>木</th>
|
||||||
|
<th>金</th>
|
||||||
|
<th>土</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</div>
|
</thead>
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
<tbody>
|
||||||
|
|
||||||
</tbody>
|
<tr th:each="week : ${#numbers.sequence(0, 5)}">
|
||||||
</table>
|
|
||||||
|
|
||||||
<div>
|
<td th:each="weekDay : ${#numbers.sequence(0, 6)}">
|
||||||
<h2>
|
|
||||||
<span th:text="|収入:${totalIncome}|"></span>
|
<a th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1
|
||||||
<span th:text="|支出:${totalExpense}|"></span>
|
and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}"
|
||||||
</h2>
|
th:href="@{/transaction/detail(
|
||||||
</div>
|
todayDates=${T(java.time.LocalDate).of(year, month, week * 7 + weekDay - firstDayOfWeek + 1)}
|
||||||
|
)}">
|
||||||
|
|
||||||
|
|
||||||
|
<div th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1 and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}">
|
||||||
|
|
||||||
|
<div class="date" th:text="${week * 7 + weekDay - firstDayOfWeek + 1}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div th:each="income : ${incomeList}" th:if="${income.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}" class="income" th:text="|収入 +${income.amount}円|">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div th:each="expense : ${expenseList}" th:if="${expense.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}" class="expense" th:text="|支出 -${expense.amount}円|">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="total">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>収入:</span>
|
||||||
|
<span th:text="${totalIncome}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>支出:</span>
|
||||||
|
<span th:text="${totalExpense}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -2,25 +2,41 @@
|
|||||||
<html xmlns:th="http://www.thymeleaf.org">
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<title>コース選択</title>
|
<title>コース選択</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<h1>コース選択</h1>
|
||||||
|
<form th:action="@{/user/register}" th:object="${userForm}" method="post">
|
||||||
|
<input type="hidden" th:field="*{userName}">
|
||||||
|
<input type="hidden" th:field="*{mailAddress}">
|
||||||
|
<input type="hidden" th:field="*{birthDate}">
|
||||||
|
<input type="hidden" th:field="*{password}">
|
||||||
|
<input type="hidden" th:field="*{secretQuestionId}">
|
||||||
|
<input type="hidden" th:field="*{secretAnswer}">
|
||||||
|
<input type="hidden" th:field="*{saving}">
|
||||||
|
<input type="hidden" th:field="*{annualIncome}">
|
||||||
|
<input type="hidden" th:field="*{monthlyBudget}">
|
||||||
|
<input type="hidden" th:field="*{targetAmount}">
|
||||||
|
<button type="submit">確定</button>
|
||||||
<div class="accordion" id="accordionExample">
|
<div class="accordion" id="accordionExample">
|
||||||
<div class="accordion-item" th:each="course:${courseList}">
|
<div class="accordion-item" th:each="course:${courseList}">
|
||||||
<h2 class="accordion-header">
|
<h2 class="accordion-header d-flex align-items-center">
|
||||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
<input type="radio" name="courseId" th:value="${course.courseId}" class="form-check-input ms-3 me-2">
|
||||||
<span th:text="${course.courseName}"></span>
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" th:data-bs-target="'#collapse' + ${course.courseId}" aria-expanded="false" aria-controls="'collapse' + ${course.courseId}">
|
||||||
|
<span th:text="${course.courseName}"></span>
|
||||||
</button>
|
</button>
|
||||||
</h2>
|
</h2>
|
||||||
<div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#accordionExample">
|
<div th:id="'collapse' + ${course.courseId}" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
|
||||||
<div class="accordion-body">
|
<div class="accordion-body">
|
||||||
<span th:text="${course.description}"></span>
|
<span th:text="${course.description}"></span>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<tr>
|
<tr>
|
||||||
<th>カテゴリ名</th><tr>配分(%)</tr>
|
<th>カテゴリ名</th><th>配分(%)</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:each="courseInfo:${courseInfoList}" th:if="course.courseId == courseInfo.courseId">
|
<tr th:each="courseInfo:${courseInfoList}" th:if="${course.courseId == courseInfo.courseId}">
|
||||||
<td th:text="${courseInfo.categoryName}"></td>
|
<td th:text="${courseInfo.categoryName}"></td>
|
||||||
<td th:text="${courseInfo.allocationRatio}"></td>
|
<td th:text="${courseInfo.allocationRatio}"></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -29,7 +45,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -4,16 +4,22 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Insert title here</title>
|
<title>Insert title here</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/css/menu.css}">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
|
|
||||||
<h1>取引登録</h1>
|
<h1>取引登録</h1>
|
||||||
|
|
||||||
<form th:action="@{/transaction/create}" th:object="${transactionForm}" method="post">
|
<form th:action="@{/transaction/create}" th:object="${transactionForm}" method="post">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="transactionDate">日付</label>
|
<label for="transactionDate">日付</label>
|
||||||
<input type="date" id="transactionDate" th:field="*{transactionDate}">
|
<input type="date" id="transactionDate" name="transactionDate" th:value="*{transactionDate}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@@ -61,6 +67,7 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -4,35 +4,60 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>収支詳細</title>
|
<title>収支詳細</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/css/transaction_detail.css}">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
<h1 th:text="${today}"></h1>
|
<h1 th:text="${today}"></h1>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
<li th:each="transactionForm : ${transactionFormList}">
|
<li th:each="transactionForm : ${transactionFormList}" class="transaction-item">
|
||||||
<p>カテゴリ名:<span th:text="${transactionForm.categoryName}"></span>
|
|
||||||
<br>金額:<span th:text="${transactionForm.amount}"></span>
|
|
||||||
</p>
|
|
||||||
<form th:action="@{/transaction/delete}" method="post">
|
|
||||||
<input type="hidden" name="today" id="today" th:value="${today}">
|
|
||||||
<input type="hidden" name="transactionId" id="transactionId" value="${transactionForm.transactionId}">
|
|
||||||
|
|
||||||
<button type="submit">削除</button>
|
<div>
|
||||||
</form>
|
<p>
|
||||||
<hr />
|
カテゴリ名:
|
||||||
|
<span th:text="${transactionForm.categoryName}"></span>
|
||||||
|
<br>
|
||||||
|
金額:
|
||||||
|
<span th:text="${transactionForm.amount}"></span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="transaction-buttons">
|
||||||
|
|
||||||
|
<form th:action="@{/transaction/delete}" method="post">
|
||||||
|
<input type="hidden" name="today" th:value="${today}">
|
||||||
|
<input type="hidden" name="transactionId" th:value="${transactionForm.transactionId}">
|
||||||
|
<button type="submit">削除</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form th:action="@{/transaction/update}" method="get">
|
||||||
|
<input type="hidden" name="today" th:value="${today}">
|
||||||
|
<input type="hidden" name="transactionId" th:value="${transactionForm.transactionId}">
|
||||||
|
<button type="submit">編集</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<hr>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form th:action="@{/transaction/create}" method="get">
|
<form th:action="@{/transaction/create}" method="get">
|
||||||
<input type="hidden" name="today" id="today" th:value="${today}">
|
<input type="hidden" name="today" id="today" th:value="${today}">
|
||||||
|
|
||||||
<button type="submit">新規登録</button>
|
<button type="submit">新規登録</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -4,10 +4,15 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>一覧</title>
|
<title>一覧</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/css/menu.css}">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
|
|
||||||
<div th:each="transactionForm : ${transactionFormMap}">
|
<div th:each="transactionForm : ${transactionFormMap}">
|
||||||
|
|
||||||
<a th:href="@{/transaction/detail(todayDates=${transactionForm.key})}">
|
<a th:href="@{/transaction/detail(todayDates=${transactionForm.key})}">
|
||||||
@@ -23,6 +28,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
76
src/main/resources/templates/transaction_update.html
Normal file
76
src/main/resources/templates/transaction_update.html
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/css/menu.css}">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
|
|
||||||
|
<h1>取引登録</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/transaction/update}" th:object="${transactionForm}" method="post">
|
||||||
|
|
||||||
|
<input type="hidden" name="transactionId" th:value="${transactionId}">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="transactionDate">日付</label>
|
||||||
|
<input type="date" id="transactionDate" name="transactionDate" th:value="*{transactionDate}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="transactionType">収入・支出</label>
|
||||||
|
|
||||||
|
<select id="transactionType" th:field="*{transactionType}">
|
||||||
|
|
||||||
|
<option value="">選択してください</option>
|
||||||
|
<option value="0">支出</option>
|
||||||
|
<option value="1">収入</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="categoryId">カテゴリ</label>
|
||||||
|
|
||||||
|
<select id="categoryId" th:field="*{categoryId}">
|
||||||
|
|
||||||
|
<option value="">選択してください</option>
|
||||||
|
|
||||||
|
<option th:each="category : ${categoryFormList}" th:value="${category.categoryId}"
|
||||||
|
th:text="${category.categoryName}">
|
||||||
|
</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="amount">金額</label>
|
||||||
|
|
||||||
|
<input type="number" id="amount" th:field="*{amount}" min="0" placeholder="金額を入力してください">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<input type="hidden" name="today" id="today" th:value="${today}">
|
||||||
|
|
||||||
|
<button type="submit">登録</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user