package com.hiveops.aria.repository;

import com.hiveops.aria.entity.ThreatEvent;
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.List;
import java.util.UUID;

@Repository
public interface ThreatEventRepository extends JpaRepository<ThreatEvent, Long> {

    Page<ThreatEvent> findByDeviceAgentIdOrderByDetectedAtDesc(String deviceAgentId, Pageable pageable);

    List<ThreatEvent> findBySequenceId(UUID sequenceId);

    List<ThreatEvent> findByDeviceAgentIdAndDetectedAtAfterOrderByDetectedAtAsc(
            String deviceAgentId, Instant since);

    Page<ThreatEvent> findBySeverityOrderByDetectedAtDesc(ThreatEvent.ThreatSeverity severity, Pageable pageable);

    Page<ThreatEvent> findAllByOrderByDetectedAtDesc(Pageable pageable);
}
