Compare commits
253 Commits
s-kikuchi
...
336adf0dec
| Author | SHA1 | Date | |
|---|---|---|---|
| 336adf0dec | |||
|
|
642cd7ee69 | ||
| 52fe77a5b4 | |||
| ac85c2dc23 | |||
|
|
21ca1a72e2 | ||
|
|
56bb709921 | ||
|
|
e2ddffcc60 | ||
|
|
51310bae25 | ||
|
|
08c2c06f4a | ||
|
|
06c2d35512 | ||
|
|
4192faecc2 | ||
|
|
19218d868c | ||
| 8282331339 | |||
| 1759c45fea | |||
| 44ac862bdb | |||
|
|
5939e75f86 | ||
| ed7a3a67b7 | |||
|
|
41c5f6e99e | ||
|
|
af3e171006 | ||
|
|
31a6ce44a4 | ||
| 79b1abeac6 | |||
| 1d010dc02b | |||
|
|
d308f14df4 | ||
|
|
a36705d83f | ||
|
|
ab802cdb25 | ||
|
|
1160af5711 | ||
|
|
d2cf2e6e98 | ||
| 69213bcf9c | |||
| e0a7a3496f | |||
| f35a3e03d7 | |||
| 9a1d7144a8 | |||
|
|
d83559e937 | ||
|
|
db65afe184 | ||
|
|
34e9a17273 | ||
|
|
3378f81a2d | ||
| f588e29b46 | |||
| 11fbec6d8c | |||
| 2372c81ddd | |||
| 254286f14e | |||
| d8ea1acf2f | |||
| dfcc49ad94 | |||
|
|
9259a53bad | ||
|
|
ad1121d694 | ||
|
|
6ca5a9eeec | ||
| 709f5e14da | |||
| 6197b12ac4 | |||
| 18faec044e | |||
|
|
b49c9156a1 | ||
| 6b4ae5bd96 | |||
|
|
9cdf7b7767 | ||
|
|
6dd182ed0b | ||
|
|
04d62956f7 | ||
|
|
a5c9ab9abe | ||
|
|
200ebe2a61 | ||
|
|
2300aa3644 | ||
|
|
d415bf1ad5 | ||
|
|
12550c5b1d | ||
| a2b1922548 | |||
| 1386f4b886 | |||
| 15bf2949bc | |||
| be9abffeaa | |||
| d696d8f376 | |||
| 066d76148b | |||
| 603d0d083a | |||
| cbd5aa6a7d | |||
| 43740691b5 | |||
| 7719c002ff | |||
| 8884a74625 | |||
|
|
61da5163b0 | ||
| 30a2ef3e21 | |||
| 938574654f | |||
|
|
20b4366d91 | ||
|
|
952c6f69d8 | ||
| 2e427c8189 | |||
| 0558555315 | |||
|
|
ff65d8c045 | ||
| e43028c0ee | |||
|
|
594f09553a | ||
| 7ddebf7a4a | |||
|
|
52f2559cf7 | ||
|
|
039f416f49 | ||
| cb7a3f542b | |||
|
|
ed8e971368 | ||
| b48b3ae0bd | |||
|
|
8b6e20cb3a | ||
|
|
8f3ea4cd26 | ||
| 57749b6354 | |||
| a8c46cc9db | |||
| 702dd24d2e | |||
| d71194659b | |||
| f685b10d01 | |||
| 44ceb0ca07 | |||
|
|
f955667682 | ||
|
|
b062f64ea4 | ||
| 614533e2b0 | |||
|
|
00b584372e | ||
| 2da75305fd | |||
| 7e91071379 | |||
| f55ece4dc7 | |||
|
|
b9e6b5662b | ||
| 0a63c81712 | |||
| 571fcc6d90 | |||
| 15185672c4 | |||
| 3833689759 | |||
| abe5573c88 | |||
| 46fd6ee60c | |||
| e40c64c2a9 | |||
| 05dbbb4053 | |||
| aa2a511d2b | |||
| 6d494e1ac1 | |||
| 1c61909a48 | |||
|
|
c091b0491a | ||
|
|
902167b663 | ||
|
|
4590c9e5fe | ||
|
|
aa5bf0c64e | ||
| 0bec7b3b3b | |||
| d59cf78062 | |||
| f68a2569bd | |||
|
|
fbec462f65 | ||
| a7d61be450 | |||
|
|
830d8a672f | ||
|
|
8b9765852b | ||
|
|
ae53f3e733 | ||
| d87bdfbe91 | |||
|
|
22191e63ef | ||
|
|
e261065a62 | ||
| 49ad550839 | |||
|
|
bd2cad7c34 | ||
|
|
db7fc1d16d | ||
| 662e3433d2 | |||
| 23232954f1 | |||
| 4e3477af77 | |||
|
|
296bcf8d70 | ||
|
|
544cbd0ac8 | ||
|
|
0eddd7889f | ||
| 192191d352 | |||
|
|
bda791567c | ||
|
|
1e09463984 | ||
|
|
a89c54f8c0 | ||
| cbaee01d13 | |||
| 2dad64ab10 | |||
| 9b51b26b0e | |||
| 646c37ea57 | |||
| a5799843d3 | |||
|
|
7a13d9cdda | ||
|
|
0c5f4a8c9b | ||
|
|
c5d1814be4 | ||
| 60d4ebd74f | |||
|
|
1b6193082d | ||
|
|
86e41765f5 | ||
|
|
804e4a6fdd | ||
| ca7e93908d | |||
| a735162974 | |||
| 49af15f939 | |||
|
|
2e64d623b5 | ||
|
|
170e319dca | ||
|
|
6b91c91c19 | ||
|
|
1c5cb6bf7a | ||
|
|
e2286762d6 | ||
| ce0a158988 | |||
| 3d3177bbfa | |||
| 54b909d00d | |||
|
|
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 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,3 +31,4 @@ build/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
/bin/
|
||||||
|
|||||||
11
src/main/java/com/example/demo/aop/aspect/SessionCheck.java
Normal file
11
src/main/java/com/example/demo/aop/aspect/SessionCheck.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package com.example.demo.aop.aspect;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface SessionCheck {
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.example.demo.aop.aspect;
|
||||||
|
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.example.demo.exception.NoSessionException;
|
||||||
|
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class SessionCheckAspect {
|
||||||
|
|
||||||
|
HttpServletRequest request;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public SessionCheckAspect(HttpServletRequest request) {
|
||||||
|
this.request = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Pointcut("@annotation(com.example.demo.aop.aspect.SessionCheck)")
|
||||||
|
public void sessionCheckMethod() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before("sessionCheckMethod()")
|
||||||
|
public void checkSession() {
|
||||||
|
HttpSession session = request.getSession(false);
|
||||||
|
|
||||||
|
if (session == null || session.getAttribute("loginUser") == null) {
|
||||||
|
throw new NoSessionException("不正なログインです");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.example.demo.aop.handler;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
|
||||||
|
import com.example.demo.exception.NoSessionException;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = Logger.getLogger(GlobalExceptionHandler.class.getName());
|
||||||
|
|
||||||
|
private final String SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION = "不正な遷移です。";
|
||||||
|
private final String SEVERE_ERROR_MESSAGE_BAD_REQUEST = "不正なリクエストです。";
|
||||||
|
|
||||||
|
@ExceptionHandler(NoSessionException.class)
|
||||||
|
public String handleNoSessionException(Model model, Exception e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
|
model.addAttribute(
|
||||||
|
"errorMessage",
|
||||||
|
"システムエラーが発生しました。"
|
||||||
|
+ "初めからやり直してください。");
|
||||||
|
|
||||||
|
return "error";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||||
|
public String handleBadRequestException(Model model, Exception e) {
|
||||||
|
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||||
|
model.addAttribute("status", HttpStatus.BAD_REQUEST.value());
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public String AllException(Model model, Exception e) {
|
||||||
|
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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 monthDifferenceAmount;
|
||||||
|
|
||||||
|
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,28 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.example.demo.app.domain.model;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
|
import com.example.demo.app.presentation.form.GoalForm;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GoalModel {
|
||||||
|
|
||||||
|
private Long goalId;
|
||||||
|
|
||||||
|
private String goalTitle;
|
||||||
|
|
||||||
|
private String goalSubtitle;
|
||||||
|
|
||||||
|
private Integer targetAmount;
|
||||||
|
|
||||||
|
private LocalDate deadline;
|
||||||
|
|
||||||
|
private Integer goalComplete;
|
||||||
|
|
||||||
|
private Integer achievementRate; // 達成率
|
||||||
|
|
||||||
|
private Integer currentAmount; // 現在の資産
|
||||||
|
|
||||||
|
public static GoalModel convertFrom(GoalEntity goalEntity) {
|
||||||
|
return new GoalModel(
|
||||||
|
goalEntity.getGoalId(),
|
||||||
|
goalEntity.getGoalTitle(),
|
||||||
|
goalEntity.getGoalSubtitle(),
|
||||||
|
goalEntity.getTargetAmount(),
|
||||||
|
goalEntity.getDeadline(),
|
||||||
|
goalEntity.getGoalComplete(),
|
||||||
|
null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GoalEntity convertTo(GoalModel goalModel) {
|
||||||
|
return new GoalEntity(
|
||||||
|
goalModel.getGoalId(),
|
||||||
|
goalModel.getGoalTitle(),
|
||||||
|
goalModel.getGoalSubtitle(),
|
||||||
|
goalModel.getTargetAmount(),
|
||||||
|
goalModel.getDeadline(),
|
||||||
|
goalModel.getGoalComplete(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GoalModel convertFrom(GoalForm goalForm) {
|
||||||
|
return new GoalModel(
|
||||||
|
goalForm.getGoalId(),
|
||||||
|
goalForm.getGoalTitle(),
|
||||||
|
goalForm.getGoalSubtitle(),
|
||||||
|
goalForm.getTargetAmount(),
|
||||||
|
goalForm.getDeadline(),
|
||||||
|
goalForm.getGoalComplete()
|
||||||
|
,null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,18 @@
|
|||||||
|
package com.example.demo.app.domain.model;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ProfileModel {
|
||||||
|
private Long userId;
|
||||||
|
private String userName;
|
||||||
|
private String mailAddress;
|
||||||
|
private LocalDate birthDate;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
}
|
||||||
@@ -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,44 @@
|
|||||||
|
package com.example.demo.app.domain.model;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserModel {
|
||||||
|
private Long userId;
|
||||||
|
private String userName;
|
||||||
|
private String mailAddress;
|
||||||
|
private String password;
|
||||||
|
private Long 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;
|
||||||
|
|
||||||
|
public static UserModel convertFrom(UserEntity userEntity) {
|
||||||
|
return new UserModel(
|
||||||
|
userEntity.getUserId(),
|
||||||
|
userEntity.getUserName(),
|
||||||
|
userEntity.getMailAddress(),
|
||||||
|
userEntity.getPassword(),
|
||||||
|
userEntity.getQuestionEntity().getSecretQuestionId(),
|
||||||
|
userEntity.getSecretQuestionAnswer(),
|
||||||
|
userEntity.getBirthDate(),
|
||||||
|
userEntity.getSaving(),
|
||||||
|
userEntity.getAnnualIncome(),
|
||||||
|
userEntity.getMonthlyBudget(),
|
||||||
|
userEntity.getGoalEntity().getGoalId(),
|
||||||
|
userEntity.getCourseEntity().getCourseId(),
|
||||||
|
userEntity.getDeleteFlag()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.AnalysisModel;
|
||||||
|
|
||||||
|
public interface AnalysisService {
|
||||||
|
|
||||||
|
AnalysisModel getAnalysis(
|
||||||
|
Long userId,
|
||||||
|
Integer year,
|
||||||
|
Integer month);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,16 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
public CategoryModel findByTransactionId(Long transactionId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
|
public CourseModel findById(Long courseId);
|
||||||
|
|
||||||
|
public Long findByName(String courName);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
|
||||||
|
public interface GoalService {
|
||||||
|
|
||||||
|
GoalModel getGoalById(Long goalId);
|
||||||
|
|
||||||
|
GoalModel getGoalByUserId(Long userId);
|
||||||
|
|
||||||
|
GoalModel createGoal(GoalModel goalModel);
|
||||||
|
|
||||||
|
GoalModel updateGoal(GoalModel goalModel);
|
||||||
|
|
||||||
|
// void deleteGoal(Long goalId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,7 @@
|
|||||||
|
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,10 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
import com.example.demo.app.presentation.form.ProfileEditForm;
|
||||||
|
|
||||||
|
public interface ProfileService {
|
||||||
|
ProfileModel findOne(Long userId);
|
||||||
|
void withdraw(Long userId);
|
||||||
|
void update(Long userId, ProfileEditForm profileEditForm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.example.demo.app.infra.entity.QuestionEntity;
|
||||||
|
|
||||||
|
public interface QuestionService {
|
||||||
|
public List<QuestionEntity> findAll();
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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 TransactionModel findByTransactionId(Long transactionId);
|
||||||
|
|
||||||
|
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 findMoneyRecord(Long transactionId);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.example.demo.app.domain.service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.UserModel;
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
|
||||||
|
void register(UserForm userForm, Long courseId);
|
||||||
|
|
||||||
|
public void updateCourse(Long userId, Long courseId);
|
||||||
|
|
||||||
|
public UserModel findByUserId(Long userId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
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, Integer year, Integer month) {
|
||||||
|
|
||||||
|
// ユーザー情報取得、月別使用可能資金取得
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElseThrow(() ->
|
||||||
|
new RuntimeException(
|
||||||
|
"User not found."));
|
||||||
|
|
||||||
|
// コースID取得
|
||||||
|
Long courseId = userEntity.getCourseEntity().getCourseId();
|
||||||
|
|
||||||
|
// 月別使用可能資金取得
|
||||||
|
Integer monthlyBudget =userEntity.getMonthlyBudget();
|
||||||
|
|
||||||
|
// 今月の期間取得
|
||||||
|
LocalDate targetDate = LocalDate.of(year, month, 1);
|
||||||
|
LocalDate currentMonthStartDate = targetDate.withDayOfMonth(1);
|
||||||
|
LocalDate currentMonthEndDate = targetDate.withDayOfMonth(targetDate.lengthOfMonth());
|
||||||
|
|
||||||
|
// 前月の期間取得
|
||||||
|
LocalDate previousDate = targetDate.minusMonths(1);
|
||||||
|
|
||||||
|
LocalDate previousMonthStartDate = previousDate.withDayOfMonth(1);
|
||||||
|
LocalDate previousMonthEndDate = previousDate.withDayOfMonth(previousDate.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,56 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CategoryModel findByTransactionId(Long transactionId) {
|
||||||
|
return CategoryModel.convertFrom(categoryRepository.findByTransactionId(transactionId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.CourseInfoModel;
|
||||||
|
import com.example.demo.app.domain.service.CourseInfoService;
|
||||||
|
import com.example.demo.app.infra.repository.AllocationRepository;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CourseInfoServiceImpl implements CourseInfoService {
|
||||||
|
|
||||||
|
private final AllocationRepository allocationRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CourseInfoModel> findAll() {
|
||||||
|
return allocationRepository.findAllJoinedAllocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CourseModel findById(Long courseId) {
|
||||||
|
return CourseModel.convertFrom(courseRepository.findByCourseId(courseId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long findByName(String courseName) {
|
||||||
|
return courseRepository.findByCourseName(courseName).getCourseId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
import com.example.demo.app.domain.service.GoalService;
|
||||||
|
import com.example.demo.app.infra.entity.GoalEntity;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.GoalRepository;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GoalServiceImpl implements GoalService {
|
||||||
|
|
||||||
|
private final GoalRepository goalRepository;
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel getGoalById(Long goalId) {
|
||||||
|
GoalEntity goalEntity = goalRepository.findById(goalId).orElse(null);
|
||||||
|
return GoalModel.convertFrom(goalEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel getGoalByUserId(Long userId) {
|
||||||
|
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
|
||||||
|
GoalEntity goalEntity = userEntity.getGoalEntity();
|
||||||
|
|
||||||
|
// 収支の合計を計算(収入はプラス、支出はマイナス)
|
||||||
|
int transactionTotal = userEntity.getTransactionEntityList().stream()
|
||||||
|
.mapToInt(t -> {
|
||||||
|
int sign = t.getCategoryEntity().getTransactionType() == 1 ? 1 : -1;
|
||||||
|
return sign * t.getAmount();
|
||||||
|
})
|
||||||
|
.sum();
|
||||||
|
|
||||||
|
// 現在の資産 = 貯蓄金 + 収支合計
|
||||||
|
int currentAmount = userEntity.getSaving() + transactionTotal;
|
||||||
|
|
||||||
|
// 達成率(%) = 現在の資産 ÷ 目標金額 × 100
|
||||||
|
int achievementRate =
|
||||||
|
(goalEntity.getTargetAmount() == null)
|
||||||
|
? 0 :
|
||||||
|
(int) ((currentAmount * 100.0) / goalEntity.getTargetAmount());
|
||||||
|
|
||||||
|
GoalModel goalModel = GoalModel.convertFrom(goalEntity);
|
||||||
|
|
||||||
|
return new GoalModel(
|
||||||
|
goalModel.getGoalId(),
|
||||||
|
goalModel.getGoalTitle(),
|
||||||
|
goalModel.getGoalSubtitle(),
|
||||||
|
goalModel.getTargetAmount(),
|
||||||
|
goalModel.getDeadline(),
|
||||||
|
goalModel.getGoalComplete(),
|
||||||
|
achievementRate,
|
||||||
|
currentAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel createGoal(GoalModel goalModel) {
|
||||||
|
|
||||||
|
GoalEntity goalEntity = GoalModel.convertTo(goalModel);
|
||||||
|
|
||||||
|
GoalEntity savedGoalEntity = goalRepository.save(goalEntity);
|
||||||
|
|
||||||
|
return GoalModel.convertFrom(savedGoalEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoalModel updateGoal(GoalModel goalModel) {
|
||||||
|
|
||||||
|
GoalEntity goalEntity = GoalModel.convertTo(goalModel);
|
||||||
|
|
||||||
|
GoalEntity updatedGoalEntity = goalRepository.save(goalEntity);
|
||||||
|
|
||||||
|
return GoalModel.convertFrom(updatedGoalEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,42 @@
|
|||||||
|
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,63 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
import com.example.demo.app.domain.service.ProfileService;
|
||||||
|
import com.example.demo.app.infra.entity.UserEntity;
|
||||||
|
import com.example.demo.app.infra.repository.UserRepository;
|
||||||
|
import com.example.demo.app.presentation.form.ProfileEditForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ProfileServiceImpl implements ProfileService{
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProfileModel findOne(Long userId) {
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
|
if(userEntity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ProfileModel(
|
||||||
|
userEntity.getUserId(),
|
||||||
|
userEntity.getUserName(),
|
||||||
|
userEntity.getMailAddress(),
|
||||||
|
userEntity.getBirthDate(),
|
||||||
|
userEntity.getSaving(),
|
||||||
|
userEntity.getAnnualIncome(),
|
||||||
|
userEntity.getMonthlyBudget());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void withdraw(Long userId) {
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
|
if (userEntity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
userEntity.setDeleteFlag(1);
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Long userId, ProfileEditForm profileEditForm) {
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
|
if (userEntity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
userEntity.setUserName(profileEditForm.getUserName());
|
||||||
|
userEntity.setMailAddress(profileEditForm.getMailAddress());
|
||||||
|
userEntity.setSaving(profileEditForm.getSaving());
|
||||||
|
userEntity.setAnnualIncome(profileEditForm.getAnnualIncome());
|
||||||
|
userEntity.setMonthlyBudget(profileEditForm.getMonthlyBudget());
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.service.QuestionService;
|
||||||
|
import com.example.demo.app.infra.entity.QuestionEntity;
|
||||||
|
import com.example.demo.app.infra.repository.QuestionRepository;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class QuestionServiceImpl implements QuestionService{
|
||||||
|
|
||||||
|
private final QuestionRepository questionRepository;
|
||||||
|
|
||||||
|
public List<QuestionEntity> findAll() {
|
||||||
|
return questionRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
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 TransactionModel findByTransactionId(Long transactionId) {
|
||||||
|
|
||||||
|
return TransactionModel.convertFrom(transactionRepository.findById(transactionId).get());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 findMoneyRecord(Long transactionId) {
|
||||||
|
return transactionRepository.findMoneyRecord(transactionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.example.demo.app.domain.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.UserModel;
|
||||||
|
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, Long courseId) {
|
||||||
|
|
||||||
|
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.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(courseId).orElse(null);
|
||||||
|
|
||||||
|
userEntity.setQuestionEntity(questionEntity);
|
||||||
|
userEntity.setGoalEntity(goalEntity);
|
||||||
|
userEntity.setCourseEntity(courseEntity);
|
||||||
|
|
||||||
|
userEntity.setDeleteFlag(0);
|
||||||
|
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCourse(Long userId, Long courseId) {
|
||||||
|
UserEntity userEntity = userRepository.findById(userId).orElseThrow();
|
||||||
|
|
||||||
|
CourseEntity courseEntity = courseRepository.findById(courseId).orElseThrow();
|
||||||
|
|
||||||
|
userEntity.setCourseEntity(courseEntity);
|
||||||
|
|
||||||
|
userRepository.save(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public UserModel findByUserId(Long userId) {
|
||||||
|
|
||||||
|
return UserModel.convertFrom(userRepository.findById(userId).get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
@@ -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,52 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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 = true)
|
||||||
|
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,32 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
@Query("select c from CategoryEntity c inner join TransactionEntity t on c.categoryId = t.categoryEntity.categoryId where t.transactionId = :transactionId")
|
||||||
|
public CategoryEntity findByTransactionId(Long transactionId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.example.demo.app.infra.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import com.example.demo.app.infra.entity.CourseEntity;
|
||||||
|
|
||||||
|
public interface CourseRepository extends JpaRepository<CourseEntity, Long> {
|
||||||
|
|
||||||
|
@Query("SELECT c FROM CourseEntity c WHERE c.courseId = :courseId ")
|
||||||
|
public CourseEntity findByCourseId(Long courseId);
|
||||||
|
|
||||||
|
@Query("SELECT c FROM CourseEntity c WHERE c.courseName = :courseName ")
|
||||||
|
public CourseEntity findByCourseName(String courseName);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
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> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,39 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
@Query("select coalesce(t.amount, 0) from TransactionEntity t where t.transactionId = :transactionId")
|
||||||
|
public Integer findMoneyRecord(Long transactionId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
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.RequestParam;
|
||||||
|
|
||||||
|
import com.example.demo.aop.aspect.SessionCheck;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/analysis")
|
||||||
|
public String showAnalysis(
|
||||||
|
@RequestParam(required = false) Integer year,
|
||||||
|
@RequestParam(required = false) Integer month,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
//ログインユーザーの取得(セッション)
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
//初期年月表示
|
||||||
|
LocalDate nowDate = LocalDate.now();
|
||||||
|
|
||||||
|
if (year == null) {
|
||||||
|
year = nowDate.getYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (month == null) {
|
||||||
|
month = nowDate.getMonthValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
//前月・翌月作成
|
||||||
|
LocalDate targetDate = LocalDate.of(year, month, 1);
|
||||||
|
|
||||||
|
LocalDate previousDate = targetDate.minusMonths(1);
|
||||||
|
LocalDate nextDate = targetDate.plusMonths(1);
|
||||||
|
|
||||||
|
//分析結果の取得(Service)
|
||||||
|
AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId(), year, month);
|
||||||
|
|
||||||
|
AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel);
|
||||||
|
|
||||||
|
//model格納
|
||||||
|
model.addAttribute("analysisForm", analysisForm);
|
||||||
|
model.addAttribute("year", year);
|
||||||
|
model.addAttribute("month", month);
|
||||||
|
model.addAttribute("previousYear", previousDate.getYear());
|
||||||
|
model.addAttribute("previousMonth", previousDate.getMonthValue());
|
||||||
|
model.addAttribute("nextYear", nextDate.getYear());
|
||||||
|
model.addAttribute("nextMonth", nextDate.getMonthValue());
|
||||||
|
|
||||||
|
return "analysis";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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.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 com.example.demo.app.presentation.form.PasswordResetForm;
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
model.addAttribute(
|
||||||
|
"passwordResetForm",
|
||||||
|
new PasswordResetForm());
|
||||||
|
|
||||||
|
return "password_reset";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
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.aop.aspect.SessionCheck;
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
import com.example.demo.app.domain.service.CourseInfoService;
|
||||||
|
import com.example.demo.app.domain.service.CourseService;
|
||||||
|
import com.example.demo.app.domain.service.UserService;
|
||||||
|
import com.example.demo.app.presentation.form.CourseForm;
|
||||||
|
import com.example.demo.app.presentation.form.CourseInfoForm;
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
//@RequestMapping("/course")
|
||||||
|
@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;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/course/select/register")
|
||||||
|
public String showSelectCourse(@ModelAttribute UserForm userForm, Model model, HttpSession session) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
session.setAttribute("userForm", userForm);
|
||||||
|
model.addAttribute("mode", "regist");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/select/change")
|
||||||
|
public String showChangeCourse(Model model) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
model.addAttribute("mode", "change");
|
||||||
|
model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll()));
|
||||||
|
model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll()));
|
||||||
|
|
||||||
|
return "select_course";
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
// エラー画面遷移
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@PostMapping("/change")
|
||||||
|
public String changeCourse(@RequestParam Long courseId) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) httpSession.getAttribute("loginUser");
|
||||||
|
|
||||||
|
userService.updateCourse(loginUser.getUserId(), courseId);
|
||||||
|
|
||||||
|
return "redirect:/menu";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ErrorController {
|
||||||
|
@GetMapping("/error")
|
||||||
|
public String showError() {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import com.example.demo.aop.aspect.SessionCheck;
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
import com.example.demo.app.domain.service.GoalService;
|
||||||
|
import com.example.demo.app.presentation.form.GoalForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/goal")
|
||||||
|
public class GoalController {
|
||||||
|
|
||||||
|
private final GoalService goalService;
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("")
|
||||||
|
public String getGoal(Model model, HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
|
||||||
|
GoalModel goalModel = goalService.getGoalByUserId(userId);
|
||||||
|
GoalForm goalForm = GoalForm.convertFrom(goalModel);
|
||||||
|
|
||||||
|
model.addAttribute("goalForm", goalForm);
|
||||||
|
return "goal_view";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/edit")
|
||||||
|
public String editGoal(Model model, HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
|
||||||
|
GoalModel goalModel = goalService.getGoalByUserId(userId);
|
||||||
|
GoalForm goalForm = GoalForm.convertFrom(goalModel);
|
||||||
|
|
||||||
|
model.addAttribute("goalForm", goalForm);
|
||||||
|
return "goal_edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@PostMapping("/update")
|
||||||
|
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
|
||||||
|
// 本人の目標かどうかを確認してから更新する
|
||||||
|
GoalModel currentGoal = goalService.getGoalByUserId(userId);
|
||||||
|
|
||||||
|
if (!currentGoal.getGoalId().equals(goalForm.getGoalId())) {
|
||||||
|
return "redirect:/goal"; // 他人のデータを更新しようとしたら弾く
|
||||||
|
}
|
||||||
|
|
||||||
|
GoalModel goalModel = GoalModel.convertFrom(goalForm);
|
||||||
|
goalService.updateGoal(goalModel);
|
||||||
|
|
||||||
|
return "redirect:/goal";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
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.LoginModel;
|
||||||
|
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) {
|
||||||
|
LoginModel loginUser =
|
||||||
|
(LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
if (loginUser != null) {
|
||||||
|
userId = loginUser.getUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userId == null) {
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isReset =
|
||||||
|
passwordResetService.resetPassword(userId, passwordResetForm);
|
||||||
|
|
||||||
|
System.out.println("isReset=" + isReset);
|
||||||
|
|
||||||
|
if(!isReset) {
|
||||||
|
model.addAttribute("Message", "パスワードが一致しません。");
|
||||||
|
return "password_reset";
|
||||||
|
}
|
||||||
|
|
||||||
|
session.removeAttribute("passwordResetUserId");
|
||||||
|
|
||||||
|
LoginModel loginUser =
|
||||||
|
(LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
if (loginUser != null) {
|
||||||
|
return "redirect:/menu";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
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.aop.aspect.SessionCheck;
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
import com.example.demo.app.domain.service.ProfileService;
|
||||||
|
import com.example.demo.app.presentation.form.ProfileEditForm;
|
||||||
|
import com.example.demo.app.presentation.form.ProfileForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ProfileController {
|
||||||
|
private final ProfileService profileService;
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/profile")
|
||||||
|
public String profile(Model model, HttpSession session) {
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
ProfileModel profileModel = profileService.findOne(loginUser.getUserId());
|
||||||
|
|
||||||
|
ProfileForm profileForm = ProfileForm.convertForm(profileModel);
|
||||||
|
|
||||||
|
model.addAttribute("profileForm", profileForm);
|
||||||
|
return "profile";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/profile/edit")
|
||||||
|
public String showEditProfile(
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser =
|
||||||
|
(LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
ProfileModel profileModel =
|
||||||
|
profileService.findOne(loginUser.getUserId());
|
||||||
|
|
||||||
|
ProfileEditForm profileEditForm =
|
||||||
|
new ProfileEditForm(
|
||||||
|
profileModel.getUserName(),
|
||||||
|
profileModel.getMailAddress(),
|
||||||
|
profileModel.getSaving(),
|
||||||
|
profileModel.getAnnualIncome(),
|
||||||
|
profileModel.getMonthlyBudget());
|
||||||
|
|
||||||
|
model.addAttribute("profileEditForm", profileEditForm);
|
||||||
|
return "profile_edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/profile/edit")
|
||||||
|
public String updateProfile(
|
||||||
|
@ModelAttribute ProfileEditForm profileEditForm,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser =
|
||||||
|
(LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
profileService.update(
|
||||||
|
loginUser.getUserId(),
|
||||||
|
profileEditForm);
|
||||||
|
|
||||||
|
return "redirect:/profile";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/withdraw")
|
||||||
|
public String withdraw(HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser =
|
||||||
|
(LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
profileService.withdraw(loginUser.getUserId());
|
||||||
|
|
||||||
|
session.invalidate();
|
||||||
|
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/logout")
|
||||||
|
public String logout(HttpSession session) {
|
||||||
|
session.invalidate();
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.YearMonth;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
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.aop.aspect.SessionCheck;
|
||||||
|
import com.example.demo.app.domain.model.LoginModel;
|
||||||
|
import com.example.demo.app.domain.service.CategoryService;
|
||||||
|
import com.example.demo.app.domain.service.GoalService;
|
||||||
|
import com.example.demo.app.domain.service.TransactionService;
|
||||||
|
import com.example.demo.app.domain.service.UserService;
|
||||||
|
import com.example.demo.app.presentation.form.CategoryForm;
|
||||||
|
import com.example.demo.app.presentation.form.Expense;
|
||||||
|
import com.example.demo.app.presentation.form.GoalForm;
|
||||||
|
import com.example.demo.app.presentation.form.Income;
|
||||||
|
import com.example.demo.app.presentation.form.TransactionForm;
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class TransactionController {
|
||||||
|
|
||||||
|
private final TransactionService transactionService;
|
||||||
|
private final CategoryService categoryService;
|
||||||
|
private final GoalService goalService;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
// 一覧画面
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/transaction/list")
|
||||||
|
public String transactionList(
|
||||||
|
@RequestParam(required = false, defaultValue = "0") String years,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") String months,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
YearMonth yearMonth = YearMonth.of(year, month);
|
||||||
|
|
||||||
|
YearMonth previousYearMonth = yearMonth.minusMonths(1);
|
||||||
|
|
||||||
|
int previousYear = previousYearMonth.getYear();
|
||||||
|
int previousMonth = previousYearMonth.getMonthValue();
|
||||||
|
|
||||||
|
YearMonth nextYearMonth = yearMonth.plusMonths(1);
|
||||||
|
|
||||||
|
int nextYear = nextYearMonth.getYear();
|
||||||
|
int nextMonth = nextYearMonth.getMonthValue();
|
||||||
|
|
||||||
|
LocalDate startDate = yearMonth.atDay(1);
|
||||||
|
LocalDate endDate = yearMonth.atEndOfMonth();
|
||||||
|
|
||||||
|
Map<LocalDate, List<TransactionForm>> transactionFormMap = new HashMap<>();
|
||||||
|
|
||||||
|
transactionService
|
||||||
|
.findAllByDate(
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
loginUser.getUserId())
|
||||||
|
.forEach((date, list) -> {
|
||||||
|
|
||||||
|
List<TransactionForm> transactionFormList = list.stream()
|
||||||
|
.map(transaction -> {
|
||||||
|
|
||||||
|
CategoryForm categoryForm = CategoryForm.convertFrom(
|
||||||
|
categoryService.findOne(
|
||||||
|
transaction.getCategoryId()));
|
||||||
|
|
||||||
|
return TransactionForm.convertFrom(
|
||||||
|
transaction,
|
||||||
|
categoryForm.getCategoryName(),
|
||||||
|
transactionService.findTotalExpense(
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
loginUser.getUserId()),
|
||||||
|
transactionService.findTotalIncome(
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
loginUser.getUserId()),
|
||||||
|
categoryForm.getTransactionType());
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
transactionFormMap.put(date, transactionFormList);
|
||||||
|
});
|
||||||
|
|
||||||
|
model.addAttribute("year", year);
|
||||||
|
model.addAttribute("month", month);
|
||||||
|
|
||||||
|
model.addAttribute("previousYear", previousYear);
|
||||||
|
model.addAttribute("previousMonth", previousMonth);
|
||||||
|
|
||||||
|
model.addAttribute("nextYear", nextYear);
|
||||||
|
model.addAttribute("nextMonth", nextMonth);
|
||||||
|
|
||||||
|
model.addAttribute("transactionFormMap", transactionFormMap);
|
||||||
|
|
||||||
|
return "transaction_list";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 詳細画面
|
||||||
|
@SessionCheck
|
||||||
|
@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 -> {
|
||||||
|
|
||||||
|
int type = CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
|
.getTransactionType();
|
||||||
|
|
||||||
|
TransactionForm transactionForm;
|
||||||
|
if (type == 1) {
|
||||||
|
|
||||||
|
transactionForm = TransactionForm.convertFrom(
|
||||||
|
transaction,
|
||||||
|
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
|
.getCategoryName(),
|
||||||
|
0,
|
||||||
|
transactionService.findMoneyRecord(transaction.getTransactionId()),
|
||||||
|
type);
|
||||||
|
|
||||||
|
} else if (type == 0) {
|
||||||
|
transactionForm = TransactionForm.convertFrom(
|
||||||
|
transaction,
|
||||||
|
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
|
.getCategoryName(),
|
||||||
|
transactionService.findMoneyRecord(transaction.getTransactionId()),
|
||||||
|
0,
|
||||||
|
type);
|
||||||
|
} else {
|
||||||
|
transactionForm = TransactionForm.convertFrom(
|
||||||
|
transaction,
|
||||||
|
CategoryForm.convertFrom(categoryService.findOne(transaction.getCategoryId()))
|
||||||
|
.getCategoryName(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return transactionForm;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
model.addAttribute("today", todayDate);
|
||||||
|
model.addAttribute("transactionFormList", transactionFormList);
|
||||||
|
|
||||||
|
return "transaction_detail";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/transaction/create")
|
||||||
|
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
|
||||||
|
Model model) {
|
||||||
|
|
||||||
|
if (today == null) {
|
||||||
|
today = LocalDate.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
||||||
|
|
||||||
|
TransactionForm transactionForm = new TransactionForm();
|
||||||
|
transactionForm.setTransactionDate(today);
|
||||||
|
|
||||||
|
System.out.println(transactionForm.getCategoryName() + " " + transactionForm.getAmount());
|
||||||
|
|
||||||
|
model.addAttribute("transactionForm", transactionForm);
|
||||||
|
|
||||||
|
model.addAttribute("categoryFormList", categoryFormList);
|
||||||
|
|
||||||
|
model.addAttribute("today", today.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
|
||||||
|
return "transaction_create";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@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());
|
||||||
|
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@GetMapping("/transaction/update")
|
||||||
|
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
|
||||||
|
Model model) {
|
||||||
|
|
||||||
|
if (today == null) {
|
||||||
|
today = LocalDate.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CategoryForm> categoryFormList = CategoryForm.convertFrom(categoryService.findAll());
|
||||||
|
|
||||||
|
TransactionForm transactionForm = TransactionForm.convertFrom(
|
||||||
|
transactionService.findByTransactionId(transactionId),
|
||||||
|
CategoryForm.convertFrom(categoryService.findByTransactionId(transactionId)).getCategoryName(),
|
||||||
|
transactionService.findMoneyRecord(transactionId),
|
||||||
|
transactionService.findMoneyRecord(transactionId),
|
||||||
|
CategoryForm.convertFrom(categoryService.findByTransactionId(transactionId)).getTransactionType());
|
||||||
|
|
||||||
|
System.out.println("category: " + transactionForm.getCategoryId() + "金額: " + transactionForm.getAmount());
|
||||||
|
|
||||||
|
model.addAttribute("transactionId", transactionId);
|
||||||
|
|
||||||
|
model.addAttribute("transactionForm", transactionForm);
|
||||||
|
|
||||||
|
model.addAttribute("categoryFormList", categoryFormList);
|
||||||
|
|
||||||
|
model.addAttribute("today", today);
|
||||||
|
|
||||||
|
return "transaction_update";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@PostMapping("/transaction/update")
|
||||||
|
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm,
|
||||||
|
@RequestParam LocalDate today, Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
|
||||||
|
|
||||||
|
transactionForm.setUserId(loginUser.getUserId());
|
||||||
|
transactionForm.setTransactionId(transactionId);
|
||||||
|
|
||||||
|
if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "redirect:/transaction/detail?todayDates=" + transactionForm.getTransactionDate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@PostMapping("/transaction/delete")
|
||||||
|
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
|
||||||
|
|
||||||
|
transactionService.deleteTransaction(transactionId);
|
||||||
|
return "redirect:/transaction/detail?todayDates=" + today;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@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);
|
||||||
|
|
||||||
|
YearMonth yearMonth = YearMonth.of(year, month);
|
||||||
|
|
||||||
|
int lastDay = yearMonth.lengthOfMonth();
|
||||||
|
|
||||||
|
int firstDayOfWeek = yearMonth.atDay(1).getDayOfWeek().getValue() % 7;
|
||||||
|
|
||||||
|
YearMonth previousYearMonth = yearMonth.minusMonths(1);
|
||||||
|
|
||||||
|
int previousYear = previousYearMonth.getYear();
|
||||||
|
int previousMonth = previousYearMonth.getMonthValue();
|
||||||
|
|
||||||
|
YearMonth nextYearMonth = yearMonth.plusMonths(1);
|
||||||
|
|
||||||
|
int nextYear = nextYearMonth.getYear();
|
||||||
|
int nextMonth = nextYearMonth.getMonthValue();
|
||||||
|
|
||||||
|
model.addAttribute("year", year);
|
||||||
|
model.addAttribute("month", month);
|
||||||
|
model.addAttribute("day", today.getDayOfMonth());
|
||||||
|
|
||||||
|
model.addAttribute("lastDay", lastDay);
|
||||||
|
model.addAttribute("firstDayOfWeek", firstDayOfWeek);
|
||||||
|
|
||||||
|
model.addAttribute("previousYear", previousYear);
|
||||||
|
model.addAttribute("previousMonth", previousMonth);
|
||||||
|
|
||||||
|
model.addAttribute("nextYear", nextYear);
|
||||||
|
model.addAttribute("nextMonth", nextMonth);
|
||||||
|
|
||||||
|
LocalDate startDate = yearMonth.atDay(1);
|
||||||
|
LocalDate endDate = yearMonth.atEndOfMonth();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
GoalForm goalForm = GoalForm.convertFrom(goalService.getGoalByUserId(loginUser.getUserId()));
|
||||||
|
|
||||||
|
UserForm userForm = UserForm.convertFrom(userService.findByUserId(loginUser.getUserId()));
|
||||||
|
|
||||||
|
model.addAttribute("achievementRate", goalForm.getAchievementRate());
|
||||||
|
|
||||||
|
model.addAttribute("currentAmount", goalForm.getCurrentAmount());
|
||||||
|
|
||||||
|
model.addAttribute("targetAmount", goalForm.getTargetAmount());
|
||||||
|
|
||||||
|
model.addAttribute("saving", userForm.getSaving());
|
||||||
|
|
||||||
|
model.addAttribute("deadline", goalForm.getDeadline());
|
||||||
|
|
||||||
|
return "menu";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.example.demo.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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.service.CourseService;
|
||||||
|
import com.example.demo.app.domain.service.QuestionService;
|
||||||
|
import com.example.demo.app.domain.service.UserService;
|
||||||
|
import com.example.demo.app.infra.entity.QuestionEntity;
|
||||||
|
import com.example.demo.app.presentation.form.UserForm;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
private final CourseService courseService;
|
||||||
|
|
||||||
|
private final QuestionService questionService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/user/register")
|
||||||
|
public String showRegister(Model model, HttpSession session) {
|
||||||
|
UserForm userForm = new UserForm();
|
||||||
|
|
||||||
|
List<QuestionEntity> questionList = questionService.findAll();
|
||||||
|
|
||||||
|
session.setAttribute("questionList", questionList);
|
||||||
|
|
||||||
|
model.addAttribute("userForm", userForm);
|
||||||
|
return "user_register";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/register/return")
|
||||||
|
public String showRegisterReturn(@RequestParam(required = false) Long courseId, Model model, HttpSession session) {
|
||||||
|
|
||||||
|
UserForm userForm = (UserForm) session.getAttribute("userForm");
|
||||||
|
System.out.println(
|
||||||
|
"######################################################################3" + userForm.getBirthDate());
|
||||||
|
|
||||||
|
if (userForm.getUserName().equals("")) {
|
||||||
|
userForm = new UserForm();
|
||||||
|
userForm.setCourseId(courseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (courseId != null) {
|
||||||
|
model.addAttribute("selectedCourseName", courseService.findById(courseId).getCourseName());
|
||||||
|
}
|
||||||
|
|
||||||
|
session.setAttribute("selectedCourseName", courseService.findById(courseId).getCourseName());
|
||||||
|
model.addAttribute("courseId", courseId);
|
||||||
|
System.out.println(
|
||||||
|
"######################################################################3" + userForm.getBirthDate());
|
||||||
|
model.addAttribute("userForm", userForm);
|
||||||
|
|
||||||
|
return "user_register_return";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/user/register/confirm")
|
||||||
|
public String confirmRegisterGet(@ModelAttribute UserForm userForm,
|
||||||
|
String selectedCourseName, Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
model.addAttribute("selectedCourseName", (String) session.getAttribute("selectedCourseName"));
|
||||||
|
return "user_register_confirm";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/register/complete")
|
||||||
|
public String confirmRegister(
|
||||||
|
@ModelAttribute UserForm userForm,
|
||||||
|
Model model,
|
||||||
|
HttpSession session) {
|
||||||
|
|
||||||
|
Long courseId = courseService.findByName((String) session.getAttribute("selectedCourseName"));
|
||||||
|
|
||||||
|
userService.register(userForm, courseId);
|
||||||
|
|
||||||
|
return "redirect:/login";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 Long secretQuestionId;
|
||||||
|
private String secretAnswer;
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,33 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.GoalModel;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GoalForm {
|
||||||
|
|
||||||
|
private Long goalId;
|
||||||
|
|
||||||
|
private String goalTitle;
|
||||||
|
|
||||||
|
private String goalSubtitle;
|
||||||
|
|
||||||
|
private Integer targetAmount;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate deadline;
|
||||||
|
|
||||||
|
private Integer goalComplete;
|
||||||
|
|
||||||
|
private Integer achievementRate; // 達成率
|
||||||
|
|
||||||
|
private Integer currentAmount; // 現在の資産
|
||||||
|
|
||||||
|
public static GoalForm convertFrom(GoalModel goalModel) {
|
||||||
|
return new GoalForm(
|
||||||
|
goalModel.getGoalId(),
|
||||||
|
goalModel.getGoalTitle(),
|
||||||
|
goalModel.getGoalSubtitle(),
|
||||||
|
goalModel.getTargetAmount(),
|
||||||
|
goalModel.getDeadline(),
|
||||||
|
goalModel.getGoalComplete(),
|
||||||
|
goalModel.getAchievementRate(),
|
||||||
|
goalModel.getCurrentAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static List<GoalForm> convertFrom(List<GoalModel> goalModelList) {
|
||||||
|
// return goalModelList.stream().map(GoalForm::convertFrom).toList();
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,16 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ProfileEditForm {
|
||||||
|
private String userName;
|
||||||
|
private String mailAddress;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.ProfileModel;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ProfileForm {
|
||||||
|
private Long userId;
|
||||||
|
private String userName;
|
||||||
|
private String mailAddress;
|
||||||
|
private LocalDate birthDate;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
|
||||||
|
public static ProfileForm convertForm(ProfileModel profileModel) {
|
||||||
|
return new ProfileForm(
|
||||||
|
profileModel.getUserId(),
|
||||||
|
profileModel.getUserName(),
|
||||||
|
profileModel.getMailAddress(),
|
||||||
|
profileModel.getBirthDate(),
|
||||||
|
profileModel.getSaving(),
|
||||||
|
profileModel.getAnnualIncome(),
|
||||||
|
profileModel.getMonthlyBudget());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,43 @@
|
|||||||
|
package com.example.demo.app.presentation.form;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import com.example.demo.app.domain.model.UserModel;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserForm {
|
||||||
|
private String userName;
|
||||||
|
private String mailAddress;
|
||||||
|
private LocalDate birthDate;
|
||||||
|
private String password;
|
||||||
|
private Long secretQuestionId;
|
||||||
|
private String secretAnswer;
|
||||||
|
private Integer saving;
|
||||||
|
private Integer annualIncome;
|
||||||
|
private Integer monthlyBudget;
|
||||||
|
private Long goalId;
|
||||||
|
private Long courseId;
|
||||||
|
|
||||||
|
|
||||||
|
public static UserForm convertFrom(UserModel userModel) {
|
||||||
|
return new UserForm(
|
||||||
|
userModel.getUserName(),
|
||||||
|
userModel.getMailAddress(),
|
||||||
|
userModel.getBrithDate(),
|
||||||
|
userModel.getPassword(),
|
||||||
|
userModel.getSecretQuestionId(),
|
||||||
|
userModel.getSecretAnswer(),
|
||||||
|
userModel.getSaving(),
|
||||||
|
userModel.getAnnualIncome(),
|
||||||
|
userModel.getMonthlyBudget(),
|
||||||
|
userModel.getGoalId(),
|
||||||
|
userModel.getCourseId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.demo.exception;
|
||||||
|
|
||||||
|
public class InsufficientPermissionException extends RuntimeException {
|
||||||
|
|
||||||
|
public InsufficientPermissionException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.demo.exception;
|
||||||
|
|
||||||
|
public class NoSessionException extends RuntimeException {
|
||||||
|
|
||||||
|
public NoSessionException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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 {
|
||||||
|
|
||||||
|
}
|
||||||
111
src/main/resources/static/css/menu.css
Normal file
111
src/main/resources/static/css/menu.css
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#calendar {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
#calendar th,
|
||||||
|
#calendar td {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
font-weight: bold;
|
||||||
|
height: 35px;
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
width: 14%;
|
||||||
|
height: 70px;
|
||||||
|
padding: 5px;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
td:hover {
|
||||||
|
background-color: lightblue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.holiday {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
#today {
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: bisque;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-title {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
gap: 30px;
|
||||||
|
|
||||||
|
margin: 15px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-date {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.month {
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.month-button {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
|
||||||
|
font-size: 28px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #333;
|
||||||
|
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.month-button:hover {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.income {
|
||||||
|
color: blue;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expense {
|
||||||
|
color: red;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.total {
|
||||||
|
margin: 15px 10px;
|
||||||
|
padding: 10px;
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
|
||||||
|
font-size: 16px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
15
src/main/resources/static/css/transaction_detail.css
Normal file
15
src/main/resources/static/css/transaction_detail.css
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
.transaction-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transaction-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transaction-buttons form {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
110
src/main/resources/templates/analysis.html
Normal file
110
src/main/resources/templates/analysis.html
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<!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 class="pb-5 pt-5">
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h2 class="text-center">支出分析</h2>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
|
||||||
|
<a class="month-button" th:href="@{/analysis(year=${previousYear}, month=${previousMonth})}">
|
||||||
|
←
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="calendar-date">
|
||||||
|
<span class="year" th:text="|${year}年|"></span>
|
||||||
|
<span class="month" th:text="|${month}月|"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a class="month-button" th:href="@{/analysis(year=${nextYear}, month=${nextMonth})}">
|
||||||
|
→
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
60
src/main/resources/templates/authentication.html
Normal file
60
src/main/resources/templates/authentication.html
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>認証</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
35
src/main/resources/templates/error.html
Normal file
35
src/main/resources/templates/error.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!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 class="pb-5 pt-5">
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container text-center mt-5">
|
||||||
|
|
||||||
|
<h2 class="text-danger">
|
||||||
|
エラーが発生しました
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p th:text="${errorMessage}"></p>
|
||||||
|
|
||||||
|
<a class="btn btn-primary" th:href="@{/login}">
|
||||||
|
ログイン画面へ
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
42
src/main/resources/templates/footer.html
Normal file
42
src/main/resources/templates/footer.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<!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>
|
||||||
|
|
||||||
|
<footer th:fragment="footer" class="fixed-bottom border-top py-2" style="background-color:#E3F2FD;">
|
||||||
|
|
||||||
|
<nav data-bs-theme="light">
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col border-end">
|
||||||
|
<button type="button" class="btn btn-link text-black text-decoration-none">
|
||||||
|
<a th:href="@{/transaction/create}">入力</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col border-end">
|
||||||
|
<button type="button" class="btn btn-link text-black text-decoration-none">
|
||||||
|
<a th:href="@{/transaction/list}">一覧</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col border-end">
|
||||||
|
<button type="button" class="btn btn-link text-black text-decoration-none">
|
||||||
|
<a th:href="@{/analysis}">分析</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col border-end">
|
||||||
|
<button type="button" class="btn btn-link text-black text-decoration-none">
|
||||||
|
<a th:href="@{/goal}">目標</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</footer>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
46
src/main/resources/templates/goal_edit.html
Normal file
46
src/main/resources/templates/goal_edit.html
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>目標編集</title>
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
|
|
||||||
|
<h1>目標編集</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/goal/update}" th:object="${goalForm}" method="post">
|
||||||
|
<input type="hidden" th:field="*{goalId}">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標名</label>
|
||||||
|
<input type="text" th:field="*{goalTitle}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標説明</label>
|
||||||
|
<textarea th:field="*{goalSubtitle}" required></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標金額</label>
|
||||||
|
<input type="number" th:field="*{targetAmount}" required min="1">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>目標達成期限</label>
|
||||||
|
<input type="date" th:field="*{deadline}" th:min="${#temporals.format(#temporals.createNow(), 'yyyy-MM-dd')}" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit">更新する</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
48
src/main/resources/templates/goal_view.html
Normal file
48
src/main/resources/templates/goal_view.html
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>目標詳細</title>
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body class="pb-5 pt-5">
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>目標詳細</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>目標名</th>
|
||||||
|
<td th:text="${goalForm.goalTitle}"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>目標説明</th>
|
||||||
|
<td th:text="${goalForm.goalSubtitle}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>目標金額</th>
|
||||||
|
<td th:text="${goalForm.targetAmount}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>目標達成期限</th>
|
||||||
|
<td th:text="${goalForm.deadline}"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>達成率</th>
|
||||||
|
<td th:text="${goalForm.achievementRate} + '%'"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<a th:href="@{/goal/edit}">編集する</a>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
29
src/main/resources/templates/header.html
Normal file
29
src/main/resources/templates/header.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<!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" class="fixed-top">
|
||||||
|
|
||||||
|
<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>
|
||||||
48
src/main/resources/templates/login.html
Normal file
48
src/main/resources/templates/login.html
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>ログイン</title>
|
||||||
|
</head>
|
||||||
|
<body class="pb-5 pt-5">
|
||||||
|
<div th:replace="~{header :: header}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h1>ログイン</h1>
|
||||||
|
|
||||||
|
<div th:if="${errorMessage}" th:text="${errorMessage}"></div>
|
||||||
|
<form th:action="@{/login}" th:object="${loginForm}" method="post">
|
||||||
|
<div>
|
||||||
|
<label for="mailAddress">メールアドレス</label>
|
||||||
|
|
||||||
|
<input type="email"
|
||||||
|
id="mailAddress"
|
||||||
|
th:field="*{mailAddress}"
|
||||||
|
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 th:href="@{user/register}">新規会員登録</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a th:href="@{/authentication}">パスワードを忘れた方</a>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
151
src/main/resources/templates/menu.html
Normal file
151
src/main/resources/templates/menu.html
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<title>Calendar</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" th:href="@{/css/menu.css}">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}"></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="calendar-title">
|
||||||
|
|
||||||
|
<a class="month-button" th:href="@{/menu(years=${previousYear}, months=${previousMonth})}">
|
||||||
|
←
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="calendar-date">
|
||||||
|
<span class="year" th:text="|${year}年|"></span>
|
||||||
|
<span class="month" th:text="|${month}月|"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a class="month-button" th:href="@{/menu(years=${nextYear}, months=${nextMonth})}">
|
||||||
|
→
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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)}">
|
||||||
|
|
||||||
|
<a th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1
|
||||||
|
and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}" th:href="@{/transaction/detail(
|
||||||
|
todayDates=${T(java.time.LocalDate).of(year, month, week * 7 + weekDay - firstDayOfWeek + 1)}
|
||||||
|
)}">
|
||||||
|
|
||||||
|
|
||||||
|
<div
|
||||||
|
th:if="${week * 7 + weekDay - firstDayOfWeek + 1 >= 1 and week * 7 + weekDay - firstDayOfWeek + 1 <= lastDay}">
|
||||||
|
|
||||||
|
<div class="date" th:text="${week * 7 + weekDay - firstDayOfWeek + 1}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div th:each="income : ${incomeList}"
|
||||||
|
th:if="${income.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}"
|
||||||
|
class="income" th:text="|収入 +${income.amount}円|">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div th:each="expense : ${expenseList}"
|
||||||
|
th:if="${expense.date.dayOfMonth == week * 7 + weekDay - firstDayOfWeek + 1}"
|
||||||
|
class="expense" th:text="|支出 -${expense.amount}円|">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="total">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>収入:</span>
|
||||||
|
<span th:text="${totalIncome}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>支出:</span>
|
||||||
|
<span th:text="${totalExpense}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>目標貯金</span>
|
||||||
|
<span th:text="${targetAmount}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>現在高</span>
|
||||||
|
<span th:text="${currentAmount}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>貯金額</span>
|
||||||
|
<span th:text="${saving}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>達成率</span>
|
||||||
|
<span th:text="${achievementRate}"></span>
|
||||||
|
<span>%</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>達成期限</span>
|
||||||
|
<span th:text="${deadline}"></span>
|
||||||
|
<span>円</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}"></div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
44
src/main/resources/templates/password_reset.html
Normal file
44
src/main/resources/templates/password_reset.html
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ja"xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>パスワード再設定</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!--<body class="pb-5 pt-5">-->
|
||||||
|
<!-- <div th:replace="~{header :: header}">-->
|
||||||
|
<!-- </div>-->
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h1>パスワード再設定</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/password/reset}" th:object="${passwordResetForm}" 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="${Message}">
|
||||||
|
<p th:text="${Message}"></p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
70
src/main/resources/templates/profile.html
Normal file
70
src/main/resources/templates/profile.html
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>プロフィール</title>
|
||||||
|
</head>
|
||||||
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div>
|
||||||
|
<p>氏名</p>
|
||||||
|
<p th:text="${profileForm.userName}"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>メールアドレス</p>
|
||||||
|
<p th:text="${profileForm.mailAddress}"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>生年月日</p>
|
||||||
|
<p th:text="${profileForm.birthDate}"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>パスワード</p>
|
||||||
|
<form th:action="@{/password/reset}" method="get">
|
||||||
|
<button type="submit">パスワード再設定</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>貯蓄金</p>
|
||||||
|
<p th:text="${profileForm.saving}"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>年収</p>
|
||||||
|
<p th:text="${profileForm.annualIncome}"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>月別使用可能額</p>
|
||||||
|
<p th:text="${profileForm.monthlyBudget}"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<form th:action="@{/profile/edit}" method="get">
|
||||||
|
<button type="submit">編集</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form th:action="@{/logout}" method="post">
|
||||||
|
<button type="submit">ログアウト</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form th:action="@{/withdraw}" method="post"
|
||||||
|
onsubmit="return confirm('本当に脱退しますか?');">
|
||||||
|
<button type="submit">脱退</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
72
src/main/resources/templates/profile_edit.html
Normal file
72
src/main/resources/templates/profile_edit.html
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>プロフィール編集</title>
|
||||||
|
</head>
|
||||||
|
<body class="pb-5 pt-5">
|
||||||
|
|
||||||
|
<div th:replace="~{header :: header}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h1>プロフィール編集</h1>
|
||||||
|
|
||||||
|
<form th:action="@{/profile/edit}"th:object="${profileEditForm}"method="post">
|
||||||
|
<div>
|
||||||
|
<label>氏名</label>
|
||||||
|
<input type="text"
|
||||||
|
th:field="*{userName}"
|
||||||
|
maxlength="100"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>メールアドレス</label>
|
||||||
|
<input type="email"
|
||||||
|
th:field="*{mailAddress}"
|
||||||
|
maxlength="255"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>パスワード</label>
|
||||||
|
<input type="password"
|
||||||
|
value="********"
|
||||||
|
disabled>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>貯蓄金</label>
|
||||||
|
<input type="number"
|
||||||
|
th:field="*{saving}"
|
||||||
|
min="0"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>年収</label>
|
||||||
|
<input type="number"
|
||||||
|
th:field="*{annualIncome}"
|
||||||
|
min="0"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>月別使用可能額</label>
|
||||||
|
<input type="number"
|
||||||
|
th:field="*{monthlyBudget}"
|
||||||
|
min="0"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button type="submit">確認</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<div th:replace="~{footer :: footer}">
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user