diff --git a/src/main/java/com/example/demo/app/domain/model/AuthenticationModel.java b/src/main/java/com/example/demo/app/domain/model/AllocationModel.java similarity index 52% rename from src/main/java/com/example/demo/app/domain/model/AuthenticationModel.java rename to src/main/java/com/example/demo/app/domain/model/AllocationModel.java index ec8db4b..1f6a9c1 100644 --- a/src/main/java/com/example/demo/app/domain/model/AuthenticationModel.java +++ b/src/main/java/com/example/demo/app/domain/model/AllocationModel.java @@ -5,6 +5,10 @@ import lombok.Getter; @Getter @AllArgsConstructor -public class AuthenticationModel { - private Long userId; +public class AllocationModel { + + private Long categoryId; + private Long courseId; + private Integer allocationRatio; + } diff --git a/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java b/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java index 3a94930..47cdadf 100644 --- a/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java +++ b/src/main/java/com/example/demo/app/domain/model/CategoryAnalysisModel.java @@ -13,7 +13,7 @@ public class CategoryAnalysisModel { private Integer previousMonthAmount; - private Integer previousMonthDifferenceAmount; + private Integer monthDifferenceAmount; private Integer courseLimitAmount; diff --git a/src/main/java/com/example/demo/app/domain/model/CourseModel.java b/src/main/java/com/example/demo/app/domain/model/CourseModel.java new file mode 100644 index 0000000..e9e8014 --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/model/CourseModel.java @@ -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 convertFrom(List courseEntityList) { + return courseEntityList.stream().map(CourseModel::convertFrom).toList(); + } +} diff --git a/src/main/java/com/example/demo/app/domain/model/UserModel.java b/src/main/java/com/example/demo/app/domain/model/UserModel.java index 1f79b0c..bb34609 100644 --- a/src/main/java/com/example/demo/app/domain/model/UserModel.java +++ b/src/main/java/com/example/demo/app/domain/model/UserModel.java @@ -8,9 +8,10 @@ import lombok.Getter; @Getter @AllArgsConstructor public class UserModel { + private Long userId; private String userName; - private String mailAddress; + private String emailAddress; private String password; private Integer secretQuestionId; private String secretAnswer; @@ -18,7 +19,7 @@ public class UserModel { private Integer saving; private Integer annualIncome; private Integer monthlyBudget; - private Long goalId; - private Long courseId; + private Integer goalId; + private Integer courseId; private Integer deleteFlag; } diff --git a/src/main/java/com/example/demo/app/domain/service/AuthenticationService.java b/src/main/java/com/example/demo/app/domain/service/AuthenticationService.java deleted file mode 100644 index 824c752..0000000 --- a/src/main/java/com/example/demo/app/domain/service/AuthenticationService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.demo.app.domain.service; - -import com.example.demo.app.domain.model.AuthenticationModel; -import com.example.demo.app.presentation.form.AuthenticationForm; - -public interface AuthenticationService { - - AuthenticationModel authenticate(AuthenticationForm authenticationForm); -} diff --git a/src/main/java/com/example/demo/app/domain/service/CourseInfoService.java b/src/main/java/com/example/demo/app/domain/service/CourseInfoService.java new file mode 100644 index 0000000..83cf4ab --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/CourseInfoService.java @@ -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 findAll(); +} diff --git a/src/main/java/com/example/demo/app/domain/service/CourseService.java b/src/main/java/com/example/demo/app/domain/service/CourseService.java new file mode 100644 index 0000000..4681860 --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/CourseService.java @@ -0,0 +1,11 @@ +package com.example.demo.app.domain.service; + +import java.util.List; + +import com.example.demo.app.domain.model.CourseModel; + +public interface CourseService { + + public List findAll(); + +} diff --git a/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java index 66f4bbc..d0f3388 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/AnalysisServiceImpl.java @@ -1,9 +1,21 @@ 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; @@ -12,29 +24,119 @@ import lombok.RequiredArgsConstructor; public class AnalysisServiceImpl implements AnalysisService { //Repositoryの呼び出し -// private final TransactionRepository transactionRepository; -// private final AllocationRepository allocationRepository; -// private final UserRepository userRepository; -// private final CategoryRepository categoryRepository; + private final TransactionRepository transactionRepository; + private final AllocationRepository allocationRepository; + private final UserRepository userRepository; + private final CategoryRepository categoryRepository; @Override public AnalysisModel getAnalysis(Long userId) { // ユーザー情報取得、月別使用可能資金取得 + UserEntity userEntity = userRepository.findById(userId).orElseThrow(); + + // コースID取得 + Long courseId = userEntity.getCourseEntity().getCourseId(); + + // 月別使用可能資金取得 + Integer monthlyBudget =userEntity.getMonthlyBudget(); // 今月の期間取得 - // 前月の期間取得 - // 今月の支出取得 - // 前月の支出取得 - // コース配分取得 - // カテゴリ別集計 - // 前月との差額集計 - //総支出算出 - // コース限度額算出、コース別差額算出 - // CategoryAnalysisModel生成 - // AnalysisModelの生成 + LocalDate currentMonthStartDate = LocalDate.now().withDayOfMonth(1); + LocalDate currentMonthEndDate = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()); - return null; + // 前月の期間取得 + LocalDate previousMonthStartDate = LocalDate.now().minusMonths(1).withDayOfMonth(1); + LocalDate previousMonthEndDate = LocalDate.now().minusMonths(1).withDayOfMonth(LocalDate.now().minusMonths(1).lengthOfMonth()); + + // 今月の支出取得 + Integer currentMonthTotalAmount = transactionRepository.findTotalExpense(currentMonthStartDate, currentMonthEndDate, userId); + + if (currentMonthTotalAmount == null) { + currentMonthTotalAmount = 0; + } + + // 前月の支出取得 + Integer previousMonthTotalAmount = transactionRepository.findTotalExpense(previousMonthStartDate, previousMonthEndDate, userId); + + if (previousMonthTotalAmount == null) { + previousMonthTotalAmount = 0; + } + + //総支出差額算出 + Integer totalDifferenceAmount = currentMonthTotalAmount - previousMonthTotalAmount; + + //カテゴリ一覧取得 + List categoryAnalysisModelList = new ArrayList<>(); + List categoryEntityList = categoryRepository.findAll(); + List 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); } } diff --git a/src/main/java/com/example/demo/app/domain/service/impl/AuthenticationServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/AuthenticationServiceImpl.java deleted file mode 100644 index 89ac9f4..0000000 --- a/src/main/java/com/example/demo/app/domain/service/impl/AuthenticationServiceImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.example.demo.app.domain.service.impl; - -import org.springframework.stereotype.Service; - -import com.example.demo.app.domain.model.AuthenticationModel; -import com.example.demo.app.domain.service.AuthenticationService; -import com.example.demo.app.infra.entity.UserEntity; -import com.example.demo.app.infra.repository.UserRepository; -import com.example.demo.app.presentation.form.AuthenticationForm; - -import lombok.RequiredArgsConstructor; - -@Service -@RequiredArgsConstructor -public class AuthenticationServiceImpl implements AuthenticationService { - - private final UserRepository userRepository; - - @Override - public AuthenticationModel authenticate(AuthenticationForm authenticationForm) { - - UserEntity userEntity = userRepository.findByMailAddress( - authenticationForm.getMailAddress()) - .orElse(null); - - if (userEntity == null) { - return null; - } - - if (!userEntity.getQuestionEntity().getSecretQuestionId() - .equals(authenticationForm.getSecretQuestionId())) { - return null; - } - - if (!userEntity.getSecretQuestionAnswer() - .equals(authenticationForm.getSecretAnswer())) { - return null; - } - - return new AuthenticationModel(userEntity.getUserId()); - } -} diff --git a/src/main/java/com/example/demo/app/domain/service/impl/CourseInfoServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/CourseInfoServiceImpl.java new file mode 100644 index 0000000..4658a18 --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/impl/CourseInfoServiceImpl.java @@ -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.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 findAll() { + return allocationRepository.findAllJoinedAllocation(); + } +} diff --git a/src/main/java/com/example/demo/app/domain/service/impl/CourseServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/CourseServiceImpl.java new file mode 100644 index 0000000..a4dec5f --- /dev/null +++ b/src/main/java/com/example/demo/app/domain/service/impl/CourseServiceImpl.java @@ -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.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 findAll(){ + return CourseEntity.createCourseModelList(courseRepository.findAll()); + } + +} diff --git a/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java b/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java index 8a6d1a0..bd15a2c 100644 --- a/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/AllocationEntity.java @@ -1,20 +1,26 @@ 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 -@Table(name = "allocation") +@IdClass(AllocationId.class) +@Table(name = "allocation_m") @Data @NoArgsConstructor @AllArgsConstructor @@ -32,5 +38,16 @@ public class AllocationEntity { @Column(name = "allocation_ratio", nullable = false) private Integer allocationRatio; + + + public static List createAllocationModelList(List allocationEntityList) { + return allocationEntityList + .stream() + .map(allocationEntity -> new AllocationModel( + allocationEntity.getCategoryEntity().getCategoryId(), + allocationEntity.getCourseEntity().getCourseId(), + allocationEntity.getAllocationRatio() + )).toList(); + } } diff --git a/src/main/java/com/example/demo/app/infra/entity/AllocationId.java b/src/main/java/com/example/demo/app/infra/entity/AllocationId.java new file mode 100644 index 0000000..3812864 --- /dev/null +++ b/src/main/java/com/example/demo/app/infra/entity/AllocationId.java @@ -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; +} diff --git a/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java b/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java index 995ac6b..3afec50 100644 --- a/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/CourseEntity.java @@ -6,18 +6,19 @@ 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.OneToOne; import jakarta.persistence.Table; -import org.springframework.data.annotation.Id; +import com.example.demo.app.domain.model.CourseModel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Entity -@Table(name = "course") +@Table(name = "course_m") @Data @NoArgsConstructor @AllArgsConstructor @@ -39,6 +40,18 @@ public class CourseEntity { private List userEntity; @OneToOne(mappedBy = "courseEntity") - private List allocationEntity; + private AllocationEntity allocationEntity; + + + public static List createCourseModelList(List courseEntityList) { + + return courseEntityList + .stream() + .map(courseEntity -> new CourseModel( + courseEntity.getCourseId(), + courseEntity.getCourseName(), + courseEntity.getDescription() + )).toList(); + } } diff --git a/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java b/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java index a028437..1eb3503 100644 --- a/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/QuestionEntity.java @@ -29,7 +29,7 @@ public class QuestionEntity { @Column(name = "question_text", nullable = false) private String questionText; - @OneToMany(mappedBy = "QuestionEntity") + @OneToMany(mappedBy = "questionEntity") private List userEntity; } diff --git a/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java b/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java index 838632d..28656c2 100644 --- a/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java +++ b/src/main/java/com/example/demo/app/infra/repository/AllocationRepository.java @@ -7,6 +7,7 @@ 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{ diff --git a/src/main/java/com/example/demo/app/infra/repository/GoalRepository.java b/src/main/java/com/example/demo/app/infra/repository/GoalRepository.java new file mode 100644 index 0000000..c66aa15 --- /dev/null +++ b/src/main/java/com/example/demo/app/infra/repository/GoalRepository.java @@ -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 { + +} \ No newline at end of file diff --git a/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java b/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java index 905f2c3..5bc8cd9 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/AnalysisController.java @@ -1,10 +1,15 @@ package com.example.demo.app.presentation.controller; +import jakarta.servlet.http.HttpSession; + import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import com.example.demo.app.domain.model.AnalysisModel; +import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.service.AnalysisService; +import com.example.demo.app.presentation.form.AnalysisForm; import lombok.RequiredArgsConstructor; @@ -16,13 +21,18 @@ public class AnalysisController { private final AnalysisService analysisService; @GetMapping("/analysis") - public String showAnalysis(Model model) { + public String showAnalysis(Model model, HttpSession session) { //ログインユーザーの取得(セッション) + LoginModel loginUser = (LoginModel) session.getAttribute("loginUser"); //分析結果の取得(Service) + AnalysisModel analysisModel = analysisService.getAnalysis(loginUser.getUserId()); + AnalysisForm analysisForm = AnalysisForm.convertFrom(analysisModel); + //model格納 + model.addAttribute("analysisForm", analysisForm); return "analysis"; } diff --git a/src/main/java/com/example/demo/app/presentation/controller/AuthenticationController.java b/src/main/java/com/example/demo/app/presentation/controller/AuthenticationController.java deleted file mode 100644 index 5cf8569..0000000 --- a/src/main/java/com/example/demo/app/presentation/controller/AuthenticationController.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.example.demo.app.presentation.controller; - -import jakarta.servlet.http.HttpSession; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; - -import com.example.demo.app.domain.model.AuthenticationModel; -import com.example.demo.app.domain.service.AuthenticationService; -import com.example.demo.app.infra.repository.QuestionRepository; -import com.example.demo.app.presentation.form.AuthenticationForm; - -import lombok.RequiredArgsConstructor; - -@Controller -@RequiredArgsConstructor -public class AuthenticationController { - - private final AuthenticationService authenticationService; - private final QuestionRepository questionRepository; - - @GetMapping("/authentication") - public String showAuthentication(Model model) { - - model.addAttribute("authenticationForm", new AuthenticationForm()); - model.addAttribute("questionList", questionRepository.findAll()); - - return "authentication"; - } - - @PostMapping("/authentication") - public String authenticate( - AuthenticationForm authenticationForm, - Model model, - HttpSession session) { - - AuthenticationModel authenticationModel = - authenticationService.authenticate(authenticationForm); - - if (authenticationModel == null) { - model.addAttribute("errorMessage", "認証情報が正しくありません。"); - model.addAttribute("questionList", questionRepository.findAll()); - - return "authentication"; - } - - session.setAttribute( - "passwordResetUserId", - authenticationModel.getUserId()); - - return "password_reset"; - - } -} diff --git a/src/main/java/com/example/demo/app/presentation/controller/CourseController.java b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java new file mode 100644 index 0000000..c9199af --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/controller/CourseController.java @@ -0,0 +1,52 @@ +package com.example.demo.app.presentation.controller; + +import java.util.logging.Logger; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +import com.example.demo.app.domain.service.CourseInfoService; +import com.example.demo.app.domain.service.CourseService; +import com.example.demo.app.presentation.form.CourseForm; +import com.example.demo.app.presentation.form.CourseInfoForm; + +import lombok.RequiredArgsConstructor; + + +@Controller +@RequiredArgsConstructor +public class CourseController { + + private final static Logger LOGGER = Logger.getLogger(CourseController.class.getName()); + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + + // private final HttpSession httpSession; + private final CourseService courseService; + private final CourseInfoService courseInfoService; + + + + @GetMapping("/select-course") + public String select(Model model) { + + //try { + model.addAttribute("courseList", CourseForm.convertFrom(courseService.findAll())); + model.addAttribute("courseInfoList", CourseInfoForm.convertFrom(courseInfoService.findAll())); + + return "select-course"; + + //} catch (Exception e) { +// // ログイン情報の破棄 +// httpSession.invalidate(); +// +// e.printStackTrace(); +// +// // エラーログ出力 +// LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); +// // エラー画面遷移 +// return null; +// } + } +} diff --git a/src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java b/src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java new file mode 100644 index 0000000..c9c4202 --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/AnalysisForm.java @@ -0,0 +1,32 @@ +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 categoryAnalysisFormList; + + public static AnalysisForm convertFrom( + AnalysisModel analysisModel) { + + return new AnalysisForm( + analysisModel.getCurrentMonthTotalAmount(), + analysisModel.getPreviousMonthTotalAmount(), + analysisModel.getTotalDifferenceAmount(), + CategoryAnalysisForm.convertFrom( + analysisModel.getCategoryAnalysisModelList())); + } + +} diff --git a/src/main/java/com/example/demo/app/presentation/form/AuthenticationForm.java b/src/main/java/com/example/demo/app/presentation/form/AuthenticationForm.java deleted file mode 100644 index 2c27a5d..0000000 --- a/src/main/java/com/example/demo/app/presentation/form/AuthenticationForm.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.demo.app.presentation.form; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class AuthenticationForm { - private String mailAddress; - private Integer secretQuestionId; - private String secretAnswer; -} diff --git a/src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java b/src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java new file mode 100644 index 0000000..add1762 --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/CategoryAnalysisForm.java @@ -0,0 +1,48 @@ +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 convertFrom( + List categoryAnalysisModelList) { + + return categoryAnalysisModelList.stream() + .map(CategoryAnalysisForm::convertFrom) + .toList(); + } + +} diff --git a/src/main/java/com/example/demo/app/presentation/form/CourseForm.java b/src/main/java/com/example/demo/app/presentation/form/CourseForm.java new file mode 100644 index 0000000..57ba52e --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/CourseForm.java @@ -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 convertFrom(List courseModelList){ + return courseModelList.stream().map(CourseForm::convertFrom).toList(); + } + +} diff --git a/src/main/java/com/example/demo/app/presentation/form/CourseInfoForm.java b/src/main/java/com/example/demo/app/presentation/form/CourseInfoForm.java new file mode 100644 index 0000000..addce2f --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/form/CourseInfoForm.java @@ -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.getCategoryId(), courseInfoModel.getCourseName(), courseInfoModel.getCategoryId(), courseInfoModel.getCategoryName(), courseInfoModel.getAllocationRatio()); + } + + public static List convertFrom(List 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()); + } + +} diff --git a/src/main/resources/templates/Authentication.html b/src/main/resources/templates/Authentication.html deleted file mode 100644 index 336b3cc..0000000 --- a/src/main/resources/templates/Authentication.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - 認証 - - - -
-

本人認証確認

- -
- -
- - -
- -
- - -
- -
- - -
- - - -
- -
- -
-
- - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/analysis.html b/src/main/resources/templates/analysis.html index 31b6d9b..55201dd 100644 --- a/src/main/resources/templates/analysis.html +++ b/src/main/resources/templates/analysis.html @@ -12,7 +12,7 @@ - + @@ -20,8 +20,17 @@ - - + +
カテゴリ別 支出 前月比
総支出¥234,000+¥38,000 + 0 + + 0 +
@@ -33,24 +42,42 @@ カテゴリ別 支出 - 前月比
コース比 + + 前月比 +
+ コース比 + - - 食費 - ¥34,000 - +¥8,000
+¥1,100 - - - 交通費 - ¥14,000 - +¥8,000
+¥1,100 - - - 日用品 - ¥4,000 - +¥8,000
+¥1,100 + + + + 食費 + + + + 0 + + + + + +
+ + + diff --git a/src/main/resources/templates/select_course.html b/src/main/resources/templates/select_course.html new file mode 100644 index 0000000..6718ef4 --- /dev/null +++ b/src/main/resources/templates/select_course.html @@ -0,0 +1,35 @@ + + + + +コース選択 + + + +
+
+

+ +

+
+
+ + + + 配分(%) + + + + + +
カテゴリ名
+
+
+
+
+ + + + \ No newline at end of file