@@ -0,0 +1,40 @@
|
||||
package ru.soune.nocopy.repository;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import ru.soune.nocopy.entity.complaint.LawCase;
|
||||
import ru.soune.nocopy.entity.complaint.LawCasePriority;
|
||||
import ru.soune.nocopy.entity.complaint.LawCaseType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface LawCaseRepository extends JpaRepository<LawCase, Long> {
|
||||
|
||||
@Query("SELECT l FROM LawCase l WHERE l.user.Id = :userId")
|
||||
List<LawCase> getUserLawCases(@Param("userId") Long userId, Pageable pageable);
|
||||
|
||||
// @Query("SELECT l FROM LawCase l WHERE l.user.Id = :userId " +
|
||||
// "AND (:type IS NULL OR l.type = :type) " +
|
||||
// "AND (:lawyer IS NULL OR l.lawyer = :lawyer) " +
|
||||
// "AND (:priority IS NULL OR l.priority = :priority)")
|
||||
// List<LawCase> getUserLawCases(@Param("userId") Long userId,
|
||||
// @Param("type") LawCaseType type,
|
||||
// @Param("lawyer") String lawyer,
|
||||
// @Param("priority") LawCasePriority priority,
|
||||
// Pageable pageable);
|
||||
|
||||
@Query("SELECT l FROM LawCase l WHERE l.user.Id = :userId " +
|
||||
"AND (:type IS NULL OR l.type = :type) " +
|
||||
"AND (:lawyer IS NULL OR l.lawyer = :lawyer) " +
|
||||
"AND (:priority IS NULL OR l.priority = :priority)")
|
||||
Page<LawCase> getUserLawCases(@Param("userId") Long userId,
|
||||
@Param("type") LawCaseType type,
|
||||
@Param("lawyer") String lawyer,
|
||||
@Param("priority") LawCasePriority priority,
|
||||
Pageable pageable);
|
||||
}
|
||||
Reference in New Issue
Block a user