package com.estate.expert.admin.domain.business.contract; import com.estate.expert.admin.domain.business.client.ClientType; import com.estate.expert.admin.domain.common.EntityBaseRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; public interface ContractRepository extends EntityBaseRepository { @Query("select c from Contract c where ( :keyword is null or :keyword = '' or c.name like %:keyword% " + "or c.creator.name like %:keyword% ) " + "and (c.client is null or :clientType is null or c.client.type = :clientType) " + "and (:creatorId is null or c.creator.id = :creatorId)" + "and c.deleted = false " + "order by c.updateTime desc") Page findContracts( @Param("keyword") String keyword, @Param("clientType") ClientType clientType, @Param("creatorId") Integer creatorId, Pageable page); }