liujie
2026-01-14 f976a39b294f8c7dd60bcd2c661983c0dcc97fc6
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
47
48
package com.estate.expert.admin.domain.standard.problem;
 
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;
 
import java.util.List;
 
public interface ProblemRepository extends EntityBaseRepository<Problem> {
 
    @Query("select p from Problem p where p.hierarchyId = :hierarchyId " +
            "and p.hierarchyPath in :hierarchyPaths " +
            "and (:keyword is null or :keyword = '' or p.description like %:keyword% ) " +
            "and p.deleted = false")
    Page<Problem> findProblems(@Param("hierarchyId") Integer hierarchyId,
                               @Param("hierarchyPaths") List<String> hierarchyPaths,
                               @Param("keyword") String keyword,
                               Pageable pageReq);
 
 
    @Query("select distinct(p.id) from Problem p where p.hierarchyId = :hierarchyId " +
            "and (p.hierarchyPath in :ps) " +
            "and p.deleted = false")
    List<Integer> findProblemIds(@Param("hierarchyId") Integer hierarchyId,
                                 @Param("ps") List<String> hierarchyPaths);
 
    @Query("select distinct(p.id) from Problem p where p.hierarchyId = :hierarchyId and p.deleted = false")
    List<Integer> findAllProblemIds(@Param("hierarchyId") Integer hierarchyId);
 
    List<Problem> findAllByHierarchyIdAndDeleted(Integer hierarchyId, boolean deleted);
 
 
    @Query("select p from Problem p where p.hierarchyId = :hierarchyId " +
            "and (p.hierarchyPath in :hierarchyPaths) " +
            "and (p.id in :problemIds) " +
            "and p.deleted = false")
    List<Problem> findProblems(@Param("hierarchyId") Integer hierarchyId,
                               @Param("hierarchyPaths") List<String> hierarchyPaths,
                               @Param("problemIds") List<Integer> problemIds);
 
    @Query("select p from Problem p where p.hierarchyId = :hierarchyId " +
            "and (p.hierarchyPath in :hierarchyPaths) " +
            "and p.deleted = false")
    List<Problem> findProblems(@Param("hierarchyId") Integer hierarchyId,
                               @Param("hierarchyPaths") List<String> hierarchyPaths);
}