관리자 - 라이브 리스트 API
This commit is contained in:
parent
38f6e8d870
commit
7696f06fbd
|
@ -0,0 +1,15 @@
|
|||
package kr.co.vividnext.sodalive.admin.live
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@RequestMapping("/admin/live")
|
||||
class AdminLiveController(private val service: AdminLiveService) {
|
||||
@GetMapping
|
||||
fun getOnAirLive() = ApiResponse.ok(data = service.getLiveList())
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package kr.co.vividnext.sodalive.admin.live
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.live.room.LiveRoom
|
||||
import kr.co.vividnext.sodalive.live.room.QLiveRoom.liveRoom
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
class AdminLiveRoomQueryRepository(private val queryFactory: JPAQueryFactory) {
|
||||
fun getLiveRoomList(): List<LiveRoom> {
|
||||
return queryFactory
|
||||
.selectFrom(liveRoom)
|
||||
.innerJoin(liveRoom.member, member)
|
||||
.where(liveRoom.isActive.isTrue)
|
||||
.orderBy(liveRoom.channelName.desc(), liveRoom.beginDateTime.asc())
|
||||
.fetch()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package kr.co.vividnext.sodalive.admin.live
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class AdminLiveService(
|
||||
private val repository: AdminLiveRoomQueryRepository,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val coverImageHost: String
|
||||
) {
|
||||
fun getLiveList(): GetLiveResponse {
|
||||
return GetLiveResponse(
|
||||
liveList = repository.getLiveRoomList()
|
||||
.asSequence()
|
||||
.map {
|
||||
GetLiveResponseItem(
|
||||
id = it.id!!,
|
||||
title = it.title,
|
||||
content = it.notice,
|
||||
managerNickname = it.member!!.nickname,
|
||||
coverImageUrl = if (it.coverImage!!.startsWith("https://")) {
|
||||
it.coverImage!!
|
||||
} else {
|
||||
"$coverImageHost/${it.coverImage!!}"
|
||||
},
|
||||
channelName = it.channelName ?: "",
|
||||
type = it.type,
|
||||
password = it.password,
|
||||
isAdult = it.isAdult
|
||||
)
|
||||
}
|
||||
.toList()
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package kr.co.vividnext.sodalive.admin.live
|
||||
|
||||
import kr.co.vividnext.sodalive.live.room.LiveRoomType
|
||||
|
||||
data class GetLiveResponse(
|
||||
val liveList: List<GetLiveResponseItem>
|
||||
)
|
||||
|
||||
data class GetLiveResponseItem(
|
||||
val id: Long,
|
||||
val title: String,
|
||||
val content: String,
|
||||
val managerNickname: String,
|
||||
val coverImageUrl: String,
|
||||
val channelName: String,
|
||||
val type: LiveRoomType,
|
||||
val password: String?,
|
||||
val isAdult: Boolean
|
||||
)
|
Loading…
Reference in New Issue