package space.nstart.pcp.pcp_request_service.repository

import jakarta.transaction.Transactional
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 space.nstart.pcp.pcp_request_service.entity.EarthCoverageEntity
import java.time.LocalDateTime


interface EarthCoverageRepository : JpaRepository<EarthCoverageEntity, Long>{

    @Modifying
    @Transactional
    @Query("DELETE FROM  earth_coverage WHERE satellite_id =:sat", nativeQuery = true)
    fun deleteBySatId(@Param("sat") sat : Long) : Int


    fun findBySatelliteIdAndTStartGreaterThanAndTStopLessThanAndCellNumberIn
                (id : Long, tn : LocalDateTime, tk: LocalDateTime, cells : List<Long>) : List<EarthCoverageEntity>
}