[EDIT] 該当テーブルの収支の情報を取得するメソッドを追加しました。
This commit is contained in:
@@ -10,6 +10,8 @@ import com.example.demo.app.presentation.form.Income;
|
|||||||
|
|
||||||
public interface TransactionService {
|
public interface TransactionService {
|
||||||
|
|
||||||
|
public TransactionModel findByTransactionId(Long transactionId);
|
||||||
|
|
||||||
public Map<LocalDate, List<TransactionModel>> findAllByDate(LocalDate startDate, LocalDate endDate, Long userId);
|
public Map<LocalDate, List<TransactionModel>> findAllByDate(LocalDate startDate, LocalDate endDate, Long userId);
|
||||||
|
|
||||||
public List<TransactionModel> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
public List<TransactionModel> findByUserIdAndDate(LocalDate todayDate, Long userId);
|
||||||
@@ -18,6 +20,8 @@ public interface TransactionService {
|
|||||||
|
|
||||||
public int findTotalExpense(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 createTransaction(TransactionModel transactionModel);
|
||||||
|
|
||||||
public int updateTransaction(TransactionModel transactionModel);
|
public int updateTransaction(TransactionModel transactionModel);
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ public class TransactionServiceImpl implements TransactionService {
|
|||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final CategoryRepository categoryRepository;
|
private final CategoryRepository categoryRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public TransactionModel findByTransactionId(Long transactionId) {
|
||||||
|
|
||||||
|
return TransactionModel.convertFrom(transactionRepository.findById(transactionId).get());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Map<LocalDate, List<TransactionModel>> findAllByDate(
|
public Map<LocalDate, List<TransactionModel>> findAllByDate(
|
||||||
LocalDate startDate,
|
LocalDate startDate,
|
||||||
LocalDate endDate,
|
LocalDate endDate,
|
||||||
@@ -92,6 +99,11 @@ public class TransactionServiceImpl implements TransactionService {
|
|||||||
return TransactionModel.convertFrom(transactionRepository.findByUserIdAndDate(todayDate, userId));
|
return TransactionModel.convertFrom(transactionRepository.findByUserIdAndDate(todayDate, userId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int findMoneyRecord(Long transactionId) {
|
||||||
|
return transactionRepository.findMoneyRecord(transactionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int createTransaction(TransactionModel transactionModel) {
|
public int createTransaction(TransactionModel transactionModel) {
|
||||||
|
|
||||||
|
|||||||
@@ -33,5 +33,7 @@ public interface TransactionRepository extends JpaRepository<TransactionEntity,
|
|||||||
@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")
|
@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);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user