package ru.soune.nocopy.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import ru.soune.nocopy.entity.file.moderation.ModerationLog;

import java.util.List;

public interface ModerationLogRepository extends JpaRepository<ModerationLog, String> {

    List<ModerationLog> findByFileIdOrderByCreatedAtDesc(String fileId);

    List<ModerationLog> findByModeratorId(Long moderatorId);

    List<ModerationLog> findByFileId(String fileId);

    @Modifying
    @Transactional
    @Query("DELETE FROM ModerationLog m WHERE m.fileId IN :fileIds")
    void deleteAllByFileIdIn(@Param("fileIds") List<String> fileIds);
}