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);
|
}
|