File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
src/main/kotlin/nexters/weski/ski_resort Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 44### 스키장 정보 조회 API
55GET http://localhost:8080/api/ski-resorts
66
7+ ### 스키장 정보 조회 API
8+ GET http://localhost:8080/api/ski-resort/{{resortId}}
9+
710### 날씨 정보 조회 API
811GET http://localhost:8080/api/weather/{{resortId}}
912
Original file line number Diff line number Diff line change 11package nexters.weski.ski_resort
22
33import io.swagger.v3.oas.annotations.Operation
4+ import io.swagger.v3.oas.annotations.Parameter
45import io.swagger.v3.oas.annotations.tags.Tag
56import org.springframework.web.bind.annotation.GetMapping
7+ import org.springframework.web.bind.annotation.PathVariable
68import org.springframework.web.bind.annotation.RestController
79
810@Tag(name = " 전체 스키장 정보 API" , description = " 전체 스키장 날씨 및 슬로프 정보 관련" )
@@ -15,4 +17,13 @@ class SkiResortController(
1517 fun getAllSkiResorts (): List <SkiResortResponseDto > {
1618 return skiResortService.getAllSkiResortsAndWeather()
1719 }
20+
21+ @Operation(summary = " 날씨와 슬로프 정보를 포함한 특정 스키장 데이터를 조회하는 API" )
22+ @GetMapping(" /api/ski-resort/{resortId}" )
23+ fun getSkiResort (
24+ @Parameter(description = " 스키장 ID" , example = " 1" )
25+ @PathVariable resortId : Long
26+ ): SkiResortResponseDto {
27+ return skiResortService.getSkiResortAndWeather(resortId)
28+ }
1829}
Original file line number Diff line number Diff line change @@ -22,6 +22,16 @@ class SkiResortService(
2222 }
2323 }
2424
25+ fun getSkiResortAndWeather (resortId : Long ): SkiResortResponseDto {
26+ val skiResort = skiResortRepository.findById(resortId)
27+ .orElseThrow { IllegalArgumentException (" 해당 ID의 스키장이 존재하지 않습니다." ) }
28+
29+ val currentWeather = currentWeatherRepository.findBySkiResortResortId(skiResort.resortId)
30+ val weeklyWeather = dailyWeatherRepository.findAllBySkiResortResortId(skiResort.resortId)
31+
32+ return SkiResortResponseDto .fromEntity(skiResort, currentWeather, weeklyWeather)
33+ }
34+
2535 fun updateResortDate (resortId : Long , dateType : DateType , date : LocalDate ) {
2636 val skiResort = skiResortRepository.findById(resortId)
2737 .orElseThrow { IllegalArgumentException (" 해당 ID의 스키장이 존재하지 않습니다." ) }
You can’t perform that action at this time.
0 commit comments