package space.nstart.pcp.pcp_stations_service.controller

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
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.RestController
import space.nstart.pcp.pcp_stations_service.service.StationService
import space.nstart.pcp.pcp_types_lib.dto.ballistics.StationDTO
import java.util.UUID


@RestController
@RequestMapping("api/stations")
class StationController {

    @Autowired
    private lateinit var stationService: StationService

    @GetMapping()
    fun all() = stationService.all()

    @GetMapping("/{station_id}")
    fun byId(@PathVariable("station_id") id : UUID): StationDTO = stationService.byId(id)

    @PostMapping()
    fun add(@RequestBody body : StationDTO): StationDTO = stationService.add(body)

    @DeleteMapping("{station_id}")
    fun delete(@PathVariable("station_id") id : UUID): Int = stationService.delete(id)
}
