refactor(creator): 시리즈 subtitle 모델을 분리한다
This commit is contained in:
@@ -2,10 +2,6 @@ package kr.co.vividnext.sodalive.v2.creator.channel.series.model
|
|||||||
|
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.series.data.CreatorChannelSeriesResponse
|
import kr.co.vividnext.sodalive.v2.creator.channel.series.data.CreatorChannelSeriesResponse
|
||||||
|
|
||||||
private const val BULLET_SEPARATOR = " • "
|
|
||||||
private const val STATUS_PROCEEDING = "연재"
|
|
||||||
private const val STATUS_COMPLETED = "완결"
|
|
||||||
|
|
||||||
fun List<CreatorChannelSeriesResponse>.toSeriesItemUiModels(
|
fun List<CreatorChannelSeriesResponse>.toSeriesItemUiModels(
|
||||||
isOwner: Boolean
|
isOwner: Boolean
|
||||||
): List<CreatorChannelSeriesItemUiModel> = mapNotNull { it.toSeriesItemUiModel(isOwner) }
|
): List<CreatorChannelSeriesItemUiModel> = mapNotNull { it.toSeriesItemUiModel(isOwner) }
|
||||||
@@ -16,7 +12,7 @@ private fun CreatorChannelSeriesResponse.toSeriesItemUiModel(isOwner: Boolean):
|
|||||||
return CreatorChannelSeriesItemUiModel(
|
return CreatorChannelSeriesItemUiModel(
|
||||||
seriesId = seriesId,
|
seriesId = seriesId,
|
||||||
title = title,
|
title = title,
|
||||||
subtitle = subtitle(),
|
subtitle = toSubtitleUiModel(),
|
||||||
coverImageUrl = coverImageUrl,
|
coverImageUrl = coverImageUrl,
|
||||||
showOriginalTag = isOriginal,
|
showOriginalTag = isOriginal,
|
||||||
showAdultBadge = isAdult,
|
showAdultBadge = isAdult,
|
||||||
@@ -24,11 +20,13 @@ private fun CreatorChannelSeriesResponse.toSeriesItemUiModel(isOwner: Boolean):
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CreatorChannelSeriesResponse.subtitle(): String = listOfNotNull(
|
private fun CreatorChannelSeriesResponse.toSubtitleUiModel(): CreatorChannelSeriesSubtitleUiModel {
|
||||||
publishedDaysOfWeek?.takeIf { it.isNotBlank() },
|
return CreatorChannelSeriesSubtitleUiModel(
|
||||||
"총 ${contentCount}화",
|
publishedDaysOfWeek = publishedDaysOfWeek?.takeIf { it.isNotBlank() },
|
||||||
if (isProceeding) STATUS_PROCEEDING else STATUS_COMPLETED
|
contentCount = contentCount,
|
||||||
).joinToString(BULLET_SEPARATOR)
|
isProceeding = isProceeding
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun CreatorChannelSeriesResponse.toProgressUiModel(isOwner: Boolean): CreatorChannelSeriesProgressUiModel? {
|
private fun CreatorChannelSeriesResponse.toProgressUiModel(isOwner: Boolean): CreatorChannelSeriesProgressUiModel? {
|
||||||
if (isOwner) return null
|
if (isOwner) return null
|
||||||
|
|||||||
@@ -3,13 +3,19 @@ package kr.co.vividnext.sodalive.v2.creator.channel.series.model
|
|||||||
data class CreatorChannelSeriesItemUiModel(
|
data class CreatorChannelSeriesItemUiModel(
|
||||||
val seriesId: Long,
|
val seriesId: Long,
|
||||||
val title: String,
|
val title: String,
|
||||||
val subtitle: String,
|
val subtitle: CreatorChannelSeriesSubtitleUiModel,
|
||||||
val coverImageUrl: String?,
|
val coverImageUrl: String?,
|
||||||
val showOriginalTag: Boolean,
|
val showOriginalTag: Boolean,
|
||||||
val showAdultBadge: Boolean,
|
val showAdultBadge: Boolean,
|
||||||
val progress: CreatorChannelSeriesProgressUiModel?
|
val progress: CreatorChannelSeriesProgressUiModel?
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class CreatorChannelSeriesSubtitleUiModel(
|
||||||
|
val publishedDaysOfWeek: String?,
|
||||||
|
val contentCount: Int,
|
||||||
|
val isProceeding: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
data class CreatorChannelSeriesProgressUiModel(
|
data class CreatorChannelSeriesProgressUiModel(
|
||||||
val purchasedCount: Int,
|
val purchasedCount: Int,
|
||||||
val paidCount: Int,
|
val paidCount: Int,
|
||||||
|
|||||||
@@ -11,35 +11,39 @@ import org.junit.Test
|
|||||||
class CreatorChannelSeriesMapperTest {
|
class CreatorChannelSeriesMapperTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `isProceeding true이면 subtitle에 연재가 포함된다`() {
|
fun `isProceeding true이면 subtitle status가 proceeding이다`() {
|
||||||
val item = listOf(series(isProceeding = true)).toSeriesItemUiModels(isOwner = false).single()
|
val item = listOf(series(isProceeding = true)).toSeriesItemUiModels(isOwner = false).single()
|
||||||
|
|
||||||
assertTrue(item.subtitle.contains("연재"))
|
assertEquals(true, item.subtitle.isProceeding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `isProceeding false이면 subtitle에 완결이 포함된다`() {
|
fun `isProceeding false이면 subtitle status가 completed이다`() {
|
||||||
val item = listOf(series(isProceeding = false)).toSeriesItemUiModels(isOwner = false).single()
|
val item = listOf(series(isProceeding = false)).toSeriesItemUiModels(isOwner = false).single()
|
||||||
|
|
||||||
assertTrue(item.subtitle.contains("완결"))
|
assertEquals(false, item.subtitle.isProceeding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `publishedDaysOfWeek contentCount 진행 상태를 bullet 형식으로 조합한다`() {
|
fun `publishedDaysOfWeek contentCount 진행 상태를 subtitle 조각으로 유지한다`() {
|
||||||
val item = listOf(
|
val item = listOf(
|
||||||
series(publishedDaysOfWeek = "매주 월", contentCount = 45, isProceeding = true)
|
series(publishedDaysOfWeek = "매주 월", contentCount = 45, isProceeding = true)
|
||||||
).toSeriesItemUiModels(isOwner = false).single()
|
).toSeriesItemUiModels(isOwner = false).single()
|
||||||
|
|
||||||
assertEquals("매주 월 • 총 45화 • 연재", item.subtitle)
|
assertEquals("매주 월", item.subtitle.publishedDaysOfWeek)
|
||||||
|
assertEquals(45, item.subtitle.contentCount)
|
||||||
|
assertEquals(true, item.subtitle.isProceeding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `publishedDaysOfWeek가 blank이면 빈 bullet 없이 조합한다`() {
|
fun `publishedDaysOfWeek가 blank이면 subtitle 조각에서 제외한다`() {
|
||||||
val item = listOf(
|
val item = listOf(
|
||||||
series(publishedDaysOfWeek = " ", contentCount = 45, isProceeding = true)
|
series(publishedDaysOfWeek = " ", contentCount = 45, isProceeding = true)
|
||||||
).toSeriesItemUiModels(isOwner = false).single()
|
).toSeriesItemUiModels(isOwner = false).single()
|
||||||
|
|
||||||
assertEquals("총 45화 • 연재", item.subtitle)
|
assertNull(item.subtitle.publishedDaysOfWeek)
|
||||||
|
assertEquals(45, item.subtitle.contentCount)
|
||||||
|
assertEquals(true, item.subtitle.isProceeding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user