“mitao”
2026-05-16 c556e46c2a6232d74ab6dbf7566479ec955d905d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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);
 
    @Query("select p from Project p where ( :name is null or :name = '' or p.name like %:name% ) " +
 
            "and p.deleted = false " +
            "order by p.updateTime desc")
    List<Project> findAllByTitleIdAndDeleted(String name);
 
}