feat(home): 메인 전체 탭 유료 오디오 필터를 적용한다
This commit is contained in:
@@ -36,6 +36,7 @@ class DefaultMainContentAllQueryRepository(
|
||||
memberId: Long?,
|
||||
canViewAdultContent: Boolean,
|
||||
now: LocalDateTime,
|
||||
onlyPaid: Boolean,
|
||||
onlyFree: Boolean,
|
||||
onlyPointAvailable: Boolean
|
||||
): Int {
|
||||
@@ -44,7 +45,7 @@ class DefaultMainContentAllQueryRepository(
|
||||
.from(audioContent)
|
||||
.join(audioContent.member, member)
|
||||
.join(audioContent.theme, audioContentTheme)
|
||||
.where(audioCondition(memberId, canViewAdultContent, now, onlyFree, onlyPointAvailable))
|
||||
.where(audioCondition(memberId, canViewAdultContent, now, onlyPaid, onlyFree, onlyPointAvailable))
|
||||
.fetchOne()
|
||||
?.toInt()
|
||||
?: 0
|
||||
@@ -57,10 +58,11 @@ class DefaultMainContentAllQueryRepository(
|
||||
sort: ContentSort,
|
||||
offset: Long,
|
||||
limit: Int,
|
||||
onlyPaid: Boolean,
|
||||
onlyFree: Boolean,
|
||||
onlyPointAvailable: Boolean
|
||||
): List<MainContentAllAudio> {
|
||||
val rows = findAudioRows(memberId, canViewAdultContent, now, sort, offset, limit, onlyFree, onlyPointAvailable)
|
||||
val rows = findAudioRows(memberId, canViewAdultContent, now, sort, offset, limit, onlyPaid, onlyFree, onlyPointAvailable)
|
||||
if (rows.isEmpty()) return emptyList()
|
||||
|
||||
val contentIds = rows.map { it.get(audioContent.id)!! }
|
||||
@@ -157,6 +159,7 @@ class DefaultMainContentAllQueryRepository(
|
||||
sort: ContentSort,
|
||||
offset: Long,
|
||||
limit: Int,
|
||||
onlyPaid: Boolean,
|
||||
onlyFree: Boolean,
|
||||
onlyPointAvailable: Boolean
|
||||
): List<Tuple> {
|
||||
@@ -175,7 +178,7 @@ class DefaultMainContentAllQueryRepository(
|
||||
.from(audioContent)
|
||||
.join(audioContent.member, member)
|
||||
.join(audioContent.theme, audioContentTheme)
|
||||
.where(audioCondition(memberId, canViewAdultContent, now, onlyFree, onlyPointAvailable))
|
||||
.where(audioCondition(memberId, canViewAdultContent, now, onlyPaid, onlyFree, onlyPointAvailable))
|
||||
|
||||
when (sort) {
|
||||
ContentSort.POPULAR -> {
|
||||
@@ -344,10 +347,12 @@ class DefaultMainContentAllQueryRepository(
|
||||
memberId: Long?,
|
||||
canViewAdultContent: Boolean,
|
||||
now: LocalDateTime,
|
||||
onlyPaid: Boolean,
|
||||
onlyFree: Boolean,
|
||||
onlyPointAvailable: Boolean
|
||||
): BooleanExpression {
|
||||
return publicAudioCondition(canViewAdultContent, now)
|
||||
.and(optionalAudioPaidCondition(onlyPaid))
|
||||
.and(optionalAudioFreeCondition(onlyFree))
|
||||
.and(optionalAudioPointCondition(onlyPointAvailable))
|
||||
.withOptionalAnd(notBlockedCreatorCondition(memberId, audioContent.member.id))
|
||||
@@ -392,6 +397,10 @@ class DefaultMainContentAllQueryRepository(
|
||||
.withOptionalAnd(notBlockedCreatorCondition(memberId, series.member.id))
|
||||
}
|
||||
|
||||
private fun optionalAudioPaidCondition(onlyPaid: Boolean): BooleanExpression? {
|
||||
return if (onlyPaid) audioContent.price.gt(0) else null
|
||||
}
|
||||
|
||||
private fun optionalAudioFreeCondition(onlyFree: Boolean): BooleanExpression? {
|
||||
return if (onlyFree) audioContent.price.eq(0) else null
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ class MainContentAllQueryService(
|
||||
page = resolvedPage,
|
||||
memberId = memberId,
|
||||
canViewAdultContent = canViewAdultContent,
|
||||
now = now
|
||||
now = now,
|
||||
onlyPaid = true
|
||||
)
|
||||
|
||||
MainContentAllType.FREE -> getAudioContents(
|
||||
@@ -102,10 +103,18 @@ class MainContentAllQueryService(
|
||||
memberId: Long?,
|
||||
canViewAdultContent: Boolean,
|
||||
now: LocalDateTime,
|
||||
onlyPaid: Boolean = false,
|
||||
onlyFree: Boolean = false,
|
||||
onlyPointAvailable: Boolean = false
|
||||
): MainContentAll {
|
||||
val totalCount = queryPort.countAudios(memberId, canViewAdultContent, now, onlyFree, onlyPointAvailable)
|
||||
val totalCount = queryPort.countAudios(
|
||||
memberId = memberId,
|
||||
canViewAdultContent = canViewAdultContent,
|
||||
now = now,
|
||||
onlyPaid = onlyPaid,
|
||||
onlyFree = onlyFree,
|
||||
onlyPointAvailable = onlyPointAvailable
|
||||
)
|
||||
val audios = queryPort.findAudios(
|
||||
memberId = memberId,
|
||||
canViewAdultContent = canViewAdultContent,
|
||||
@@ -113,6 +122,7 @@ class MainContentAllQueryService(
|
||||
sort = sort,
|
||||
offset = page.offset,
|
||||
limit = page.size + 1,
|
||||
onlyPaid = onlyPaid,
|
||||
onlyFree = onlyFree,
|
||||
onlyPointAvailable = onlyPointAvailable
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ interface MainContentAllQueryPort {
|
||||
memberId: Long?,
|
||||
canViewAdultContent: Boolean,
|
||||
now: LocalDateTime,
|
||||
onlyPaid: Boolean = false,
|
||||
onlyFree: Boolean = false,
|
||||
onlyPointAvailable: Boolean = false
|
||||
): Int
|
||||
@@ -22,6 +23,7 @@ interface MainContentAllQueryPort {
|
||||
sort: ContentSort,
|
||||
offset: Long,
|
||||
limit: Int,
|
||||
onlyPaid: Boolean = false,
|
||||
onlyFree: Boolean = false,
|
||||
onlyPointAvailable: Boolean = false
|
||||
): List<MainContentAllAudio>
|
||||
|
||||
@@ -34,6 +34,7 @@ class MainContentAllQueryServiceTest {
|
||||
assertEquals(ContentSort.POPULAR, port.lastSort)
|
||||
assertEquals(20L, port.lastOffset)
|
||||
assertEquals(21, port.lastLimit)
|
||||
assertTrue(port.lastOnlyPaid)
|
||||
assertFalse(port.lastOnlyFree)
|
||||
assertFalse(port.lastOnlyPointAvailable)
|
||||
assertEquals(20, tab.audios.size)
|
||||
@@ -52,6 +53,7 @@ class MainContentAllQueryServiceTest {
|
||||
|
||||
assertEquals(MainContentAllType.FREE, tab.type)
|
||||
assertEquals("audio", port.lastListKind)
|
||||
assertFalse(port.lastOnlyPaid)
|
||||
assertTrue(port.lastOnlyFree)
|
||||
assertFalse(port.lastOnlyPointAvailable)
|
||||
assertEquals(21, port.lastLimit)
|
||||
@@ -71,6 +73,7 @@ class MainContentAllQueryServiceTest {
|
||||
assertEquals(MainContentAllType.POINT, tab.type)
|
||||
assertEquals("audio", port.lastListKind)
|
||||
assertEquals(ContentSort.PRICE_LOW, port.lastSort)
|
||||
assertFalse(port.lastOnlyPaid)
|
||||
assertFalse(port.lastOnlyFree)
|
||||
assertTrue(port.lastOnlyPointAvailable)
|
||||
assertEquals(21, port.lastLimit)
|
||||
@@ -153,6 +156,7 @@ private class FakeMainContentAllQueryPort : MainContentAllQueryPort {
|
||||
var lastSort: ContentSort? = null
|
||||
var lastOffset: Long? = null
|
||||
var lastLimit: Int? = null
|
||||
var lastOnlyPaid: Boolean = false
|
||||
var lastOnlyFree: Boolean = false
|
||||
var lastOnlyPointAvailable: Boolean = false
|
||||
var lastOnlyOriginal: Boolean = false
|
||||
@@ -163,11 +167,13 @@ private class FakeMainContentAllQueryPort : MainContentAllQueryPort {
|
||||
memberId: Long?,
|
||||
canViewAdultContent: Boolean,
|
||||
now: LocalDateTime,
|
||||
onlyPaid: Boolean,
|
||||
onlyFree: Boolean,
|
||||
onlyPointAvailable: Boolean
|
||||
): Int {
|
||||
lastMemberId = memberId
|
||||
lastCanViewAdultContent = canViewAdultContent
|
||||
lastOnlyPaid = onlyPaid
|
||||
lastOnlyFree = onlyFree
|
||||
lastOnlyPointAvailable = onlyPointAvailable
|
||||
return 30
|
||||
@@ -180,6 +186,7 @@ private class FakeMainContentAllQueryPort : MainContentAllQueryPort {
|
||||
sort: ContentSort,
|
||||
offset: Long,
|
||||
limit: Int,
|
||||
onlyPaid: Boolean,
|
||||
onlyFree: Boolean,
|
||||
onlyPointAvailable: Boolean
|
||||
): List<MainContentAllAudio> {
|
||||
@@ -189,6 +196,7 @@ private class FakeMainContentAllQueryPort : MainContentAllQueryPort {
|
||||
lastSort = sort
|
||||
lastOffset = offset
|
||||
lastLimit = limit
|
||||
lastOnlyPaid = onlyPaid
|
||||
lastOnlyFree = onlyFree
|
||||
lastOnlyPointAvailable = onlyPointAvailable
|
||||
return (1L..limit.toLong()).map { id ->
|
||||
|
||||
Reference in New Issue
Block a user