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.AscNodeEntity
import java.time.LocalDateTime


interface AscNodeRepository : JpaRepository<AscNodeEntity, Long>{

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


    fun findBySatelliteId(id : Long) : List<AscNodeEntity>

    fun findBySatelliteIdAndTimeBetween(id : Long, t1 : LocalDateTime, t2 : LocalDateTime) : List<AscNodeEntity>

    fun findBySatelliteIdAndTimeAfter(id : Long, t : LocalDateTime): List<AscNodeEntity>

    fun findBySatelliteIdAndTimeBefore(id : Long, t : LocalDateTime): List<AscNodeEntity>
}