package com.estate.expert.admin.domain.project;
|
|
import com.estate.expert.admin.domain.common.EntityBaseRepository;
|
import com.estate.expert.admin.domain.project.enums.ProjectType;
|
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;
|
|
import java.util.List;
|
|
public interface ProjectRepository extends EntityBaseRepository<Project> {
|
|
@Query("select p from Project p where ( :keyword is null or :keyword = '' or p.name like %:keyword% ) " +
|
"and ( coalesce(:projectTypes, null) is null or p.type in :projectTypes ) " +
|
"and ( coalesce(:clientIds, null) is null or p.client.id in :clientIds ) " +
|
"and p.deleted = false " +
|
"order by p.updateTime desc")
|
Page<Project> findProjects(@Param("keyword") String keyword,
|
@Param("projectTypes") List<ProjectType> projectTypes,
|
@Param("clientIds") List<Integer> clientIds,
|
Pageable page);
|
|
@Query("select p from Project p where ( :keyword is null or :keyword = '' or p.name like %:keyword% ) " +
|
"and ( coalesce(:projectTypes, null) is null or p.type in :projectTypes ) " +
|
"and ( coalesce(:clientIds, null) is null or p.client.id in :clientIds ) " +
|
"and p.deleted = false " +
|
"order by p.updateTime desc")
|
List<Project> findProjects(@Param("keyword") String keyword,
|
@Param("projectTypes") List<ProjectType> projectTypes,
|
@Param("clientIds") List<Integer> clientIds);
|
|
List<Project> findAllByClientIdAndDeleted(Integer clientId, boolean deleted);
|
|
|
@Query("select p.id from Project p where ( :keyword is null or :keyword = '' or p.name like %:keyword% ) " +
|
"and p.deleted = false " )
|
List<Integer> listProjectIds(@Param("keyword") String keyword);
|
|
}
|