package com.loan.system.repository; import com.loan.system.domain.entity.ApprovalRecord; import com.loan.system.domain.entity.ContractRepayment; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * @author EdwinXu * @date 2020/9/2 - 15:35 * @Description */ public interface ContractRepaymentRepository extends JpaRepository { @Query("select c.id from ContractRepayment c where c.repaymentRecordId = ?1 and c.isDelete = ?2") List findByRepaymentRecordIdAndIsDelete(Long recordId, boolean b); @Modifying @Transactional @Query("update ContractRepayment c set c.isDelete = true where c.id in ?1") void deleteByIds(List ids); @Query("select c from ContractRepayment c where c.repaymentRecordId in ?1 and c.isDelete = ?2") List findByRepaymentRecordIdsAndIsDelete(List recordIds, boolean b); @Query("select c from ContractRepayment c where c.contractId = ?1 and c.isDelete = ?2") List findByContractIdAndIsDelete(Long id, boolean b); @Query("select c from ContractRepayment c where c.repaymentRecordId = ?1 and c.isDelete = ?2") List findDataByRepaymentRecordIdAndIsDelete(Long recordId, boolean b); @Query("select c.contractId from ContractRepayment c where c.repaymentRecordId = ?1 and c.isDelete = ?2 order by c.createTime asc") List findContractIdsByRepaymentId(Long recordId, boolean b); @Modifying @Transactional @Query("update ContractRepayment c set c.amount = ?1 where c.contractId = ?2 and c.repaymentRecordId = ?3") void updateAmountByRecordIdAndContractId(Double amount, Long contractId, Long recordId); }