package de.oaa.xxx.location.repository;

import de.oaa.xxx.location.entity.LocationEventEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

public interface LocationEventRepository extends JpaRepository<LocationEventEntity, UUID> {

    List<LocationEventEntity> findByLocationIdOrderByStartAtAsc(UUID locationId);

    /** Alle zukünftigen Events mit Koordinaten ihrer Location (für Umkreis-Suche) */
    @Query("""
            SELECT e FROM LocationEventEntity e
             WHERE e.startAt >= :from
               AND e.startAt <= :to
            """)
    List<LocationEventEntity> findInTimeRange(LocalDateTime from, LocalDateTime to);

    void deleteByLocationId(UUID locationId);
}
