Compare commits

..

2 Commits

Author SHA1 Message Date
Klaus eb552f01f0 룰렛 프리셋 API 추가
- 룰렛 만들기
- 룰렛 업데이트
- 룰렛 프리셋 전체 가져오기
2024-02-22 16:04:06 +09:00
Klaus 95717824c6 룰렛 프리셋 API 추가
- 룰렛 만들기
- 룰렛 업데이트
- 룰렛 프리셋 전체 가져오기
2024-02-22 16:03:37 +09:00
1 changed files with 6 additions and 3 deletions

View File

@ -36,11 +36,11 @@ 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("잘못된 요청입니다.")
val rouletteList = repository.findByCreatorId(creatorId) var rouletteList = repository.findByCreatorId(creatorId)
if (rouletteList.isEmpty()) { if (rouletteList.isEmpty()) {
val roulette = oldRepository.findByIdOrNull(creatorId) val roulette = oldRepository.findByIdOrNull(creatorId)
if (roulette != null) { if (roulette != null) {
val newRoulette = repository.save( repository.save(
NewRoulette( NewRoulette(
id = idGenerator.generateId(SEQUENCE_NAME), id = idGenerator.generateId(SEQUENCE_NAME),
creatorId = creatorId, creatorId = creatorId,
@ -50,11 +50,14 @@ class NewRouletteService(
) )
) )
rouletteList.toMutableList().add(newRoulette) rouletteList = repository.findByCreatorId(creatorId)
} }
} }
rouletteList.sortedBy { it.id } rouletteList.sortedBy { it.id }
println(rouletteList)
return rouletteList.asSequence() return rouletteList.asSequence()
.map { .map {
GetNewRouletteResponse( GetNewRouletteResponse(