feat(creator-channel): 시리즈 탭 응답 변환을 추가한다
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.creator.channel.series.application
|
||||
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.v2.api.creator.channel.series.dto.CreatorChannelSeriesTabResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.series.application.CreatorChannelSeriesQueryService
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
class CreatorChannelSeriesFacade(
|
||||
private val creatorChannelSeriesQueryService: CreatorChannelSeriesQueryService
|
||||
) {
|
||||
fun getSeriesTab(
|
||||
creatorId: Long,
|
||||
viewer: Member,
|
||||
sort: String?,
|
||||
page: Int?,
|
||||
size: Int?,
|
||||
now: LocalDateTime = LocalDateTime.now()
|
||||
): CreatorChannelSeriesTabResponse {
|
||||
return CreatorChannelSeriesTabResponse.from(
|
||||
creatorChannelSeriesQueryService.getSeriesTab(
|
||||
creatorId = creatorId,
|
||||
viewer = viewer,
|
||||
sort = sort,
|
||||
page = page,
|
||||
size = size,
|
||||
now = now
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.creator.channel.series.dto
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import kr.co.vividnext.sodalive.v2.common.domain.ContentSort
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.series.domain.CreatorChannelSeries
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.series.domain.CreatorChannelSeriesTab
|
||||
|
||||
data class CreatorChannelSeriesTabResponse(
|
||||
val seriesCount: Int,
|
||||
val series: List<CreatorChannelSeriesResponse>,
|
||||
val sort: ContentSort,
|
||||
val page: Int,
|
||||
val size: Int,
|
||||
@JsonProperty("hasNext")
|
||||
val hasNext: Boolean
|
||||
) {
|
||||
companion object {
|
||||
fun from(tab: CreatorChannelSeriesTab): CreatorChannelSeriesTabResponse {
|
||||
return CreatorChannelSeriesTabResponse(
|
||||
seriesCount = tab.seriesCount,
|
||||
series = tab.series.map(CreatorChannelSeriesResponse::from),
|
||||
sort = tab.sort,
|
||||
page = tab.page.page,
|
||||
size = tab.page.size,
|
||||
hasNext = tab.hasNext
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class CreatorChannelSeriesResponse(
|
||||
val seriesId: Long,
|
||||
val title: String,
|
||||
val coverImageUrl: String?,
|
||||
val publishedDaysOfWeek: String,
|
||||
@JsonProperty("isOriginal")
|
||||
val isOriginal: Boolean,
|
||||
@JsonProperty("isAdult")
|
||||
val isAdult: Boolean,
|
||||
@JsonProperty("isProceeding")
|
||||
val isProceeding: Boolean,
|
||||
val contentCount: Int,
|
||||
val purchasedContentCount: Int?,
|
||||
val paidContentCount: Int?,
|
||||
val purchasedPaidContentRate: Int?
|
||||
) {
|
||||
companion object {
|
||||
fun from(series: CreatorChannelSeries): CreatorChannelSeriesResponse {
|
||||
return CreatorChannelSeriesResponse(
|
||||
seriesId = series.seriesId,
|
||||
title = series.title,
|
||||
coverImageUrl = series.coverImageUrl,
|
||||
publishedDaysOfWeek = series.publishedDaysOfWeek,
|
||||
isOriginal = series.isOriginal,
|
||||
isAdult = series.isAdult,
|
||||
isProceeding = series.isProceeding,
|
||||
contentCount = series.contentCount,
|
||||
purchasedContentCount = series.purchasedContentCount,
|
||||
paidContentCount = series.paidContentCount,
|
||||
purchasedPaidContentRate = series.purchasedPaidContentRate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user