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;

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