Compare commits
103 Commits
s-kikuchi
...
db7fc1d16d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db7fc1d16d | ||
| 192191d352 | |||
| 646c37ea57 | |||
|
|
1b6193082d | ||
|
|
86e41765f5 | ||
|
|
804e4a6fdd | ||
|
|
2e64d623b5 | ||
|
|
170e319dca | ||
|
|
6b91c91c19 | ||
|
|
1c5cb6bf7a | ||
|
|
e2286762d6 | ||
| 3d3177bbfa | |||
|
|
0c19adb63f | ||
|
|
f86d47c17a | ||
| a98554ac69 | |||
| 0b336dcf5a | |||
|
|
cf31d03415 | ||
|
|
80d83b96f4 | ||
|
|
7f828657ad | ||
|
|
064b74c49b | ||
|
|
4fc69cddb3 | ||
| 68fbe40385 | |||
|
|
c7e68f6a4f | ||
|
|
083ad8644d | ||
| 9ae0669739 | |||
| f03638b347 | |||
|
|
7e648b9466 | ||
| 54512e411a | |||
| 867926391f | |||
| b0e675d32e | |||
|
|
19989111ec | ||
|
|
4f49c24c99 | ||
|
|
8763f88de4 | ||
|
|
5ab8109504 | ||
| be286201f5 | |||
|
|
d31d6aaf2d | ||
| 86c6910c4a | |||
|
|
42bb3c608f | ||
| c279045228 | |||
| 72477d014b | |||
|
|
67ad98b0ae | ||
| d65a84ea79 | |||
| 79cbbc1f2b | |||
| cef08f1663 | |||
|
|
792172664c | ||
| 1170c710e3 | |||
| fbd1746776 | |||
|
|
073ed5e864 | ||
| 9bc5bd20ac | |||
|
|
882212aed5 | ||
| 5506f5884b | |||
|
|
844c023ef2 | ||
| a6a9cb0b63 | |||
|
|
1369d839af | ||
|
|
7f454b852a | ||
|
|
544ce423d0 | ||
| 6c24eba7bf | |||
|
|
6847f225c4 | ||
|
|
036a495bc7 | ||
| 3d857952c9 | |||
|
|
534fc2683d | ||
|
|
555d8ceb87 | ||
| 83e97b7ec1 | |||
|
|
60159ea3fe | ||
|
|
f1b5e3eaf8 | ||
|
|
3e0c6092aa | ||
|
|
59cec2fed7 | ||
|
|
8aba950a5f | ||
| c21e90185b | |||
|
|
4774badffe | ||
|
|
743fe20e9a | ||
|
|
f3d599e696 | ||
| 91823240da | |||
|
|
7a38ba8e63 | ||
|
|
493dd26367 | ||
|
|
cf732c7a48 | ||
| 5b9db556e0 | |||
| e38153238d | |||
| 841a19688d | |||
| 8c4539dd49 | |||
|
|
e361e02aa8 | ||
|
|
837a82ef9a | ||
| 38b2c1b2cb | |||
| 16477f4ba1 | |||
| ad717036b4 | |||
| c7098f2ec3 | |||
| 67cd3e27ca | |||
| b2662693c2 | |||
|
|
e8eef1aa73 | ||
|
|
40ada62856 | ||
| acd31c9f2a | |||
| 842f2b55f8 | |||
|
|
c093fcad24 | ||
|
|
bae92ded58 | ||
|
|
210579de68 | ||
|
|
05797d47d4 | ||
|
|
9710b52d8d | ||
|
|
0561541bec | ||
|
|
a800606bb2 | ||
|
|
c41bcd1791 | ||
|
|
3e2af36bfb | ||
|
|
c9d0985c7f | ||
|
|
d9a556717c |
@@ -0,0 +1,20 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.example.demo.app.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AuthenticationModel {
|
||||||
|
private Long userId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
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 previousMonthDifferenceAmount;
|
||||||
|
|
||||||
|
private Integer courseLimitAmount;
|
||||||
|
|
||||||
|
private Integer courseDifferenceAmount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.example.demo.app.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class LoginModel {
|
||||||
|
private Long userId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AnalysisModel;
|
||||||
|
|
||||||
|
public interface AnalysisService {
|
||||||
|
|
||||||
|
AnalysisModel getAnalysis(Long userId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
|
||||||
|
public interface LoginService {
|
||||||
|
|
||||||
|
LoginModel login(String mailAddress, String password);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||||
|
|
||||||
|
public interface PasswordResetService {
|
||||||
|
|
||||||
|
boolean resetPassword(Long userId, PasswordResetForm passwordResetForm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
|
||||||
|
void register(UserForm userForm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AnalysisModel;
|
||||||
|
import com.example.demo.app.domain.service.AnalysisService;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
// ユーザー情報取得、月別使用可能資金取得
|
||||||
|
|
||||||
|
// 今月の期間取得
|
||||||
|
// 前月の期間取得
|
||||||
|
// 今月の支出取得
|
||||||
|
// 前月の支出取得
|
||||||
|
// コース配分取得
|
||||||
|
// カテゴリ別集計
|
||||||
|
// 前月との差額集計
|
||||||
|
//総支出算出
|
||||||
|
// コース限度額算出、コース別差額算出
|
||||||
|
// CategoryAnalysisModel生成
|
||||||
|
// AnalysisModelの生成
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.PasswordResetService;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PasswordResetServiceImpl implements PasswordResetService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean resetPassword(
|
||||||
|
Long userId,
|
||||||
|
PasswordResetForm passwordResetForm) {
|
||||||
|
|
||||||
|
if (!passwordResetForm.getPassword()
|
||||||
|
.equals(passwordResetForm.getPasswordConfirm())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserEntity userEntity =
|
||||||
|
userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
|
if (userEntity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
userEntity.setPassword(passwordResetForm.getPassword());
|
||||||
|
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
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 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) {
|
||||||
|
|
||||||
|
List<TransactionEntity> transactionEntityList = transactionRepository.findAllByDateAndUserId(startDate, endDate,
|
||||||
|
userId);
|
||||||
|
|
||||||
|
List<TransactionModel> transactionModelList = TransactionModel
|
||||||
|
.convertFrom(transactionEntityList);
|
||||||
|
|
||||||
|
Map<LocalDate, List<TransactionModel>> transactionModelMap = transactionModelList.stream()
|
||||||
|
.collect(Collectors.groupingBy(TransactionModel::getTransactionDate));
|
||||||
|
|
||||||
|
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.findTotalIncome(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.UserService;
|
||||||
|
import com.example.demo.app.infra.entity.CourseEntity;
|
||||||
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
|
import com.example.demo.app.infra.entity.QuestionEntity;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.CourseRepository;
|
||||||
|
import com.example.demo.app.infra.repository.GoalRepository;
|
||||||
|
import com.example.demo.app.infra.repository.QuestionRepository;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
private final QuestionRepository questionRepository;
|
||||||
|
private final GoalRepository goalRepository;
|
||||||
|
private final CourseRepository courseRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(UserForm userForm) {
|
||||||
|
|
||||||
|
UserEntity userEntity = new UserEntity();
|
||||||
|
|
||||||
|
userEntity.setUserName(userForm.getUserName());
|
||||||
|
userEntity.setMailAddress(userForm.getMailAddress());
|
||||||
|
userEntity.setPassword(userForm.getPassword());
|
||||||
|
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
|
||||||
|
userEntity.setBirthDate(userForm.getBirthDate());
|
||||||
|
userEntity.setSaving(userForm.getSaving());
|
||||||
|
userEntity.setAnnualIncome(userForm.getAnnualIncome());
|
||||||
|
userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
|
||||||
|
|
||||||
|
QuestionEntity questionEntity =
|
||||||
|
questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
|
||||||
|
|
||||||
|
GoalEntity goalEntity =
|
||||||
|
goalRepository.findById(userForm.getGoalId()).orElse(null);
|
||||||
|
|
||||||
|
CourseEntity courseEntity =
|
||||||
|
courseRepository.findById(userForm.getCourseId()).orElse(null);
|
||||||
|
|
||||||
|
userEntity.setQuestionEntity(questionEntity);
|
||||||
|
userEntity.setGoalEntity(goalEntity);
|
||||||
|
userEntity.setCourseEntity(courseEntity);
|
||||||
|
|
||||||
|
userEntity.setDeleteFlag(0);
|
||||||
|
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.example.demo.app.infra.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "allocation")
|
||||||
|
@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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
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.OneToMany;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "course")
|
||||||
|
@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;
|
||||||
|
|
||||||
|
@OneToOne(mappedBy = "courseEntity")
|
||||||
|
private List<AllocationEntity> allocationEntity;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
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> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
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> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public interface TransactionRepository extends JpaRepository<TransactionEntity, Long> {
|
||||||
|
|
||||||
|
@Query("select t from TransactionEntity t where t.userEntity.userId = :userId and t.transactionDate = :transactionDate")
|
||||||
|
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 sum(t.amount) 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 sum(t.amount) 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 sum(t.amount) 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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.AnalysisService;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AnalysisController {
|
||||||
|
|
||||||
|
private final AnalysisService analysisService;
|
||||||
|
|
||||||
|
@GetMapping("/analysis")
|
||||||
|
public String showAnalysis(Model model) {
|
||||||
|
|
||||||
|
//ログインユーザーの取得(セッション)
|
||||||
|
|
||||||
|
//分析結果の取得(Service)
|
||||||
|
|
||||||
|
//model格納
|
||||||
|
|
||||||
|
return "analysis";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
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(Model model) {
|
||||||
|
|
||||||
|
model.addAttribute(
|
||||||
|
"loginForm",
|
||||||
|
new 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 "menu";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
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.service.PasswordResetService;
|
||||||
|
import com.example.demo.app.presentation.form.PasswordResetForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PasswordResetController {
|
||||||
|
|
||||||
|
private final PasswordResetService passwordResetService;
|
||||||
|
|
||||||
|
@GetMapping("/password_reset")
|
||||||
|
public String showPasswordReset(Model model) {
|
||||||
|
|
||||||
|
model.addAttribute(
|
||||||
|
"passwordResetForm",
|
||||||
|
new PasswordResetForm());
|
||||||
|
|
||||||
|
return "password_reset";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/password_reset")
|
||||||
|
public String resetPassword(
|
||||||
|
PasswordResetForm passwordResetForm,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
Long userId =
|
||||||
|
(Long) session.getAttribute("passwordResetUserId");
|
||||||
|
|
||||||
|
if (userId == null) {
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isReset =
|
||||||
|
passwordResetService.resetPassword(
|
||||||
|
userId,
|
||||||
|
passwordResetForm);
|
||||||
|
|
||||||
|
if (!isReset) {
|
||||||
|
model.addAttribute(
|
||||||
|
"errorMessage",
|
||||||
|
"パスワードが一致していません。");
|
||||||
|
|
||||||
|
return "password_reset";
|
||||||
|
}
|
||||||
|
|
||||||
|
session.removeAttribute("passwordResetUserId");
|
||||||
|
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
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.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 -> {
|
||||||
|
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());
|
||||||
|
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("transactionFormList", transactionFormList);
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/transaction/create")
|
||||||
|
public String createOneGet(@ModelAttribute TransactionForm transactionForm) {
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/transaction/create")
|
||||||
|
public String createOnePost(@ModelAttribute TransactionForm transactionForm, Model model) {
|
||||||
|
|
||||||
|
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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.presentation.form.UserForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
@GetMapping("/user/register")
|
||||||
|
public String showRegister(Model model) {
|
||||||
|
model.addAttribute("userForm", new UserForm());
|
||||||
|
return "user_register";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/register/confirm")
|
||||||
|
public String confirmRegister(
|
||||||
|
@ModelAttribute UserForm userForm,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
session.setAttribute("userForm", userForm);
|
||||||
|
|
||||||
|
return "user_register_confirm";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PasswordResetForm {
|
||||||
|
private String password;
|
||||||
|
private String passwordConfirm;
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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 UserForm {
|
||||||
|
private String userName;
|
||||||
|
private String mailAddress;
|
||||||
|
private String password;
|
||||||
|
private Long secretQuestionId;
|
||||||
|
private String SecretAnswer;
|
||||||
|
private LocalDate birthDate;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
private Long goalId;
|
||||||
|
private Long courseId;
|
||||||
|
}
|
||||||
5
src/main/java/com/example/demo/utility/Constant.java
Normal file
5
src/main/java/com/example/demo/utility/Constant.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.demo.utility;
|
||||||
|
|
||||||
|
public class Constant {
|
||||||
|
|
||||||
|
}
|
||||||
53
src/main/resources/templates/Authentication.html
Normal file
53
src/main/resources/templates/Authentication.html
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<!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>
|
||||||
60
src/main/resources/templates/analysis.html
Normal file
60
src/main/resources/templates/analysis.html
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta content="text/html; charset=UTF-8" 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>
|
||||||
|
|
||||||
|
<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>¥234,000</td>
|
||||||
|
<td>+¥38,000</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 scope="row">食費</th>
|
||||||
|
<td>¥34,000</td>
|
||||||
|
<td>+¥8,000<br>+¥1,100</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">交通費</th>
|
||||||
|
<td>¥14,000</td>
|
||||||
|
<td>+¥8,000<br>+¥1,100</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">日用品</th>
|
||||||
|
<td>¥4,000</td>
|
||||||
|
<td>+¥8,000<br>+¥1,100</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
47
src/main/resources/templates/login.html
Normal file
47
src/main/resources/templates/login.html
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<!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"
|
||||||
|
id="emailAddress"
|
||||||
|
th:field="{emailAddress}"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="password">パスワード</label>
|
||||||
|
|
||||||
|
<input type="password"
|
||||||
|
id="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>
|
||||||
42
src/main/resources/templates/password_reset.html
Normal file
42
src/main/resources/templates/password_reset.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<!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="@{/password_reset}" th:obiect="${passwordResteForm"} method="post">
|
||||||
|
<div>
|
||||||
|
<label for="password">新しいパスワード</label>
|
||||||
|
<input type="password"
|
||||||
|
id="password"
|
||||||
|
th:field="*{password}"
|
||||||
|
minlength="8"
|
||||||
|
maxlength="255"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="passwordConfirm">パスワード確認</label>
|
||||||
|
<input type="password"
|
||||||
|
id="passwordConfirm"
|
||||||
|
th:field="*{passwordConfirm}"
|
||||||
|
minlength="8"
|
||||||
|
maxlength="255"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit">再設定</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div th:if="${errorMessage}">
|
||||||
|
<p th:text="${errorMessage}"></p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
136
src/main/resources/templates/user_register.html
Normal file
136
src/main/resources/templates/user_register.html
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
<!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>
|
||||||
78
src/main/resources/templates/user_register_confirm.html
Normal file
78
src/main/resources/templates/user_register_confirm.html
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<!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>
|
||||||
|
<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