Compare commits
1 Commits
952c6f69d8
...
s-kikuchi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f9287765d |
0
kikuchi.txt
Normal file
0
kikuchi.txt
Normal file
@@ -1,14 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class AllocationModel {
|
||||
|
||||
private Long categoryId;
|
||||
private Long courseId;
|
||||
private Integer allocationRatio;
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class AnalysisModel {
|
||||
|
||||
private Integer currentMonthTotalAmount;
|
||||
|
||||
private Integer previousMonthTotalAmount;
|
||||
|
||||
private Integer totalDifferenceAmount;
|
||||
|
||||
private List<CategoryAnalysisModel>
|
||||
categoryAnalysisModelList;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class AuthenticationModel {
|
||||
private Long userId;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class CategoryAnalysisModel {
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private Integer currentMonthAmount;
|
||||
|
||||
private Integer previousMonthAmount;
|
||||
|
||||
private Integer monthDifferenceAmount;
|
||||
|
||||
private Integer courseLimitAmount;
|
||||
|
||||
private Integer courseDifferenceAmount;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.infra.entity.CategoryEntity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class CategoryModel {
|
||||
|
||||
private Long categoryId;
|
||||
private String categoryName;
|
||||
private Integer transactionType;
|
||||
|
||||
|
||||
public static CategoryModel convertFrom(CategoryEntity categoryEntity) {
|
||||
return new CategoryModel(
|
||||
categoryEntity.getCategoryId(),
|
||||
categoryEntity.getCategoryName(),
|
||||
categoryEntity.getTransactionType());
|
||||
}
|
||||
|
||||
public static List<CategoryModel> convertFrom(List<CategoryEntity> categoryEntityList) {
|
||||
return categoryEntityList.stream().map(CategoryModel::convertFrom).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class CourseInfoModel {
|
||||
|
||||
private Long courseId;
|
||||
|
||||
private String courseName;
|
||||
|
||||
private Long categoryId;
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private Integer allocationRatio;
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.infra.entity.CourseEntity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class CourseModel {
|
||||
|
||||
private Long courseId;
|
||||
private String courseName;
|
||||
private String description;
|
||||
|
||||
public static CourseModel convertFrom(CourseEntity courseEntity) {
|
||||
return new CourseModel(
|
||||
courseEntity.getCourseId(),
|
||||
courseEntity.getCourseName(),
|
||||
courseEntity.getDescription());
|
||||
}
|
||||
|
||||
public static List<CourseModel> convertFrom(List<CourseEntity> courseEntityList) {
|
||||
return courseEntityList.stream().map(CourseModel::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class GoalModel {
|
||||
|
||||
private Long goalId;
|
||||
|
||||
private String goalTitle;
|
||||
|
||||
private String goalSubtitle;
|
||||
|
||||
private Integer targetAmount;
|
||||
|
||||
private LocalDate deadline;
|
||||
|
||||
private Integer goalComplete;
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class LoginModel {
|
||||
private Long userId;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.infra.entity.CategoryEntity;
|
||||
import com.example.demo.app.infra.entity.TransactionEntity;
|
||||
import com.example.demo.app.infra.entity.UserEntity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class TransactionModel {
|
||||
|
||||
private Long transactionId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long categoryId;
|
||||
|
||||
private Integer amount;
|
||||
|
||||
private LocalDate transactionDate;
|
||||
|
||||
public static TransactionModel convertFrom(TransactionEntity transactionEntity) {
|
||||
return new TransactionModel(
|
||||
transactionEntity.getTransactionId(),
|
||||
transactionEntity.getUserEntity().getUserId(),
|
||||
transactionEntity.getCategoryEntity().getCategoryId(),
|
||||
transactionEntity.getAmount(),
|
||||
transactionEntity.getTransactionDate());
|
||||
}
|
||||
|
||||
public static List<TransactionModel> convertFrom(List<TransactionEntity> transactionEntityList) {
|
||||
return transactionEntityList.stream().map(TransactionModel::convertFrom).toList();
|
||||
}
|
||||
|
||||
public static TransactionEntity convertTo(TransactionModel transactionModel, UserEntity userEntity, CategoryEntity categoryEntity) {
|
||||
return new TransactionEntity(
|
||||
transactionModel.getTransactionId(),
|
||||
userEntity,
|
||||
categoryEntity,
|
||||
transactionModel.getAmount(),
|
||||
transactionModel.getTransactionDate());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.example.demo.app.domain.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class UserModel {
|
||||
private Long userId;
|
||||
private String userName;
|
||||
private String mailAddress;
|
||||
private String password;
|
||||
private Integer secretQuestionId;
|
||||
private String secretAnswer;
|
||||
private LocalDate brithDate;
|
||||
private Integer saving;
|
||||
private Integer annualIncome;
|
||||
private Integer monthlyBudget;
|
||||
private Long goalId;
|
||||
private Long courseId;
|
||||
private Integer deleteFlag;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.AllocationModel;
|
||||
|
||||
public interface AllocationService {
|
||||
|
||||
public List<AllocationModel> findAll();
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import com.example.demo.app.domain.model.AnalysisModel;
|
||||
|
||||
public interface AnalysisService {
|
||||
|
||||
AnalysisModel getAnalysis(Long userId);
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||
|
||||
public interface AuthenticationService {
|
||||
|
||||
AuthenticationModel authenticate(AuthenticationForm authenticationForm);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.CategoryModel;
|
||||
|
||||
public interface CategoryService {
|
||||
|
||||
public List<CategoryModel> findAll();
|
||||
|
||||
public CategoryModel findOne(Long categoryId);
|
||||
|
||||
public CategoryModel findOneByCategoryName(String categoryName);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseInfoModel;
|
||||
|
||||
public interface CourseInfoService {
|
||||
//
|
||||
public List<CourseInfoModel> findAll();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseModel;
|
||||
|
||||
public interface CourseService {
|
||||
//
|
||||
public List<CourseModel> findAll();
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import com.example.demo.app.domain.model.LoginModel;
|
||||
|
||||
public interface LoginService {
|
||||
|
||||
LoginModel login(String mailAddress, String password);
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.example.demo.app.domain.service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.example.demo.app.domain.model.TransactionModel;
|
||||
import com.example.demo.app.presentation.form.Expense;
|
||||
import com.example.demo.app.presentation.form.Income;
|
||||
|
||||
public interface TransactionService {
|
||||
|
||||
public Map<LocalDate, List<TransactionModel>> findAllByDate(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
public List<TransactionModel> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
||||
|
||||
public int findTotalIncome(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
public int findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
public int createTransaction(TransactionModel transactionModel);
|
||||
|
||||
public int updateTransaction(TransactionModel transactionModel);
|
||||
|
||||
public void deleteTransaction(Long transactionId);
|
||||
|
||||
public List<Income> findTotalIncomeList(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
public List<Expense> findTotalExpenseList(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.model.AllocationModel;
|
||||
import com.example.demo.app.domain.service.AllocationService;
|
||||
import com.example.demo.app.infra.entity.AllocationEntity;
|
||||
import com.example.demo.app.infra.repository.AllocationRepository;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AllocationServiceImpl implements AllocationService {
|
||||
|
||||
AllocationRepository allocationRepository;
|
||||
|
||||
public List<AllocationModel> findAll(){
|
||||
return AllocationEntity.createAllocationModelList(allocationRepository.findAll());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.model.AnalysisModel;
|
||||
import com.example.demo.app.domain.model.CategoryAnalysisModel;
|
||||
import com.example.demo.app.domain.service.AnalysisService;
|
||||
import com.example.demo.app.infra.entity.AllocationEntity;
|
||||
import com.example.demo.app.infra.entity.CategoryEntity;
|
||||
import com.example.demo.app.infra.entity.UserEntity;
|
||||
import com.example.demo.app.infra.repository.AllocationRepository;
|
||||
import com.example.demo.app.infra.repository.CategoryRepository;
|
||||
import com.example.demo.app.infra.repository.TransactionRepository;
|
||||
import com.example.demo.app.infra.repository.UserRepository;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AnalysisServiceImpl implements AnalysisService {
|
||||
|
||||
//Repositoryの呼び出し
|
||||
private final TransactionRepository transactionRepository;
|
||||
private final AllocationRepository allocationRepository;
|
||||
private final UserRepository userRepository;
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
||||
@Override
|
||||
public AnalysisModel getAnalysis(Long userId) {
|
||||
|
||||
// ユーザー情報取得、月別使用可能資金取得
|
||||
UserEntity userEntity = userRepository.findById(userId).orElseThrow(() ->
|
||||
new RuntimeException(
|
||||
"User not found."));
|
||||
|
||||
// コースID取得
|
||||
Long courseId = userEntity.getCourseEntity().getCourseId();
|
||||
|
||||
// 月別使用可能資金取得
|
||||
Integer monthlyBudget =userEntity.getMonthlyBudget();
|
||||
|
||||
// 今月の期間取得
|
||||
LocalDate currentMonthStartDate = LocalDate.now().withDayOfMonth(1);
|
||||
LocalDate currentMonthEndDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
|
||||
|
||||
// 前月の期間取得
|
||||
LocalDate previousMonthStartDate = LocalDate.now().minusMonths(1).withDayOfMonth(1);
|
||||
LocalDate previousMonthEndDate = LocalDate.now().minusMonths(1).withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth());
|
||||
|
||||
// 今月の支出取得
|
||||
Integer currentMonthTotalAmount = transactionRepository.findTotalExpense(currentMonthStartDate, currentMonthEndDate, userId);
|
||||
|
||||
if (currentMonthTotalAmount == null) {
|
||||
currentMonthTotalAmount = 0;
|
||||
}
|
||||
|
||||
// 前月の支出取得
|
||||
Integer previousMonthTotalAmount = transactionRepository.findTotalExpense(previousMonthStartDate, previousMonthEndDate, userId);
|
||||
|
||||
if (previousMonthTotalAmount == null) {
|
||||
previousMonthTotalAmount = 0;
|
||||
}
|
||||
|
||||
//総支出差額算出
|
||||
Integer totalDifferenceAmount = currentMonthTotalAmount - previousMonthTotalAmount;
|
||||
|
||||
//カテゴリ一覧取得
|
||||
List<CategoryAnalysisModel> categoryAnalysisModelList = new ArrayList<>();
|
||||
List<CategoryEntity> categoryEntityList = categoryRepository.findAll();
|
||||
List<AllocationEntity> allocationEntityList = allocationRepository.findByCourseEntity_CourseId(courseId);
|
||||
|
||||
//取得ループ
|
||||
for (CategoryEntity categoryEntity : categoryEntityList) {
|
||||
|
||||
if (categoryEntity.getTransactionType() != 0) {
|
||||
continue;
|
||||
}
|
||||
// カテゴリ別今月金額取得
|
||||
Integer currentMonthAmount =
|
||||
transactionRepository.findCategoryExpense(currentMonthStartDate,
|
||||
currentMonthEndDate,
|
||||
userId,
|
||||
categoryEntity.getCategoryId());
|
||||
|
||||
// カテゴリ別前月金額取得
|
||||
Integer previousMonthAmount =
|
||||
transactionRepository.findCategoryExpense(previousMonthStartDate,
|
||||
previousMonthEndDate,
|
||||
userId,
|
||||
categoryEntity.getCategoryId());
|
||||
|
||||
if (currentMonthAmount == null) {
|
||||
currentMonthAmount = 0;
|
||||
}
|
||||
|
||||
if (previousMonthAmount == null) {
|
||||
previousMonthAmount = 0;
|
||||
}
|
||||
|
||||
// カテゴリ別前月差額算出
|
||||
Integer monthDifferenceAmount = currentMonthAmount - previousMonthAmount;
|
||||
|
||||
// コース配分取得
|
||||
AllocationEntity allocationEntity = allocationEntityList.stream().filter(allocation ->
|
||||
allocation.getCategoryEntity()
|
||||
.getCategoryId()
|
||||
.equals(categoryEntity.getCategoryId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
Integer allocationRatio = 0;
|
||||
|
||||
if (allocationEntity != null) {
|
||||
allocationRatio =
|
||||
allocationEntity.getAllocationRatio();
|
||||
}
|
||||
|
||||
// コース限度額算出
|
||||
Integer courseLimitAmount = monthlyBudget * allocationRatio / 100;
|
||||
|
||||
// コース差額算出
|
||||
Integer courseDifferenceAmount = currentMonthAmount - courseLimitAmount;
|
||||
|
||||
// CategoryAnalysisModel生成
|
||||
CategoryAnalysisModel categoryAnalysisModel = new CategoryAnalysisModel(
|
||||
categoryEntity.getCategoryName(),
|
||||
currentMonthAmount,
|
||||
previousMonthAmount,
|
||||
monthDifferenceAmount,
|
||||
courseLimitAmount,
|
||||
courseDifferenceAmount);
|
||||
|
||||
categoryAnalysisModelList.add(categoryAnalysisModel);
|
||||
}
|
||||
|
||||
// AnalysisModelの生成
|
||||
return new AnalysisModel(currentMonthTotalAmount, previousMonthTotalAmount, totalDifferenceAmount, categoryAnalysisModelList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||
import com.example.demo.app.domain.service.AuthenticationService;
|
||||
import com.example.demo.app.infra.entity.UserEntity;
|
||||
import com.example.demo.app.infra.repository.UserRepository;
|
||||
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public AuthenticationModel authenticate(AuthenticationForm authenticationForm) {
|
||||
|
||||
UserEntity userEntity = userRepository.findByMailAddress(
|
||||
authenticationForm.getMailAddress())
|
||||
.orElse(null);
|
||||
|
||||
if (userEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!userEntity.getQuestionEntity().getSecretQuestionId()
|
||||
.equals(authenticationForm.getSecretQuestionId())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!userEntity.getSecretQuestionAnswer()
|
||||
.equals(authenticationForm.getSecretAnswer())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new AuthenticationModel(userEntity.getUserId());
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.model.CategoryModel;
|
||||
import com.example.demo.app.domain.service.CategoryService;
|
||||
import com.example.demo.app.infra.entity.CategoryEntity;
|
||||
import com.example.demo.app.infra.repository.CategoryRepository;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CategoryServiceImpl implements CategoryService {
|
||||
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
||||
public List<CategoryModel> findAll() {
|
||||
|
||||
return CategoryModel.convertFrom(categoryRepository.findAll());
|
||||
|
||||
}
|
||||
|
||||
public CategoryModel findOne(Long categoryId) {
|
||||
|
||||
Optional<CategoryEntity> optionalCategoryModel = categoryRepository.findById(categoryId);
|
||||
|
||||
if (optionalCategoryModel.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CategoryModel.convertFrom(optionalCategoryModel.get());
|
||||
|
||||
}
|
||||
|
||||
public CategoryModel findOneByCategoryName(String categoryName) {
|
||||
|
||||
CategoryEntity categoryModel = categoryRepository.findByCategoryName(categoryName);
|
||||
|
||||
if (categoryModel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CategoryModel.convertFrom(categoryModel);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseModel;
|
||||
import com.example.demo.app.domain.service.CourseService;
|
||||
import com.example.demo.app.infra.entity.CourseEntity;
|
||||
import com.example.demo.app.infra.repository.CourseRepository;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CourseServiceImpl implements CourseService {
|
||||
|
||||
private final CourseRepository courseRepository;
|
||||
|
||||
public List<CourseModel> findAll(){
|
||||
|
||||
return CourseEntity.createCourseModelList(courseRepository.findAll());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.model.LoginModel;
|
||||
import com.example.demo.app.domain.service.LoginService;
|
||||
import com.example.demo.app.infra.entity.UserEntity;
|
||||
import com.example.demo.app.infra.repository.UserRepository;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public LoginModel login(String mailAddress, String password) {
|
||||
|
||||
UserEntity userEntity = userRepository.findByMailAddressAndPassword(
|
||||
mailAddress,
|
||||
password).orElse(null);
|
||||
|
||||
if (userEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new LoginModel(userEntity.getUserId());
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
package com.example.demo.app.domain.service.impl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.app.domain.model.TransactionModel;
|
||||
import com.example.demo.app.domain.service.TransactionService;
|
||||
import com.example.demo.app.infra.entity.CategoryEntity;
|
||||
import com.example.demo.app.infra.entity.TransactionEntity;
|
||||
import com.example.demo.app.infra.entity.UserEntity;
|
||||
import com.example.demo.app.infra.repository.CategoryRepository;
|
||||
import com.example.demo.app.infra.repository.TransactionRepository;
|
||||
import com.example.demo.app.infra.repository.UserRepository;
|
||||
import com.example.demo.app.presentation.form.Expense;
|
||||
import com.example.demo.app.presentation.form.Income;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TransactionServiceImpl implements TransactionService {
|
||||
|
||||
private final TransactionRepository transactionRepository;
|
||||
private final UserRepository userRepository;
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
||||
public Map<LocalDate, List<TransactionModel>> findAllByDate(
|
||||
LocalDate startDate,
|
||||
LocalDate endDate,
|
||||
Long userId) {
|
||||
|
||||
System.out.println("========== findAllByDate ==========");
|
||||
System.out.println("startDate = " + startDate);
|
||||
System.out.println("endDate = " + endDate);
|
||||
System.out.println("userId = " + userId);
|
||||
|
||||
List<TransactionEntity> transactionEntityList = transactionRepository.findAllByDateAndUserId(startDate, endDate,
|
||||
userId);
|
||||
|
||||
System.out.println("Entity count = " + transactionEntityList.size());
|
||||
|
||||
transactionEntityList.forEach(t -> {
|
||||
System.out.println(
|
||||
"date = " + t.getTransactionDate()
|
||||
+ ", amount = " + t.getAmount());
|
||||
});
|
||||
|
||||
List<TransactionModel> transactionModelList = TransactionModel.convertFrom(transactionEntityList);
|
||||
|
||||
System.out.println("Model count = " + transactionModelList.size());
|
||||
|
||||
Map<LocalDate, List<TransactionModel>> transactionModelMap = transactionModelList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TransactionModel::getTransactionDate));
|
||||
|
||||
System.out.println("Map = " + transactionModelMap);
|
||||
|
||||
return transactionModelMap;
|
||||
}
|
||||
|
||||
public int findTotalIncome(LocalDate startDate, LocalDate endDate, Long userId) {
|
||||
|
||||
return transactionRepository.findTotalIncome(startDate, endDate, userId);
|
||||
|
||||
}
|
||||
|
||||
public int findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId) {
|
||||
|
||||
return transactionRepository.findTotalExpense(startDate, endDate, userId);
|
||||
|
||||
}
|
||||
|
||||
public List<Income> findTotalIncomeList(LocalDate startDate, LocalDate endDate, Long userId) {
|
||||
|
||||
return transactionRepository.findTotalIncomeList(startDate, endDate, userId);
|
||||
|
||||
}
|
||||
|
||||
public List<Expense> findTotalExpenseList(LocalDate startDate, LocalDate endDate, Long userId) {
|
||||
|
||||
return transactionRepository.findTotalExpenseList(startDate, endDate, userId);
|
||||
|
||||
}
|
||||
|
||||
public List<TransactionModel> findByUserIdAndDate(LocalDate todayDate, Long userId) {
|
||||
|
||||
return TransactionModel.convertFrom(transactionRepository.findByUserIdAndDate(todayDate, userId));
|
||||
|
||||
}
|
||||
|
||||
public int createTransaction(TransactionModel transactionModel) {
|
||||
|
||||
Optional<UserEntity> userEntityOptional = userRepository.findById(transactionModel.getUserId());
|
||||
|
||||
if (userEntityOptional.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Optional<CategoryEntity> categoryEntityOptional = categoryRepository.findById(transactionModel.getCategoryId());
|
||||
if (categoryEntityOptional.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
TransactionEntity transactionEntity = TransactionModel.convertTo(
|
||||
transactionModel,
|
||||
userEntityOptional.get(),
|
||||
categoryEntityOptional.get());
|
||||
if (transactionRepository.save(transactionEntity) != null) {
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int updateTransaction(TransactionModel transactionModel) {
|
||||
|
||||
if (!transactionRepository.existsById(transactionModel.getTransactionId())) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Optional<UserEntity> userEntityOptional = userRepository.findById(transactionModel.getUserId());
|
||||
|
||||
if (userEntityOptional.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Optional<CategoryEntity> categoryEntityOptional = categoryRepository.findById(transactionModel.getCategoryId());
|
||||
if (categoryEntityOptional.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
TransactionEntity transactionEntity = TransactionModel.convertTo(
|
||||
transactionModel,
|
||||
userEntityOptional.get(),
|
||||
categoryEntityOptional.get());
|
||||
if (transactionRepository.save(transactionEntity) != null) {
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteTransaction(Long transactionId) {
|
||||
transactionRepository.deleteById(transactionId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.IdClass;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import com.example.demo.app.domain.model.AllocationModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@IdClass(AllocationId.class)
|
||||
@Table(name = "allocation_m")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AllocationEntity {
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "category_id")
|
||||
private CategoryEntity categoryEntity;
|
||||
|
||||
@Id
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "course_id")
|
||||
private CourseEntity courseEntity;
|
||||
|
||||
@Column(name = "allocation_ratio", nullable = false)
|
||||
private Integer allocationRatio;
|
||||
|
||||
|
||||
public static List<AllocationModel> createAllocationModelList(List<AllocationEntity> allocationEntityList) {
|
||||
|
||||
return allocationEntityList
|
||||
.stream()
|
||||
.map(allocationEntity -> new AllocationModel(
|
||||
allocationEntity.getCategoryEntity().getCategoryId(),
|
||||
allocationEntity.getCourseEntity().getCourseId(),
|
||||
allocationEntity.getAllocationRatio()
|
||||
)).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AllocationId implements Serializable {
|
||||
private Long categoryEntity;
|
||||
|
||||
private Long courseEntity;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "category_t")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CategoryEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "category_id")
|
||||
private Long categoryId;
|
||||
|
||||
@Column(name = "category_name", nullable = false)
|
||||
private String categoryName;
|
||||
|
||||
@Column(name = "transaction_type", nullable = false)
|
||||
private Integer transactionType;
|
||||
|
||||
@OneToMany(mappedBy = "categoryEntity")
|
||||
private List<TransactionEntity> transactionEntity;
|
||||
|
||||
@OneToMany(mappedBy = "categoryEntity")
|
||||
private List<AllocationEntity> allocationEntity;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "course_m")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CourseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
|
||||
@Column(name = "course_name", nullable = false)
|
||||
private String courseName;
|
||||
|
||||
|
||||
@Column(name = "description", nullable = false)
|
||||
private String description;
|
||||
|
||||
@OneToMany(mappedBy = "courseEntity")
|
||||
private List<UserEntity> userEntity;
|
||||
|
||||
public static List<CourseModel> createCourseModelList(List<CourseEntity> courseEntityList) {
|
||||
|
||||
return courseEntityList
|
||||
.stream()
|
||||
.map(courseEntity -> new CourseModel(
|
||||
courseEntity.getCourseId(),
|
||||
courseEntity.getCourseName(),
|
||||
courseEntity.getDescription()
|
||||
)).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "goal_t")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GoalEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "goal_id")
|
||||
private Long goalId;
|
||||
|
||||
@Column(name = "goal_title", nullable = true)
|
||||
private String goalTitle;
|
||||
|
||||
@Column(name = "goal_subtitle", nullable = true)
|
||||
private String goalSubtitle;
|
||||
|
||||
@Column(name = "target_amount", nullable = false)
|
||||
private Integer targetAmount;
|
||||
|
||||
@Column(name = "deadline", nullable = false)
|
||||
private LocalDate deadline;
|
||||
|
||||
@Column(name = "goal_complete", nullable = false)
|
||||
private Integer goalComplete;
|
||||
|
||||
@OneToOne(mappedBy = "goalEntity")
|
||||
private UserEntity userEntity;
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "question_m")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QuestionEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "secret_question_id")
|
||||
private Long secretQuestionId;
|
||||
|
||||
@Column(name = "question_text", nullable = false)
|
||||
private String questionText;
|
||||
|
||||
@OneToMany(mappedBy = "questionEntity")
|
||||
private List<UserEntity> userEntity;
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "transaction_t")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TransactionEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "transaction_id")
|
||||
private Long transactionId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "user_id")
|
||||
private UserEntity userEntity;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "category_id")
|
||||
private CategoryEntity categoryEntity;
|
||||
|
||||
@Column(name = "amount", nullable = false)
|
||||
private Integer amount;
|
||||
|
||||
@Column(name = "transaction_date", nullable = false)
|
||||
private LocalDate transactionDate;
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.example.demo.app.infra.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user_t")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "user_id")
|
||||
private Long userId;
|
||||
|
||||
@Column(name = "user_name", nullable = false)
|
||||
private String userName;
|
||||
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
@Column(name = "secret_answer", nullable = false)
|
||||
private String secretQuestionAnswer;
|
||||
|
||||
@Column(name = "birth_date", nullable = false)
|
||||
private LocalDate birthDate;
|
||||
|
||||
@Column(name = "saving", nullable = false)
|
||||
private Integer saving;
|
||||
|
||||
@Column(name = "annual_income", nullable = false)
|
||||
private Integer annualIncome;
|
||||
|
||||
@Column(name = "monthly_budget", nullable = false)
|
||||
private Integer monthlyBudget;
|
||||
|
||||
@Column(name = "delete_flag", nullable = false)
|
||||
private Integer deleteFlag;
|
||||
|
||||
@OneToMany(mappedBy = "userEntity")
|
||||
private List<TransactionEntity> transactionEntityList;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "secret_question_id")
|
||||
private QuestionEntity questionEntity;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "goal_id")
|
||||
private GoalEntity goalEntity;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "course_id")
|
||||
private CourseEntity courseEntity;
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseInfoModel;
|
||||
import com.example.demo.app.infra.entity.AllocationEntity;
|
||||
import com.example.demo.app.infra.entity.AllocationId;
|
||||
|
||||
public interface AllocationRepository extends JpaRepository<AllocationEntity, AllocationId>{
|
||||
|
||||
List<AllocationEntity> findByCourseEntity_CourseId(Long courseId);
|
||||
|
||||
@Query(" SELECT new com.example.demo.app.domain.model.CourseInfoModel("
|
||||
+ "co.courseId, "
|
||||
+ " co.courseName, "
|
||||
+ " ca.categoryId, "
|
||||
+ " ca.categoryName, "
|
||||
+ " a.allocationRatio )"
|
||||
+ " FROM AllocationEntity a"
|
||||
+ " INNER JOIN CourseEntity co "
|
||||
+ " ON a.courseEntity.courseId = co.courseId "
|
||||
+ " INNER JOIN CategoryEntity ca "
|
||||
+ " on a.categoryEntity.categoryId = ca.categoryId "
|
||||
+ " WHERE ca.transactionType = 0 "
|
||||
+ " ORDER BY a.courseEntity.courseId ASC, "
|
||||
+ " a.categoryEntity.categoryId ASC ")
|
||||
List<CourseInfoModel> findAllJoinedAllocation();
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import com.example.demo.app.infra.entity.CategoryEntity;
|
||||
|
||||
public interface CategoryRepository extends JpaRepository<CategoryEntity, Long> {
|
||||
|
||||
|
||||
@Query("select c from CategoryEntity c where c.categoryName = :categoryName")
|
||||
public CategoryEntity findByCategoryName(@Param("categoryName") String categoryName);
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.example.demo.app.infra.entity.CourseEntity;
|
||||
|
||||
public interface CourseRepository extends JpaRepository<CourseEntity, Long> {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.app.infra.entity.GoalEntity;
|
||||
|
||||
@Repository
|
||||
public interface GoalRepository extends JpaRepository<GoalEntity, Long> {
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.example.demo.app.infra.entity.QuestionEntity;
|
||||
|
||||
public interface QuestionRepository extends JpaRepository<QuestionEntity, Long> {
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import com.example.demo.app.infra.entity.TransactionEntity;
|
||||
import com.example.demo.app.presentation.form.Expense;
|
||||
import com.example.demo.app.presentation.form.Income;
|
||||
|
||||
public interface TransactionRepository extends JpaRepository<TransactionEntity, Long> {
|
||||
|
||||
@Query("select t from TransactionEntity t where t.userEntity.userId = :userId and t.transactionDate = :todayDate")
|
||||
public List<TransactionEntity> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
||||
|
||||
@Query("select t from TransactionEntity t where (t.transactionDate between :startDate and :endDate) and (t.userEntity.userId = :userId) order by t.transactionDate asc")
|
||||
public List<TransactionEntity> findAllByDateAndUserId(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
@Query("select 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 = 0")
|
||||
public Integer findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
@Query("select 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")
|
||||
public Integer findTotalIncome(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
@Query("select coalesce(sum(t.amount), 0) from TransactionEntity t where t.userEntity.userId = :userId and t.categoryEntity.categoryId = :categoryId and t.transactionDate between :startDate and :endDate")
|
||||
public Integer findCategoryExpense(LocalDate startDate, LocalDate endDate, Long userId, Long categoryId);
|
||||
|
||||
@Query("select new com.example.demo.app.presentation.form.Expense(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 = 0 group by t.transactionDate order by t.transactionDate asc")
|
||||
public List<Expense> findTotalExpenseList(LocalDate startDate, LocalDate endDate, Long userId);
|
||||
|
||||
@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);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.example.demo.app.infra.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.app.infra.entity.UserEntity;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
|
||||
@Query("select u from UserEntity u where u.mailAddress = :mailAddress and u.password = :password and u.deleteFlag = 0")
|
||||
Optional<UserEntity> findByMailAddressAndPassword(
|
||||
String mailAddress,
|
||||
String password);
|
||||
|
||||
Optional<UserEntity> findByMailAddress(String mailAddress);
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
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 com.example.demo.app.domain.model.AnalysisModel;
|
||||
import com.example.demo.app.domain.model.LoginModel;
|
||||
import com.example.demo.app.domain.service.AnalysisService;
|
||||
import com.example.demo.app.presentation.form.AnalysisForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class AnalysisController {
|
||||
|
||||
private final AnalysisService analysisService;
|
||||
|
||||
@GetMapping("/analysis")
|
||||
public String showAnalysis(Model model, HttpSession session) {
|
||||
|
||||
//ログインユーザーの取得(セッション)
|
||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||
|
||||
//分析結果の取得(Service)
|
||||
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId());
|
||||
|
||||
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
|
||||
|
||||
//model格納
|
||||
model.addAttribute("analysisForm", analysisForm);
|
||||
|
||||
return "analysis";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
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.PostMapping;
|
||||
|
||||
import com.example.demo.app.domain.model.AuthenticationModel;
|
||||
import com.example.demo.app.domain.service.AuthenticationService;
|
||||
import com.example.demo.app.infra.repository.QuestionRepository;
|
||||
import com.example.demo.app.presentation.form.AuthenticationForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class AuthenticationController {
|
||||
|
||||
private final AuthenticationService authenticationService;
|
||||
private final QuestionRepository questionRepository;
|
||||
|
||||
@GetMapping("/authentication")
|
||||
public String showAuthentication(Model model) {
|
||||
|
||||
model.addAttribute("authenticationForm", new AuthenticationForm());
|
||||
model.addAttribute("questionList", questionRepository.findAll());
|
||||
|
||||
return "authentication";
|
||||
}
|
||||
|
||||
@PostMapping("/authentication")
|
||||
public String authenticate(
|
||||
AuthenticationForm authenticationForm,
|
||||
Model model,
|
||||
HttpSession session) {
|
||||
|
||||
AuthenticationModel authenticationModel =
|
||||
authenticationService.authenticate(authenticationForm);
|
||||
|
||||
if (authenticationModel == null) {
|
||||
model.addAttribute("errorMessage", "認証情報が正しくありません。");
|
||||
model.addAttribute("questionList", questionRepository.findAll());
|
||||
|
||||
return "authentication";
|
||||
}
|
||||
|
||||
session.setAttribute(
|
||||
"passwordResetUserId",
|
||||
authenticationModel.getUserId());
|
||||
|
||||
return "password_reset";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.example.demo.app.presentation.controller;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import com.example.demo.app.domain.service.CourseInfoService;
|
||||
import com.example.demo.app.domain.service.CourseService;
|
||||
import com.example.demo.app.presentation.form.CourseForm;
|
||||
import com.example.demo.app.presentation.form.CourseInfoForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class CourseController {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(CourseController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
// private final HttpSession httpSession;
|
||||
private final CourseService courseService;
|
||||
private final CourseInfoService courseInfoService;
|
||||
|
||||
|
||||
|
||||
@GetMapping("/select-course")
|
||||
public String select(Model model) {
|
||||
|
||||
//try {
|
||||
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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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 com.example.demo.app.domain.model.LoginModel;
|
||||
import com.example.demo.app.domain.service.LoginService;
|
||||
import com.example.demo.app.presentation.form.LoginForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class LoginController {
|
||||
|
||||
private final LoginService loginService;
|
||||
|
||||
@GetMapping("/login")
|
||||
public String showLogin(@ModelAttribute LoginForm loginForm) {
|
||||
|
||||
return "login";
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public String login(
|
||||
@ModelAttribute LoginForm loginForm,
|
||||
Model model,
|
||||
HttpSession session) {
|
||||
|
||||
LoginModel loginModel = loginService.login(
|
||||
loginForm.getMailAddress(),
|
||||
loginForm.getPassword());
|
||||
|
||||
if (loginModel == null) {
|
||||
model.addAttribute(
|
||||
"errorMessage",
|
||||
"Email address or password is incorrect.");
|
||||
|
||||
return "login";
|
||||
}
|
||||
|
||||
session.setAttribute("loginUser", loginModel);
|
||||
|
||||
return "redirect:/menu";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
package com.example.demo.app.presentation.controller;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.RequestParam;
|
||||
|
||||
import com.example.demo.app.domain.model.LoginModel;
|
||||
import com.example.demo.app.domain.service.CategoryService;
|
||||
import com.example.demo.app.domain.service.TransactionService;
|
||||
import com.example.demo.app.presentation.form.CategoryForm;
|
||||
import com.example.demo.app.presentation.form.Expense;
|
||||
import com.example.demo.app.presentation.form.Income;
|
||||
import com.example.demo.app.presentation.form.TransactionForm;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class TransactionController {
|
||||
|
||||
private final TransactionService transactionService;
|
||||
private final CategoryService categoryService;
|
||||
|
||||
// 一覧画面
|
||||
@GetMapping("/transaction/list")
|
||||
public String transactionList(@RequestParam(required = false) LocalDate startDates,
|
||||
@RequestParam(required = false) LocalDate endDates, Model model,
|
||||
HttpSession session) {
|
||||
|
||||
LocalDate startDate = (startDates == null) ? LocalDate.now().withDayOfMonth(1) : startDates;
|
||||
|
||||
LocalDate endDate = (endDates == null) ? LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth())
|
||||
: endDates;
|
||||
|
||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||
|
||||
Map<LocalDate, List<TransactionForm>> transactionFormMap = new HashMap<>();
|
||||
|
||||
transactionService.findAllByDate(startDate, endDate, loginUser.getUserId()).forEach((date, list) -> {
|
||||
List<TransactionForm> transactionFormList = list.stream().map(transaction -> {
|
||||
System.out.println(transaction.getTransactionDate());
|
||||
TransactionForm transactionForm = TransactionForm.convertFrom(
|
||||
transaction,
|
||||
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||
.getCategoryName(),
|
||||
transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId()),
|
||||
transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId()),
|
||||
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||
.getTransactionType());
|
||||
System.out.println("startDate = " + startDate);
|
||||
System.out.println("endDate = " + endDate);
|
||||
return transactionForm;
|
||||
}).collect(Collectors.toList());
|
||||
transactionFormMap.put(date, transactionFormList);
|
||||
});
|
||||
|
||||
|
||||
|
||||
model.addAttribute("transactionFormMap", transactionFormMap);
|
||||
|
||||
return "transaction_list";
|
||||
}
|
||||
|
||||
// 詳細画面
|
||||
@GetMapping("/transaction/detail")
|
||||
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
|
||||
|
||||
LocalDate todayDate = (todayDates == null) ? LocalDate.now() : todayDates;
|
||||
|
||||
|
||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||
|
||||
List<TransactionForm> transactionFormList = transactionService
|
||||
.findByUserIdAndDate(todayDate, loginUser.getUserId()).stream()
|
||||
.map(transaction -> {
|
||||
TransactionForm transactionForm = TransactionForm.convertFrom(
|
||||
transaction,
|
||||
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||
.getCategoryName(),
|
||||
transactionService.findTotalExpense(todayDate, todayDate, loginUser.getUserId()),
|
||||
transactionService.findTotalIncome(todayDate, todayDate, loginUser.getUserId()),
|
||||
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||
.getTransactionType());
|
||||
return transactionForm;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
model.addAttribute("today", todayDate);
|
||||
model.addAttribute("transactionFormList", transactionFormList);
|
||||
|
||||
return "transaction_detail";
|
||||
}
|
||||
|
||||
@GetMapping("/transaction/create")
|
||||
public String createOneGet(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model) {
|
||||
|
||||
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
||||
|
||||
model.addAttribute("categoryFormList", categoryFormList);
|
||||
model.addAttribute("today", today);
|
||||
|
||||
return "transaction_create";
|
||||
}
|
||||
|
||||
@PostMapping("/transaction/create")
|
||||
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today, Model model, HttpSession session) {
|
||||
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||
transactionForm.setUserId(loginUser.getUserId());
|
||||
transactionForm.setTransactionDate(today);
|
||||
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
return "redirect:/transaction/detail?todayDates=" + today;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/transaction/update")
|
||||
public String updateOneGet(@ModelAttribute TransactionForm transactionForm) {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@PostMapping("/transaction/update")
|
||||
public String updateOnePost(@ModelAttribute TransactionForm transactionForm, Model model) {
|
||||
|
||||
if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/transaction/delete")
|
||||
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
|
||||
|
||||
transactionService.deleteTransaction(transactionId);
|
||||
return "redirect:/transaction/detail?todayDates=" + today;
|
||||
}
|
||||
|
||||
@GetMapping("/menu")
|
||||
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");
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
int year = (years.equals("0")) ? today.getYear() : Integer.parseInt(years);
|
||||
int month = (months.equals("0")) ? today.getMonthValue() : Integer.parseInt(months);
|
||||
|
||||
System.out.println("year : " + year + "month : " + month);
|
||||
|
||||
YearMonth yearMonth = YearMonth.of(year, month);
|
||||
|
||||
int lastDay = yearMonth.lengthOfMonth();
|
||||
|
||||
int firstDayOfWeek =
|
||||
yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
||||
|
||||
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());
|
||||
|
||||
|
||||
List<Income> incomeList = transactionService.findTotalIncomeList(startDate, endDate, loginUser.getUserId());
|
||||
List<Expense> expenseList = transactionService.findTotalExpenseList(startDate, endDate, loginUser.getUserId());
|
||||
|
||||
model.addAttribute("incomeList", incomeList);
|
||||
|
||||
model.addAttribute("expenseList", expenseList);
|
||||
|
||||
|
||||
int totalIncome = transactionService.findTotalIncome(startDate, endDate, loginUser.getUserId());
|
||||
|
||||
int totalExpense= transactionService.findTotalExpense(startDate, endDate, loginUser.getUserId());
|
||||
|
||||
model.addAttribute("totalIncome", totalIncome);
|
||||
model.addAttribute("totalExpense", totalExpense);
|
||||
|
||||
|
||||
return "menu";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.AllocationModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AllocationForm {
|
||||
|
||||
private Long categoryId;
|
||||
private Long courseId;
|
||||
private Integer allocationRatio;
|
||||
|
||||
public static AllocationForm convertFrom(AllocationModel allocationModel) {
|
||||
return new AllocationForm(allocationModel.getCategoryId(), allocationModel.getCourseId(), allocationModel.getAllocationRatio());
|
||||
}
|
||||
|
||||
public static List<AllocationForm> convertFrom(List<AllocationModel> allocationModelList){
|
||||
return allocationModelList.stream().map(AllocationForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.AnalysisModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AnalysisForm {
|
||||
|
||||
private Integer currentMonthTotalAmount;
|
||||
|
||||
private Integer previousMonthTotalAmount;
|
||||
|
||||
private Integer totalDifferenceAmount;
|
||||
|
||||
private List<CategoryAnalysisForm>
|
||||
categoryAnalysisFormList;
|
||||
|
||||
public static AnalysisForm convertFrom(
|
||||
AnalysisModel analysisModel) {
|
||||
|
||||
return new AnalysisForm(
|
||||
analysisModel.getCurrentMonthTotalAmount(),
|
||||
analysisModel.getPreviousMonthTotalAmount(),
|
||||
analysisModel.getTotalDifferenceAmount(),
|
||||
CategoryAnalysisForm.convertFrom(
|
||||
analysisModel.getCategoryAnalysisModelList()));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AuthenticationForm {
|
||||
private String mailAddress;
|
||||
private Integer secretQuestionId;
|
||||
private String secretAnswer;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.CategoryAnalysisModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CategoryAnalysisForm {
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private Integer currentMonthAmount;
|
||||
|
||||
private Integer previousMonthAmount;
|
||||
|
||||
private Integer monthDifferenceAmount;
|
||||
|
||||
private Integer courseLimitAmount;
|
||||
|
||||
private Integer courseDifferenceAmount;
|
||||
|
||||
public static CategoryAnalysisForm convertFrom(
|
||||
CategoryAnalysisModel categoryAnalysisModel) {
|
||||
|
||||
return new CategoryAnalysisForm(
|
||||
categoryAnalysisModel.getCategoryName(),
|
||||
categoryAnalysisModel.getCurrentMonthAmount(),
|
||||
categoryAnalysisModel.getPreviousMonthAmount(),
|
||||
categoryAnalysisModel.getMonthDifferenceAmount(),
|
||||
categoryAnalysisModel.getCourseLimitAmount(),
|
||||
categoryAnalysisModel.getCourseDifferenceAmount());
|
||||
}
|
||||
|
||||
public static List<CategoryAnalysisForm> convertFrom(
|
||||
List<CategoryAnalysisModel> categoryAnalysisModelList) {
|
||||
|
||||
return categoryAnalysisModelList.stream()
|
||||
.map(CategoryAnalysisForm::convertFrom)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.CategoryModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CategoryForm {
|
||||
|
||||
private Long categoryId;
|
||||
private String categoryName;
|
||||
private Integer transactionType;
|
||||
|
||||
public static CategoryForm convertFrom(CategoryModel categoryModel) {
|
||||
return new CategoryForm(categoryModel.getCategoryId(), categoryModel.getCategoryName(), categoryModel.getTransactionType());
|
||||
}
|
||||
|
||||
public static List<CategoryForm> convertFrom(List<CategoryModel> categoryModelList){
|
||||
return categoryModelList.stream().map(CategoryForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CourseForm {
|
||||
|
||||
private Long courseId;
|
||||
private String courseName;
|
||||
private String description;
|
||||
|
||||
|
||||
public static CourseForm convertFrom(CourseModel courseModel) {
|
||||
return new CourseForm(
|
||||
courseModel.getCourseId(),
|
||||
courseModel.getCourseName(),
|
||||
courseModel.getDescription()
|
||||
);
|
||||
}
|
||||
|
||||
public static List<CourseForm> convertFrom(List<CourseModel> courseModelList){
|
||||
return courseModelList.stream().map(CourseForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.CourseInfoModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CourseInfoForm {
|
||||
|
||||
private Long courseId;
|
||||
|
||||
private String courseName;
|
||||
|
||||
private Long categoryId;
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private Integer allocationRatio;
|
||||
|
||||
|
||||
public static CourseInfoForm convertFrom(CourseInfoModel courseInfoModel ) {
|
||||
return new CourseInfoForm(courseInfoModel.getCourseId(), courseInfoModel.getCourseName(), courseInfoModel.getCategoryId(), courseInfoModel.getCategoryName(), courseInfoModel.getAllocationRatio());
|
||||
}
|
||||
|
||||
public static List<CourseInfoForm> convertFrom(List<CourseInfoModel> courseInfoModelList ) {
|
||||
return courseInfoModelList.stream().map(CourseInfoForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
public static CourseInfoModel convertTo(CourseInfoForm courseInfoForm) {
|
||||
return new CourseInfoModel(
|
||||
courseInfoForm.getCourseId(),
|
||||
courseInfoForm.getCourseName(),
|
||||
courseInfoForm.getCategoryId(),
|
||||
courseInfoForm.getCategoryName(),
|
||||
courseInfoForm.getAllocationRatio());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Expense {
|
||||
|
||||
private LocalDate date;
|
||||
private Long amount;
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Income {
|
||||
|
||||
private LocalDate date;
|
||||
private Long amount;
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginForm {
|
||||
|
||||
private String mailAddress;
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.example.demo.app.presentation.form;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.app.domain.model.TransactionModel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TransactionForm {
|
||||
|
||||
private Long transactionId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long categoryId;
|
||||
|
||||
private Integer amount;
|
||||
|
||||
private LocalDate transactionDate;
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private Integer income;
|
||||
|
||||
private Integer expense;
|
||||
|
||||
private Integer transactionType;
|
||||
|
||||
|
||||
public static TransactionForm convertFrom(TransactionModel transactionModel, String categoryName, int income, int expense, int transactionType) {
|
||||
return new TransactionForm(
|
||||
transactionModel.getTransactionId(),
|
||||
transactionModel.getUserId(),
|
||||
transactionModel.getCategoryId(),
|
||||
transactionModel.getAmount(),
|
||||
transactionModel.getTransactionDate(),
|
||||
categoryName,
|
||||
income,
|
||||
expense,
|
||||
transactionType);
|
||||
}
|
||||
|
||||
|
||||
public static List<TransactionForm> convertFrom(List<TransactionModel> transactionModelList, String categoryName, int income, int expense, int transactionType ) {
|
||||
return transactionModelList.stream().map(transactionModel -> TransactionForm.convertFrom(transactionModel, categoryName, income, expense, transactionType)).toList();
|
||||
}
|
||||
|
||||
public static TransactionModel convertTo(TransactionForm transactionForm) {
|
||||
return new TransactionModel(
|
||||
transactionForm.getTransactionId(),
|
||||
transactionForm.getUserId(),
|
||||
transactionForm.getCategoryId(),
|
||||
transactionForm.getAmount(),
|
||||
transactionForm.getTransactionDate());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.example.demo.utility;
|
||||
|
||||
public class Constant {
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
table, th, td {border: 1px solid black; border-collapse: collapse;}
|
||||
|
||||
td:hover{background-color: lightblue;}
|
||||
|
||||
th{font-weight: bold; height: 50px;}
|
||||
|
||||
td{text-align: left; vertical-align: text-top; width: 200px; height: 100px; padding: 10px}
|
||||
|
||||
.holiday{color: red;}
|
||||
|
||||
#today{font-weight: bold; background-color: bisque;}
|
||||
|
||||
.year{font-size: 30px;}
|
||||
|
||||
.month{font-size: 50px; font-weight: bold;}
|
||||
@@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>認証</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<h1>本人認証確認</h1>
|
||||
|
||||
<form th:action="@{/authentication}" th:object="${authenticationForm}" method="post">
|
||||
|
||||
<div>
|
||||
<label for="mailAddress">メールアドレス</label>
|
||||
<input type="email" id="mailAddress" th:field="*{mailAddress}">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="secretQuestionId">秘密の質問</label>
|
||||
<select id="secretQuestionId" th:field="*{secretQuestionId}">
|
||||
|
||||
<option value="">選択してください</option>
|
||||
|
||||
<option th:each="question : ${questionList}" th:value="${question.secretQuestionId}"
|
||||
th:text="${question.questionText}">
|
||||
</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="secretAnswer">秘密の質問の回答</label>
|
||||
<input type="text" id="secretAnswer" th:field="*{secretAnswer}">
|
||||
</div>
|
||||
|
||||
<button type="submit">確認</button>
|
||||
|
||||
</form>
|
||||
|
||||
<form th:action="@{/login}" method="get">
|
||||
<button type="submit">戻る</button>
|
||||
</form>
|
||||
</main>
|
||||
|
||||
<script th:if="${errorMessage}" th:inline="javascript">
|
||||
alert(/*[[${errorMessage}]]*/);
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,86 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type">
|
||||
<title>分析画面</title>
|
||||
<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>
|
||||
|
||||
<h2 class="text-center">支出分析</h2>
|
||||
|
||||
<table class="table text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">カテゴリ別</th>
|
||||
<th scope="col">支出</th>
|
||||
<th scope="col">前月比</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">総支出</th>
|
||||
<td th:text="'¥' + ${analysisForm.currentMonthTotalAmount}">
|
||||
0
|
||||
</td>
|
||||
<td th:text="${analysisForm.totalDifferenceAmount >= 0}
|
||||
? '+' + ${analysisForm.totalDifferenceAmount}
|
||||
: ${analysisForm.totalDifferenceAmount}"
|
||||
th:class="${analysisForm.totalDifferenceAmount >= 0}
|
||||
? 'color-danger;'
|
||||
: 'color-primary;'">
|
||||
0
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<hr class="border border-primary border-2 opacity-50">
|
||||
|
||||
<table class="table text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">カテゴリ別</th>
|
||||
<th scope="col">支出</th>
|
||||
<th scope="col">前月比<br>コース比</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="category : ${analysisForm.categoryAnalysisFormList}">
|
||||
|
||||
<th scope="row"
|
||||
th:text="${category.categoryName}">
|
||||
食費
|
||||
</th>
|
||||
|
||||
<td th:text="'¥' + ${category.currentMonthAmount}">
|
||||
0
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<span th:text="${category.monthDifferenceAmount >= 0}
|
||||
? '+' + ${category.monthDifferenceAmount}
|
||||
: ${category.monthDifferenceAmount}"
|
||||
th:class="${category.monthDifferenceAmount >= 0}
|
||||
? 'color-danger;'
|
||||
: 'color-primary;'">
|
||||
</span>
|
||||
<br>
|
||||
<span th:text="${category.courseDifferenceAmount >= 0}
|
||||
? '+' + ${category.courseDifferenceAmount}
|
||||
: ${category.courseDifferenceAmount}"
|
||||
th:class="${category.courseDifferenceAmount >= 0}
|
||||
? 'color-danger;'
|
||||
: 'color-primary;'">
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>ヘッダー</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header th:fragment="header">
|
||||
|
||||
<nav class="navbar" style="background-color: #e3f2fd;" data-bs-theme="light">
|
||||
<div class="container-fluid">
|
||||
<a th:href="@{/menu}" class="navbar-brand fw-bold">Monegement</a>
|
||||
<div class="d-flex gap-2">
|
||||
<a class="btn btn-outline-primary btn-sm" th:href="@{/course}">
|
||||
コース
|
||||
</a>
|
||||
<a class="btn btn-outline-secondary btn-sm" th:href="@{/profile}">
|
||||
プロフィール
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,45 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>ログイン</title>
|
||||
</head>
|
||||
<body>
|
||||
<header></header>
|
||||
|
||||
<main>
|
||||
<h1>ログイン</h1>
|
||||
|
||||
<div th:if="${errorMessage}" th:text="${errorMessage}"></div>
|
||||
<form th:action="@{/login}" th:object="${loginForm}" method="post">
|
||||
<div>
|
||||
<label for="emailAddress">メールアドレス</label>
|
||||
|
||||
<input type="email"
|
||||
th:field="*{mailAddress}"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password">パスワード</label>
|
||||
|
||||
<input type="password"
|
||||
th:field="*{password}"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit">ログイン</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a href="@{user/register}">新規会員登録</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="@{password/authentication}">パスワードを忘れた方</a>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,72 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Calendar</title>
|
||||
<link rel="stylesheet" th:href="@{/css/menu.css}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<span class="year" th:text="|${year}年|"></span>
|
||||
<span class="month" th:text="|${month}月|"></span>
|
||||
|
||||
<table id="calendar">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="holiday">日</th>
|
||||
<th>月</th>
|
||||
<th>火</th>
|
||||
<th>水</th>
|
||||
<th>木</th>
|
||||
<th>金</th>
|
||||
<th>土</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr th:each="week : ${#numbers.sequence(0, 5)}">
|
||||
|
||||
<td th:each="weekDay : ${#numbers.sequence(0, 6)}">
|
||||
|
||||
<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}円|"
|
||||
style="color: blue;">
|
||||
</div>
|
||||
|
||||
<div th:each="expense : ${expenseList}"
|
||||
th:if="${expense.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}"
|
||||
class="expense"
|
||||
th:text="|支出 -${expense.amount}円|"
|
||||
style="color: red;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<h2>
|
||||
<span th:text="|収入:${totalIncome}|"></span>
|
||||
<span th:text="|支出:${totalExpense}|"></span>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>コース選択</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="accordion" id="accordionExample">
|
||||
<div class="accordion-item" th:each="course:${courseList}">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
||||
<span th:text="${course.courseName}"></span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#accordionExample">
|
||||
<div class="accordion-body">
|
||||
<span th:text="${course.description}"></span>
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>カテゴリ名</th><tr>配分(%)</tr>
|
||||
</tr>
|
||||
<tr th:each="courseInfo:${courseInfoList}" th:if="course.courseId == courseInfo.courseId">
|
||||
<td th:text="${courseInfo.categoryName}"></td>
|
||||
<td th:text="${courseInfo.allocationRatio}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,68 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>取引登録</h1>
|
||||
|
||||
<form th:action="@{/transaction/create}" th:object="${transactionForm}" method="post">
|
||||
|
||||
<div>
|
||||
<label for="transactionDate">日付</label>
|
||||
<input type="date" id="transactionDate" th:field="*{transactionDate}">
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<label for="transactionType">収入・支出</label>
|
||||
|
||||
<select id="transactionType" th:field="*{transactionType}">
|
||||
|
||||
<option value="">選択してください</option>
|
||||
<option value="1">支出</option>
|
||||
<option value="2">収入</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>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,38 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>収支詳細</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 th:text="${today}"></h1>
|
||||
|
||||
<div>
|
||||
<ul>
|
||||
<li th:each="transactionForm : ${transactionFormList}">
|
||||
<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>
|
||||
</form>
|
||||
<hr />
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<form th:action="@{/transaction/create}" method="get">
|
||||
<input type="hidden" name="today" id="today" th:value="${today}">
|
||||
|
||||
<button type="submit">新規登録</button>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>一覧</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div th:each="transactionForm : ${transactionFormMap}">
|
||||
|
||||
<a th:href="@{/transaction/detail(todayDates=${transactionForm.key})}">
|
||||
<h3 th:text="${transactionForm.key}"></h3>
|
||||
</a>
|
||||
<ul>
|
||||
<li th:each="transaction : ${transactionForm.value}">
|
||||
<p>カテゴリ名:<span th:text="${transaction.categoryName}"></span>
|
||||
<br>金額:<span th:text="${transaction.amount}"></span>
|
||||
</p>
|
||||
<hr />
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,136 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新規会員登録</title>
|
||||
</head>
|
||||
<body>
|
||||
<header></header>
|
||||
|
||||
<main>
|
||||
<h1>新規会員登録</h1>
|
||||
|
||||
<form th:action="@{/user/register/confirm}" th:object="${userForm}" method="post">
|
||||
<div>
|
||||
<label for="userName">氏名</label>
|
||||
<input type="text"
|
||||
id="userName"
|
||||
th:field="*{userName}"
|
||||
maxlength="100"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="mailAddress">メールアドレス</label>
|
||||
<input type="email"
|
||||
id="mailAddress"
|
||||
th:field="*{mailAddress}"
|
||||
maxlength="255"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="birthDate">生年月日</label>
|
||||
<input type="date"
|
||||
id="birthDate"
|
||||
th:field="*{birthDate}"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password">パスワード</label>
|
||||
<input type="password"
|
||||
id="password"
|
||||
th:field="*{password}"
|
||||
minlength="8"
|
||||
maxlength="255"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="secretQuestionId">秘密の質問</label>
|
||||
<select id="secretQuestionId"
|
||||
th:field="*{secretQuestionId}"
|
||||
required>
|
||||
<option value="">選択してください</option>
|
||||
<option th:each="question : ${questionList}"
|
||||
th:value="${question.secretQuestionId}"
|
||||
th:text="${question.questionText}">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="secretAnswer">秘密の質問の回答</label>
|
||||
<input type="text"
|
||||
id="secretAnswer"
|
||||
th:field="*{secretAnswer}"
|
||||
maxlength="100"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="saving">貯蓄金</label>
|
||||
<input type="number"
|
||||
id="saving"
|
||||
th:field="*{saving}"
|
||||
min="0"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="annualIncome">年収</label>
|
||||
<input type="number"
|
||||
id="annualIncome"
|
||||
th:field="*{annualIncome}"
|
||||
min="0"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="monthlyBudget">月別使用可能金額</label>
|
||||
<input type="number"
|
||||
id="monthlyBudget"
|
||||
th:field="*{monthlyBudget}"
|
||||
min="0"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="goalId">目標</label>
|
||||
<select id="goalId"
|
||||
th:field="*{goalId}"
|
||||
required>
|
||||
<option value="">選択してください</option>
|
||||
<option th:each="goal : ${goalList}"
|
||||
th:value="${goal.goalId}"
|
||||
th:text="${goal.goalTitle}">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="courseId">コース</label>
|
||||
<select id="courseId"
|
||||
th:field="*{courseId}"
|
||||
required>
|
||||
<option value="">選択してください</option>
|
||||
<option th:each="course : ${courseList}"
|
||||
th:value="${course.courseId}"
|
||||
th:text="${course.courseName}">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit">作成</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form th:action="@{/login}" method="get">
|
||||
<button type="submit">戻る</button>
|
||||
</form>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,78 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新規会員登録確認</title>
|
||||
</head>
|
||||
<body>
|
||||
<header></header>
|
||||
|
||||
<main>
|
||||
<h1>新規会員登録確認</h1>
|
||||
|
||||
<div>
|
||||
<p>氏名</p>
|
||||
<p th:text="${session.userForm.userName}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>メールアドレス</p>
|
||||
<p th:text="${session.userForm.mailAddress}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>生年月日</p>
|
||||
<p th:text="${session.userForm.barthDate}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>パスワード</p>
|
||||
<p>********</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>秘密の質問</p>
|
||||
<p th:text="${session.userForm.secretQuestionId}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>秘密の質問の回答</p>
|
||||
<p th:text="${session.userForm.secretAnswer}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>貯蓄金</p>
|
||||
<p th:text="${session.userForm.saving}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>年収</p>
|
||||
<p th:text="${session.userForm.annualIncome}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>月別使用可能額</p>
|
||||
<p th:text="${session.userForm.monthlyBudget}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>目標</p>
|
||||
<p th:text="${session.userForm.goalId}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>コース</p>
|
||||
<p th:text="${session.userForm.courseId}" readonly></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form th:action="@{/user/register}" method="get">
|
||||
<button type="submit">戻る</button>
|
||||
</form>
|
||||
</div>
|
||||
<form th:action="@{/user/register/complete}" method="post">
|
||||
<button type="submit">確定</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user