package com.estate.expert.admin.domain.plan;
|
|
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 PlanRepository extends EntityBaseRepository<Plan> {
|
|
@Query("select p from Plan p " +
|
"where (:clientId is null or p.client.id = :clientId) and p.deleted = false")
|
List<Plan> findAllByClientId(Integer clientId);
|
|
@Query("select p from Plan p where ( :keyword is null or :keyword = '' or p.name like %:keyword%) " +
|
"and (coalesce(:planTypes, null) is null or p.type in :planTypes) " +
|
"and (coalesce(:planStates, null) is null or p.state in :planStates) " +
|
"and (coalesce(:clientIds, null) is null or p.client.id in :clientIds) " +
|
"and (coalesce(:planIds, null) is null or p.id in :planIds) " +
|
"and p.deleted = false " +
|
"or (p.deleted = false and (:userId is null or p.creator.id = :userId)) " +
|
"order by p.updateTime desc")
|
Page<Plan> myPlans(@Param("keyword") String keyword,
|
@Param("planTypes") List<PlanType> planTypes,
|
@Param("planStates") List<PlanState> planStates,
|
@Param("clientIds") List<Integer> clientIds,
|
@Param("userId") Integer userId,
|
@Param("planIds") List<Integer> planIds,
|
Pageable page);
|
|
@Query("select p from Plan p where ( :keyword is null or :keyword = '' or p.name like %:keyword%) " +
|
"and (coalesce(:planTypes, null) is null or p.type in :planTypes) " +
|
"and (coalesce(:planStates, null) is null or p.state in :planStates) " +
|
"and (coalesce(:clientIds, null) is null or p.client.id in :clientIds) " +
|
"and (coalesce(:planIds, null) is null or p.id in :planIds) " +
|
"and (:creatorId is null or p.creator.id = :creatorId) " +
|
"and p.deleted = false " +
|
"order by p.updateTime desc")
|
Page<Plan> findPlans(@Param("keyword") String keyword,
|
@Param("planTypes") List<PlanType> planTypes,
|
@Param("planStates") List<PlanState> planStates,
|
@Param("clientIds") List<Integer> clientIds,
|
@Param("creatorId") Integer creatorId,
|
@Param("planIds") List<Integer> planIds,
|
Pageable page);
|
|
@Query("select p from Plan p where ( :keyword is null or :keyword = '' or p.name like %:keyword%) " +
|
"and (coalesce(:planTypes, null) is null or p.type in :planTypes) " +
|
"and (coalesce(:planStates, null) is null or p.state in :planStates) " +
|
"and (coalesce(:clientIds, null) is null or p.client.id in :clientIds) " +
|
"and (coalesce(:planIds, null) is null or p.id in :planIds) " +
|
"and (:creatorId is null or p.creator.id = :creatorId) " +
|
"and p.deleted = false " +
|
"order by p.updateTime desc")
|
List<Plan> findPlans(@Param("keyword") String keyword,
|
@Param("planTypes") List<PlanType> planTypes,
|
@Param("planStates") List<PlanState> planStates,
|
@Param("clientIds") List<Integer> clientIds,
|
@Param("creatorId") Integer creatorId,
|
@Param("planIds") List<Integer> planIds);
|
|
}
|