package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ViewedPageEntity;

public interface ViewedPagesRepository extends JpaRepository<ViewedPageEntity, ViewedPageEntity.ViewedPageId> {

    void deleteByFileId(String fileId);


    List<ViewedPageEntity> findByFileIdAndIdUserId(String fileId, String userId);


    @Modifying
    @Query("DELETE FROM ViewedPageEntity e where e.id.fileId = :fileId and e.id.userId = :currentReviewer and e.id.page in :viewedPagesToReset")
    void deleteSeenPages(String fileId, String currentReviewer, List<Integer> viewedPagesToReset);

}
