-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Nexters/feature/32-slope-operation-update
[#32] 스키장 슬로프 운영현황 업데이트 API, 운영 슬로프 개수 업데이트 Batch 개발
- Loading branch information
Showing
9 changed files
with
163 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/kotlin/nexters/weski/batch/SlopeBatchController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package nexters.weski.batch | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.media.Content | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import nexters.weski.ski_resort.SkiResortService | ||
import nexters.weski.slope.SlopeService | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@Tag(name = "슬로프 데이터 업데이트 API", description = "스키장 슬로프 데이터를 업데이트") | ||
@RestController | ||
class SlopeBatchController( | ||
private val slopeService: SlopeService, | ||
private val resortService: SkiResortService | ||
) { | ||
@Operation( | ||
summary = "스키장 슬로프 운영 현황 업데이트 API", | ||
description = """ | ||
스키장 id, 슬로프 이름, 주간/야간/심야/새벽/자정, 운영 여부를 파라미터로 전달해서 업데이트합니다. | ||
resortId는 다음과 같습니다. | ||
1, 지산 리조트 | ||
2, 곤지암 스키장 | ||
3, 비발디파크 | ||
4, 엘리시안 강촌 | ||
5, 웰리힐리파크 | ||
6, 휘닉스파크 | ||
7, 하이원 스키장 | ||
8, 용평스키장 모나 | ||
9, 무주덕유산 | ||
10, 에덴벨리(양산) | ||
11, 오투리조트 | ||
""" | ||
) | ||
@PostMapping("/batch/slope-status") | ||
fun updateSlopeStatus( | ||
@RequestBody | ||
@io.swagger.v3.oas.annotations.parameters.RequestBody( | ||
description = "slopes 운영여부 업데이트 요청", | ||
required = true, | ||
content = [Content( | ||
mediaType = "application/json", | ||
schema = Schema(implementation = SlopeDateUpdateRequest::class) | ||
)] | ||
) | ||
request: SlopeDateUpdateRequest | ||
) { | ||
slopeService.updateSlopeOpeningStatus( | ||
resortId = request.resortId, | ||
slopeName = request.slopeName, | ||
timeType = request.timeType, | ||
isOpen = request.isOpen | ||
) | ||
} | ||
|
||
@Operation( | ||
summary = "스키장 슬로프 count 업데이트", | ||
description = "스키장의 슬로프 count가 업데이트됩니다." | ||
) | ||
@PostMapping("/batch/resort-slope-count") | ||
fun updateSlopeCount() { | ||
resortService.updateSkiResortSlopeCount() | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/nexters/weski/batch/SlopeDateUpdateRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package nexters.weski.batch | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
import java.time.LocalDate | ||
|
||
class SlopeDateUpdateRequest ( | ||
@Schema( | ||
description = "스키장 ID", | ||
example = "1" | ||
) | ||
val resortId: Long, | ||
|
||
@Schema( | ||
description = "슬로프 이름", | ||
example = "레몬1" | ||
) | ||
val slopeName: String, | ||
|
||
@Schema( | ||
description = "주간/야간/심야/새벽/자정 중 하나", | ||
example = "주간" | ||
) | ||
val timeType: String, | ||
|
||
@Schema( | ||
description = "운영 여부(Y/N)", | ||
example = "Y" | ||
) | ||
val isOpen: String, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
package nexters.weski.slope | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
|
||
interface SlopeRepository : JpaRepository<Slope, Long> { | ||
fun findAllBySkiResortResortId(resortId: Long): List<Slope> | ||
fun countBySkiResortResortId(resortId: Long): Int | ||
fun findBySkiResortResortIdAndName(resortId: Long, name: String): Slope? | ||
|
||
@Query(""" | ||
SELECT COUNT(s) | ||
FROM Slope s | ||
WHERE s.skiResort.resortId = :resortId | ||
AND (s.isDayOperating = true | ||
OR s.isNightOperating = true | ||
OR s.isLateNightOperating = true | ||
OR s.isDawnOperating = true | ||
OR s.isMidnightOperating = true) | ||
""") | ||
fun countOperatingSlopesByResortId(resortId: Long): Int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters