feat(creator): 채널 라이브 탭 도메인 정책을 추가한다
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.live.domain
|
||||
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class CreatorChannelLiveReplayQueryPolicy {
|
||||
fun createPage(page: Int, size: Int): CreatorChannelPage {
|
||||
if (page < MIN_PAGE || size < MIN_PAGE_SIZE || size > MAX_PAGE_SIZE) {
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
return CreatorChannelPage(page = page, size = size)
|
||||
}
|
||||
|
||||
fun <T> limitItems(fetched: List<T>, page: CreatorChannelPage): List<T> {
|
||||
return fetched.take(page.size)
|
||||
}
|
||||
|
||||
fun hasNext(fetched: List<*>, page: CreatorChannelPage): Boolean {
|
||||
return fetched.size > page.size
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MIN_PAGE = 0
|
||||
private const val MIN_PAGE_SIZE = 20
|
||||
private const val MAX_PAGE_SIZE = 50
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.live.domain
|
||||
|
||||
import kr.co.vividnext.sodalive.v2.common.domain.ContentSort
|
||||
import java.time.LocalDateTime
|
||||
|
||||
data class CreatorChannelLiveTab(
|
||||
val liveReplayContentCount: Int,
|
||||
val currentLive: CreatorChannelLive?,
|
||||
val liveReplayContents: List<CreatorChannelAudioContent>,
|
||||
val sort: ContentSort,
|
||||
val page: CreatorChannelPage,
|
||||
val hasNext: Boolean
|
||||
)
|
||||
|
||||
data class CreatorChannelLive(
|
||||
val liveId: Long,
|
||||
val title: String,
|
||||
val coverImageUrl: String?,
|
||||
val beginDateTime: LocalDateTime,
|
||||
val price: Int,
|
||||
val isAdult: Boolean
|
||||
)
|
||||
|
||||
data class CreatorChannelAudioContent(
|
||||
val audioContentId: Long,
|
||||
val title: String,
|
||||
val duration: String?,
|
||||
val imageUrl: String?,
|
||||
val price: Int,
|
||||
val isAdult: Boolean,
|
||||
val isPointAvailable: Boolean,
|
||||
val isFirstContent: Boolean,
|
||||
val publishedAt: LocalDateTime,
|
||||
val seriesName: String?,
|
||||
val isOriginalSeries: Boolean?,
|
||||
val isOwned: Boolean,
|
||||
val isRented: Boolean
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.live.domain
|
||||
|
||||
data class CreatorChannelPage(
|
||||
val page: Int,
|
||||
val size: Int
|
||||
) {
|
||||
val offset: Long = page.toLong() * size
|
||||
val fetchLimit: Int = size + 1
|
||||
}
|
||||
Reference in New Issue
Block a user