parent
0e8d3656b2
commit
382364b5df
|
@ -14,5 +14,5 @@ data class Roulette(
|
||||||
|
|
||||||
data class RouletteItem(
|
data class RouletteItem(
|
||||||
val title: String,
|
val title: String,
|
||||||
val percentage: Int
|
val weight: Int
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,14 +43,6 @@ class RouletteService(
|
||||||
if (request.items.size < 2 || request.items.size > 6) {
|
if (request.items.size < 2 || request.items.size > 6) {
|
||||||
throw SodaException("룰렛 옵션은 최소 2개, 최대 6개까지 설정할 수 있습니다.")
|
throw SodaException("룰렛 옵션은 최소 2개, 최대 6개까지 설정할 수 있습니다.")
|
||||||
}
|
}
|
||||||
|
|
||||||
val percentage = request.items.asSequence()
|
|
||||||
.map { it.percentage }
|
|
||||||
.reduce { acc, percentage -> acc + percentage }
|
|
||||||
|
|
||||||
if (percentage != 100) {
|
|
||||||
throw SodaException("옵션 확률의 합이 100%가 아닙니다.")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRoulette(creatorId: Long): GetRouletteResponse? {
|
fun getRoulette(creatorId: Long): GetRouletteResponse? {
|
||||||
|
|
Loading…
Reference in New Issue