package space.nstart.pcp.slots_service.controller

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import space.nstart.pcp.pcp_types_lib.dto.requests.slots.SatelliteMissionBatchRequestDTO
import space.nstart.pcp.slots_service.service.SlotService
import java.time.LocalDateTime

@RestController
@RequestMapping("/api/slots/mission")
class MissionController {

    @Autowired
    private lateinit var slotService: SlotService

    @GetMapping("/satellite")
    fun bySatelliteAndInterval(
        @RequestParam("satellite_id") satelliteId: Long,
        @RequestParam timeStart: LocalDateTime,
        @RequestParam timeStop: LocalDateTime
    ) = slotService.bookedBySatelliteAndInterval(satelliteId, timeStart, timeStop)

    @PostMapping("/satellites")
    fun bySatellitesAndInterval(@RequestBody body: SatelliteMissionBatchRequestDTO) =
        slotService.bookedBySatellitesAndInterval(body.satelliteIds, body.timeStart, body.timeStop)
}
