source: bus-n-go-pavel-216049/bus-n-go-backend/src/main/kotlin/mk/ukim/finki/busngobackend/api/LineController.kt

Last change on this file was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 4 weeks ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 971 bytes
Line 
1package mk.ukim.finki.busngobackend.api
2
3import mk.ukim.finki.busngobackend.service.DirectionService
4import mk.ukim.finki.busngobackend.service.LineService
5import mk.ukim.finki.busngobackend.service.StationService
6import org.springframework.web.bind.annotation.*
7
8@RestController
9@RequestMapping("/api/lines")
10class LineController(
11 private val lineService: LineService,
12 private val directionService: DirectionService,
13 private val stationService: StationService,
14) {
15 @GetMapping("")
16 fun getLines() = lineService.findAllLines()
17
18 @GetMapping("/{id}/directions")
19 fun getLineDirections(
20 @PathVariable("id") lineId: Int,
21 ) = directionService.findDirectionsByLineId(lineId)
22
23 @GetMapping("/{lineId}/stations")
24 fun getLineStations(
25 @PathVariable("lineId") lineId: Int,
26 @RequestParam("directionId", required = false) directionId: Long,
27 ) = stationService.findStationsByLineIdAndDirectionId(lineId, directionId)
28}
Note: See TracBrowser for help on using the repository browser.