test #134
|
@ -1,12 +1,14 @@
|
||||||
package kr.co.vividnext.sodalive.live.roulette
|
package kr.co.vividnext.sodalive.live.roulette
|
||||||
|
|
||||||
import org.springframework.data.redis.core.RedisHash
|
import org.springframework.data.redis.core.RedisHash
|
||||||
|
import org.springframework.data.redis.core.index.Indexed
|
||||||
import javax.persistence.Id
|
import javax.persistence.Id
|
||||||
|
|
||||||
@RedisHash("newRoulette")
|
@RedisHash("newRoulette")
|
||||||
data class NewRoulette(
|
data class NewRoulette(
|
||||||
@Id
|
@Id
|
||||||
val id: Long,
|
val id: Long,
|
||||||
|
@Indexed
|
||||||
val creatorId: Long,
|
val creatorId: Long,
|
||||||
var can: Int,
|
var can: Int,
|
||||||
var isActive: Boolean,
|
var isActive: Boolean,
|
||||||
|
|
|
@ -3,6 +3,6 @@ package kr.co.vividnext.sodalive.live.roulette
|
||||||
import org.springframework.data.repository.CrudRepository
|
import org.springframework.data.repository.CrudRepository
|
||||||
|
|
||||||
interface NewRouletteRepository : CrudRepository<NewRoulette, Long> {
|
interface NewRouletteRepository : CrudRepository<NewRoulette, Long> {
|
||||||
fun findAllByCreatorId(creatorId: Long): List<NewRoulette>
|
fun findByCreatorId(creatorId: Long): List<NewRoulette>
|
||||||
fun findAllByCreatorIdAndActive(creatorId: Long, isActive: Boolean): List<NewRoulette>
|
fun findByCreatorIdAndActive(creatorId: Long, isActive: Boolean): List<NewRoulette>
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class NewRouletteService(
|
||||||
fun getAllRoulette(creatorId: Long, memberId: Long): List<GetNewRouletteResponse> {
|
fun getAllRoulette(creatorId: Long, memberId: Long): List<GetNewRouletteResponse> {
|
||||||
if (creatorId != memberId) throw SodaException("잘못된 요청입니다.")
|
if (creatorId != memberId) throw SodaException("잘못된 요청입니다.")
|
||||||
|
|
||||||
var rouletteList = repository.findAllByCreatorId(creatorId)
|
var rouletteList = repository.findByCreatorId(creatorId)
|
||||||
println(rouletteList)
|
println(rouletteList)
|
||||||
if (rouletteList.isEmpty()) {
|
if (rouletteList.isEmpty()) {
|
||||||
val roulette = oldRepository.findByIdOrNull(creatorId)
|
val roulette = oldRepository.findByIdOrNull(creatorId)
|
||||||
|
@ -54,7 +54,7 @@ class NewRouletteService(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
rouletteList = repository.findAllByCreatorId(creatorId)
|
rouletteList = repository.findByCreatorId(creatorId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class NewRouletteService(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRoulette(creatorId: Long, memberId: Long): GetRouletteResponse {
|
fun getRoulette(creatorId: Long, memberId: Long): GetRouletteResponse {
|
||||||
val roulette = repository.findAllByCreatorIdAndActive(creatorId = creatorId, isActive = true)
|
val roulette = repository.findByCreatorIdAndActive(creatorId = creatorId, isActive = true)
|
||||||
|
|
||||||
if (roulette.isEmpty() || !roulette[0].isActive || roulette[0].items.isEmpty()) {
|
if (roulette.isEmpty() || !roulette[0].isActive || roulette[0].items.isEmpty()) {
|
||||||
throw SodaException("룰렛을 사용할 수 없습니다.")
|
throw SodaException("룰렛을 사용할 수 없습니다.")
|
||||||
|
@ -134,7 +134,7 @@ class NewRouletteService(
|
||||||
}
|
}
|
||||||
|
|
||||||
// STEP 2 - 룰렛 데이터 가져오기
|
// STEP 2 - 룰렛 데이터 가져오기
|
||||||
val rouletteList = repository.findAllByCreatorIdAndActive(creatorId = host.id!!, isActive = true)
|
val rouletteList = repository.findByCreatorIdAndActive(creatorId = host.id!!, isActive = true)
|
||||||
|
|
||||||
if (rouletteList.isEmpty() || !rouletteList[0].isActive || rouletteList[0].items.isEmpty()) {
|
if (rouletteList.isEmpty() || !rouletteList[0].isActive || rouletteList[0].items.isEmpty()) {
|
||||||
throw SodaException("룰렛을 사용할 수 없습니다.")
|
throw SodaException("룰렛을 사용할 수 없습니다.")
|
||||||
|
|
Loading…
Reference in New Issue