From 9f3c116f6c0593229f9886aac97d3834bf0b0c74 Mon Sep 17 00:00:00 2001 From: YoungJun Park Date: Mon, 18 Nov 2024 13:45:41 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Change:=20sorting=20criteria=20for?= =?UTF-8?q?=20ski=20resort=20query=20(by=20ID=20=E2=86=92=20by=20opening?= =?UTF-8?q?=20date)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #25 --- .../kotlin/nexters/weski/ski_resort/SkiResortRepository.kt | 4 +++- src/main/kotlin/nexters/weski/ski_resort/SkiResortService.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/nexters/weski/ski_resort/SkiResortRepository.kt b/src/main/kotlin/nexters/weski/ski_resort/SkiResortRepository.kt index df2840b..181eb96 100644 --- a/src/main/kotlin/nexters/weski/ski_resort/SkiResortRepository.kt +++ b/src/main/kotlin/nexters/weski/ski_resort/SkiResortRepository.kt @@ -2,4 +2,6 @@ package nexters.weski.ski_resort import org.springframework.data.jpa.repository.JpaRepository -interface SkiResortRepository : JpaRepository \ No newline at end of file +interface SkiResortRepository : JpaRepository { + fun findAllByOrderByOpeningDateAsc(): List +} \ No newline at end of file diff --git a/src/main/kotlin/nexters/weski/ski_resort/SkiResortService.kt b/src/main/kotlin/nexters/weski/ski_resort/SkiResortService.kt index c31e4ee..37fad5e 100644 --- a/src/main/kotlin/nexters/weski/ski_resort/SkiResortService.kt +++ b/src/main/kotlin/nexters/weski/ski_resort/SkiResortService.kt @@ -11,7 +11,7 @@ class SkiResortService( private val dailyWeatherRepository: DailyWeatherRepository ) { fun getAllSkiResortsAndWeather(): List { - val skiResorts = skiResortRepository.findAll() + val skiResorts = skiResortRepository.findAllByOrderByOpeningDateAsc() return skiResorts.map { skiResort -> val currentWeather = currentWeatherRepository.findBySkiResortResortId(skiResort.resortId) val weeklyWeather = dailyWeatherRepository.findAllBySkiResortResortId(skiResort.resortId)