Merge branch 's-choi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/Monegement into n-kawahito
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ public class GoalEntity {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "goal_id")
|
@Column(name = "goal_id")
|
||||||
private Integer goalId;
|
private Long goalId;
|
||||||
|
|
||||||
@Column(name = "goal_title", nullable = true)
|
@Column(name = "goal_title", nullable = true)
|
||||||
private String goalTitle;
|
private String goalTitle;
|
||||||
|
|||||||
@@ -13,19 +13,20 @@ public interface AllocationRepository extends JpaRepository<AllocationEntity, Al
|
|||||||
|
|
||||||
List<AllocationEntity> findByCourseEntity_CourseId(Long courseId);
|
List<AllocationEntity> findByCourseEntity_CourseId(Long courseId);
|
||||||
|
|
||||||
@Query(" SELECT co.course_id, "
|
@Query(" SELECT new com.example.demo.app.domain.model.CourseInfoModel("
|
||||||
+ " co.course_name, "
|
+ "co.courseId, "
|
||||||
+ " ca.category_id, "
|
+ " co.courseName, "
|
||||||
+ " ca.categpry_name, "
|
+ " ca.categoryId, "
|
||||||
+ " a.allocation_ratio "
|
+ " ca.categoryName, "
|
||||||
+ " FROM allocation_m a "
|
+ " a.allocationRatio )"
|
||||||
+ " INNER JOIN course_m co "
|
+ " FROM AllocationEntity a"
|
||||||
+ " ON a.course_id = co.course_id "
|
+ " INNER JOIN CourseEntity co "
|
||||||
+ " INNER JOIN category_t ca "
|
+ " ON a.courseEntity.courseId = co.courseId "
|
||||||
+ " on a.category_id = ca.category_id "
|
+ " INNER JOIN CategoryEntity ca "
|
||||||
+ " WHERE ca.transaction_type = 0 "
|
+ " on a.categoryEntity.categoryId = ca.categoryId "
|
||||||
+ " ORDER BY a.course_id ASC, "
|
+ " WHERE ca.transactionType = 0 "
|
||||||
+ " a.category_id ASC ")
|
+ " ORDER BY a.courseEntity.courseId ASC, "
|
||||||
|
+ " a.categoryEntity.categoryId ASC ")
|
||||||
List<CourseInfoModel> findAllJoinedAllocation();
|
List<CourseInfoModel> findAllJoinedAllocation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ public interface TransactionRepository extends JpaRepository<TransactionEntity,
|
|||||||
@Query("select t from TransactionEntity t where t.userEntity.userId = :userId and t.transactionDate = :transactionDate")
|
@Query("select t from TransactionEntity t where t.userEntity.userId = :userId and t.transactionDate = :transactionDate")
|
||||||
public List<TransactionEntity> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
public List<TransactionEntity> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
||||||
|
|
||||||
@Query("select t from TransactionEntity t where (t.transactionDate between :startDate and :endDate) and (t.userId = :userId) order by t.transactionDate asc")
|
@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);
|
public List<TransactionEntity> findAllByDateAndUserId(LocalDate startDate, LocalDate endDate, Long userId);
|
||||||
|
|
||||||
@Query("select sum(t.amount) from TransactionEntity t inner join CategoryEntity c on t.categoryId = c.categoryId where (t.userId = :userId and t.transactionDate between :startDate and :endDate) and c.transactionType = 0")
|
@Query("select sum(t.amount) from TransactionEntity t inner join CategoryEntity c on t.categoryEntity.categoryId = c.categoryId where (t.userEntity.userId = :userId and t.transactionDate between :startDate and :endDate) and c.transactionType = 0")
|
||||||
public Integer findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId);
|
public Integer findTotalExpense(LocalDate startDate, LocalDate endDate, Long userId);
|
||||||
|
|
||||||
@Query("select sum(t.amount) from TransactionEntity t inner join CategoryEntity c on t.categoryId = c.categoryId where (t.userId = :userId and t.transactionDate between :startDate and :endDate) and c.transactionType = 1")
|
@Query("select sum(t.amount) from TransactionEntity t inner join CategoryEntity c on t.categoryEntity.categoryId = c.categoryId where (t.userEntity.userId = :userId and t.transactionDate between :startDate and :endDate) and c.transactionType = 1")
|
||||||
public Integer findTotalIncome(LocalDate startDate, LocalDate endDate, Long userId);
|
public Integer findTotalIncome(LocalDate startDate, LocalDate endDate, Long userId);
|
||||||
|
|
||||||
@Query("select sum(t.amount) from TransactionEntity t where t.userEntity.userId = :userId and t.categoryEntity.categoryId = :categoryId and t.transactionDate between :startDate and :endDate")
|
@Query("select sum(t.amount) from TransactionEntity t where t.userEntity.userId = :userId and t.categoryEntity.categoryId = :categoryId and t.transactionDate between :startDate and :endDate")
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class TransactionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 詳細画面
|
// 詳細画面
|
||||||
@GetMapping()
|
@GetMapping("/transaction/detail")
|
||||||
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
|
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
|
||||||
|
|
||||||
LocalDate todayDate = (todayDates == null) ? LocalDate.now() : todayDates;
|
LocalDate todayDate = (todayDates == null) ? LocalDate.now() : todayDates;
|
||||||
@@ -93,13 +93,13 @@ public class TransactionController {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("")
|
@GetMapping("/transaction/create")
|
||||||
public String createOneGet(@ModelAttribute TransactionForm transactionForm) {
|
public String createOneGet(@ModelAttribute TransactionForm transactionForm) {
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping()
|
@PostMapping("/transaction/create")
|
||||||
public String createOnePost(@ModelAttribute TransactionForm transactionForm, Model model) {
|
public String createOnePost(@ModelAttribute TransactionForm transactionForm, Model model) {
|
||||||
|
|
||||||
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
if (transactionService.createTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||||
@@ -110,13 +110,13 @@ public class TransactionController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("")
|
@GetMapping("/transaction/update")
|
||||||
public String updateOneGet(@ModelAttribute TransactionForm transactionForm) {
|
public String updateOneGet(@ModelAttribute TransactionForm transactionForm) {
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping()
|
@PostMapping("/transaction/update")
|
||||||
public String updateOnePost(@ModelAttribute TransactionForm transactionForm, Model model) {
|
public String updateOnePost(@ModelAttribute TransactionForm transactionForm, Model model) {
|
||||||
|
|
||||||
if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
if (transactionService.updateTransaction(TransactionForm.convertTo(transactionForm)) != 0) {
|
||||||
|
|||||||
@@ -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.getCategoryId(), 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user