diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt index 9a32539..a648fe2 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt @@ -176,18 +176,24 @@ class LiveRoomQueryRepositoryImpl( ) } - return queryFactory - .selectFrom(liveRoom) - .innerJoin(liveRoom.member, member) - .limit(10) - .where(where) - .orderBy( + val orderBy = if (memberId != null) { + listOf( CaseBuilder() .`when`(member.id.eq(memberId)).then(1) .otherwise(2) .asc(), liveRoom.beginDateTime.asc() ) + } else { + listOf(liveRoom.beginDateTime.asc()) + } + + return queryFactory + .selectFrom(liveRoom) + .innerJoin(liveRoom.member, member) + .limit(10) + .where(where) + .orderBy(*orderBy.toTypedArray()) .fetch() }