feat(creator-channel): 오디오 탭 응답 변환을 추가한다
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.creator.channel.audio.application
|
||||
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.v2.api.creator.channel.audio.dto.CreatorChannelAudioTabResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.application.CreatorChannelAudioQueryService
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
class CreatorChannelAudioFacade(
|
||||
private val creatorChannelAudioQueryService: CreatorChannelAudioQueryService
|
||||
) {
|
||||
fun getAudioTab(
|
||||
creatorId: Long,
|
||||
viewer: Member,
|
||||
sort: String?,
|
||||
themeId: Long?,
|
||||
page: Int?,
|
||||
size: Int?,
|
||||
now: LocalDateTime = LocalDateTime.now()
|
||||
): CreatorChannelAudioTabResponse {
|
||||
return CreatorChannelAudioTabResponse.from(
|
||||
creatorChannelAudioQueryService.getAudioTab(
|
||||
creatorId = creatorId,
|
||||
viewer = viewer,
|
||||
sort = sort,
|
||||
themeId = themeId,
|
||||
page = page,
|
||||
size = size,
|
||||
now = now
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.creator.channel.audio.dto
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import kr.co.vividnext.sodalive.v2.api.creator.channel.common.dto.CreatorChannelAudioContentResponse
|
||||
import kr.co.vividnext.sodalive.v2.common.domain.ContentSort
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.domain.CreatorChannelAudioTab
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.domain.CreatorChannelAudioTheme
|
||||
|
||||
data class CreatorChannelAudioTabResponse(
|
||||
val audioContentCount: Int,
|
||||
val paidAudioContentCount: Int,
|
||||
val purchasedAudioContentCount: Int,
|
||||
val purchasedAudioContentRate: Double,
|
||||
val themes: List<CreatorChannelAudioThemeResponse>,
|
||||
val audioContents: List<CreatorChannelAudioContentResponse>,
|
||||
val sort: ContentSort,
|
||||
val themeId: Long?,
|
||||
val page: Int,
|
||||
val size: Int,
|
||||
@JsonProperty("hasNext")
|
||||
val hasNext: Boolean
|
||||
) {
|
||||
companion object {
|
||||
fun from(tab: CreatorChannelAudioTab): CreatorChannelAudioTabResponse {
|
||||
return CreatorChannelAudioTabResponse(
|
||||
audioContentCount = tab.audioContentCount,
|
||||
paidAudioContentCount = tab.paidAudioContentCount,
|
||||
purchasedAudioContentCount = tab.purchasedAudioContentCount,
|
||||
purchasedAudioContentRate = tab.purchasedAudioContentRate,
|
||||
themes = tab.themes.map(CreatorChannelAudioThemeResponse::from),
|
||||
audioContents = tab.audioContents.map(CreatorChannelAudioContentResponse::from),
|
||||
sort = tab.sort,
|
||||
themeId = tab.themeId,
|
||||
page = tab.page.page,
|
||||
size = tab.page.size,
|
||||
hasNext = tab.hasNext
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class CreatorChannelAudioThemeResponse(
|
||||
val themeId: Long,
|
||||
val themeName: String
|
||||
) {
|
||||
companion object {
|
||||
fun from(theme: CreatorChannelAudioTheme): CreatorChannelAudioThemeResponse {
|
||||
return CreatorChannelAudioThemeResponse(
|
||||
themeId = theme.themeId,
|
||||
themeName = theme.themeName
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user