package com.loan.system.repository;

import com.loan.system.domain.entity.Collateral;
import com.loan.system.domain.entity.ContractAndCollateral;
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 ContractAndCollateralRepository extends JpaRepository<ContractAndCollateral,Long> {

    @Transactional
    @Modifying
    @Query("delete from ContractAndCollateral c where c.caseId = ?1")
    void deleteAllByCaseId(Long caseId);

    List<ContractAndCollateral> findByCaseIdAndIsDelete(Long caseId, Boolean isDelete);
}