ContractRepaymentRepository.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.loan.system.repository;
  2. import com.loan.system.domain.entity.ApprovalRecord;
  3. import com.loan.system.domain.entity.ContractRepayment;
  4. import org.springframework.data.jpa.repository.JpaRepository;
  5. import org.springframework.data.jpa.repository.Modifying;
  6. import org.springframework.data.jpa.repository.Query;
  7. import org.springframework.transaction.annotation.Transactional;
  8. import java.util.List;
  9. /**
  10. * @author EdwinXu
  11. * @date 2020/9/2 - 15:35
  12. * @Description
  13. */
  14. public interface ContractRepaymentRepository extends JpaRepository<ContractRepayment,Long> {
  15. @Query("select c.id from ContractRepayment c where c.repaymentRecordId = ?1 and c.isDelete = ?2")
  16. List<Long> findByRepaymentRecordIdAndIsDelete(Long recordId, boolean b);
  17. @Modifying
  18. @Transactional
  19. @Query("update ContractRepayment c set c.isDelete = true where c.id in ?1")
  20. void deleteByIds(List<Long> ids);
  21. @Query("select c from ContractRepayment c where c.repaymentRecordId in ?1 and c.isDelete = ?2")
  22. List<ContractRepayment> findByRepaymentRecordIdsAndIsDelete(List<Long> recordIds, boolean b);
  23. @Query("select c from ContractRepayment c where c.contractId = ?1 and c.isDelete = ?2")
  24. List<ContractRepayment> findByContractIdAndIsDelete(Long id, boolean b);
  25. @Query("select c from ContractRepayment c where c.repaymentRecordId = ?1 and c.isDelete = ?2")
  26. List<ContractRepayment> findDataByRepaymentRecordIdAndIsDelete(Long recordId, boolean b);
  27. @Query("select c.contractId from ContractRepayment c where c.repaymentRecordId = ?1 and c.isDelete = ?2 order by c.createTime asc")
  28. List<Long> findContractIdsByRepaymentId(Long recordId, boolean b);
  29. @Modifying
  30. @Transactional
  31. @Query("update ContractRepayment c set c.amount = ?1 where c.contractId = ?2 and c.repaymentRecordId = ?3")
  32. void updateAmountByRecordIdAndContractId(Double amount, Long contractId, Long recordId);
  33. }