package space.nstart.pcp.slots_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.slots_service.entity.BookedRequestEntity

interface BookedRequestRepository : JpaRepository<BookedRequestEntity, Long>{

    @Modifying
    @Transactional
    @Query("DELETE FROM  booked_slot_request WHERE booked_slot_request_id =:id", nativeQuery = true)
    fun deleteByBookedSlotRequestId(@Param("id") id : Long) : Int

    fun findByBookedSlot_BookedSlotIdAndRequestId(slotId:Long, requestId:String): BookedRequestEntity?

    fun findByRequestId(requestId:String): List<BookedRequestEntity>
}