package br.gov.sigefp.common.repository;

import br.gov.sigefp.common.domain.AuditLog;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.Instant;
import java.util.UUID;

@Repository
public interface AuditLogRepository extends JpaRepository<AuditLog, UUID> {

    Page<AuditLog> findByUserId(UUID userId, Pageable pageable);

    Page<AuditLog> findByModule(String module, Pageable pageable);

    Page<AuditLog> findByCreatedAtBetween(Instant start, Instant end, Pageable pageable);

    Page<AuditLog> findByUserIdAndModule(UUID userId, String module, Pageable pageable);

    Page<AuditLog> findByUserIdAndModuleAndCreatedAtBetween(UUID userId, String module, Instant start, Instant end,
            Pageable pageable);
}
