Skip to content

Commit

Permalink
MODDCB-98 Fetch the record from audit table so that the response of t…
Browse files Browse the repository at this point in the history
…he API is immutable
  • Loading branch information
Vignesh-kalyanasundaram committed Apr 24, 2024
1 parent 15e2b89 commit e05fa02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public interface TransactionAuditRepository extends JpaRepository<TransactionAud
"and created_date = (SELECT MAX(created_date) FROM transactions_audit WHERE transaction_id = :trnId);", nativeQuery = true)
Optional<TransactionAuditEntity> findLatestTransactionAuditEntityByDcbTransactionId(@Param("trnId") String trnId);

@Query(value = "SELECT * FROM transactions_audit t WHERE t.created_date >= :fromDate AND t.created_date <= :toDate",
countQuery = "SELECT COUNT(*) FROM transactions_audit t WHERE t.created_date >= :fromDate AND t.created_date <= :toDate",
@Query(value = "SELECT * FROM transactions_audit t WHERE t.created_date >= :fromDate AND t.created_date <= :toDate AND t.action = 'UPDATE'",
countQuery = "SELECT COUNT(*) FROM transactions_audit t WHERE t.created_date >= :fromDate AND t.created_date <= :toDate AND t.action = 'UPDATE'",
nativeQuery = true)
Page<TransactionAuditEntity> findTransactionsByDateRange(OffsetDateTime fromDate, OffsetDateTime toDate, Pageable pageable);
Page<TransactionAuditEntity> findUpdatedTransactionsByDateRange(OffsetDateTime fromDate, OffsetDateTime toDate, Pageable pageable);

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public TransactionStatusResponseCollection getTransactionStatusList(OffsetDateTi
log.info("getTransactionStatusList:: fromDate {}, toDate {}, pageNumber {}, pageSize {}",
fromDate, toDate, pageNumber, pageSize);
var pageable = PageRequest.of(pageNumber, pageSize, Sort.by("created_Date"));
var transactionAuditEntityPage= transactionAuditRepository.findTransactionsByDateRange(fromDate, toDate, pageable);
var transactionAuditEntityPage= transactionAuditRepository.findUpdatedTransactionsByDateRange(fromDate, toDate, pageable);
var transactionStatusResponseList= transactionMapper.mapToDto(transactionAuditEntityPage);
return TransactionStatusResponseCollection
.builder()
Expand Down

0 comments on commit e05fa02

Please sign in to comment.