@@ -1,6 +1,8 @@
|
||||
package ru.soune.nocopy.repository;
|
||||
|
||||
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.search.GlobalSearchResult;
|
||||
|
||||
@@ -9,5 +11,13 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface GlobalSearchResultRepository extends JpaRepository<GlobalSearchResult, Long> {
|
||||
List<GlobalSearchResult> findByTaskIdOrderByIdAsc(String taskId);
|
||||
|
||||
void deleteByTaskId(String taskId);
|
||||
|
||||
List<GlobalSearchResult> findByTaskId(String taskId);
|
||||
|
||||
@Query("SELECT g.fileId FROM GlobalSearchResult g WHERE g.taskId = :taskId")
|
||||
List<String> findFileIdsByTaskId(@Param("taskId") String taskId);
|
||||
|
||||
long countByTaskId(String taskId);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
package ru.soune.nocopy.repository;
|
||||
|
||||
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.search.GlobalSearchTask;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface GlobalSearchTaskRepository extends JpaRepository<GlobalSearchTask, String> {
|
||||
Optional<GlobalSearchTask> findByTaskIdAndUserId(String taskId, Long userId);
|
||||
|
||||
List<GlobalSearchTask> findByUserIdOrderByCreatedAtDesc(Long userId);
|
||||
|
||||
List<GlobalSearchTask> findByUserIdAndCreatedAtAfterOrderByCreatedAtDesc(Long userId, LocalDateTime date);
|
||||
|
||||
@Query("SELECT COUNT(t) FROM GlobalSearchTask t WHERE t.userId IN :userIds")
|
||||
long countByUserId(@Param("userIds") List<Long> userIds);
|
||||
|
||||
@Query("SELECT t.status, COUNT(t) FROM GlobalSearchTask t WHERE t.userId IN :userIds GROUP BY t.status")
|
||||
List<Object[]> countByStatusAndUserId(@Param("userIds") List<Long> userIds);
|
||||
|
||||
@Query("SELECT t FROM GlobalSearchTask t WHERE t.userId = :userId ORDER BY t.createdAt DESC")
|
||||
List<GlobalSearchTask> findTopByUserIdOrderByCreatedAtDesc(@Param("userId") Long userId,
|
||||
org.springframework.data.domain.Pageable pageable);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ 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.file.FileEntity;
|
||||
import ru.soune.nocopy.entity.violation.Violation;
|
||||
@@ -42,4 +44,10 @@ public interface ViolationRepository extends JpaRepository<Violation, Long> {
|
||||
List<Violation> findByFileEntityInAndCreatedDateBetween(List<FileEntity> files,
|
||||
LocalDateTime startDate,
|
||||
LocalDateTime endDate);
|
||||
|
||||
@Query("SELECT COUNT(v) FROM Violation v WHERE v.fileEntity.id IN :fileIds")
|
||||
long countByFileEntityIdIn(@Param("fileIds") List<String> fileIds);
|
||||
|
||||
@Query("SELECT COUNT(v) FROM Violation v WHERE v.globalSearchResult.taskId = :taskId")
|
||||
long countByGlobalSearchResultTaskId(@Param("taskId") String taskId);
|
||||
}
|
||||
Reference in New Issue
Block a user