Compare commits
20 Commits
ee403915f0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 587f3d6b58 | |||
| 76806e2e90 | |||
| 39c51825da | |||
| 9b6167d46d | |||
| 9a58b7b95f | |||
| 26eae4b06e | |||
| 008ee3b4e5 | |||
| 60989391f6 | |||
| 88d90eec2f | |||
| b6eb13df06 | |||
| 3a57ad23bb | |||
| a6b815ad05 | |||
| d89122802a | |||
| 729552335a | |||
| 690432d6ee | |||
| bc358d18de | |||
| 02ae507c87 | |||
| add88aca35 | |||
| 5818abf69d | |||
| b6971f6a8d |
@@ -124,7 +124,8 @@ class HomeService(
|
||||
|
||||
val originalAudioDramaList = seriesService.getOriginalAudioDramaList(
|
||||
isAdult = isAdult,
|
||||
contentType = contentType
|
||||
contentType = contentType,
|
||||
orderByRandom = true
|
||||
)
|
||||
|
||||
val auditionList = auditionService.getInProgressAuditionList(isAdult = isAdult)
|
||||
|
||||
@@ -23,7 +23,7 @@ enum class PurchaseOption {
|
||||
}
|
||||
|
||||
enum class SortType {
|
||||
NEWEST, PRICE_HIGH, PRICE_LOW
|
||||
NEWEST, PRICE_HIGH, PRICE_LOW, POPULARITY
|
||||
}
|
||||
|
||||
@Entity
|
||||
|
||||
@@ -243,6 +243,8 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
||||
@RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null,
|
||||
@RequestParam("sort-type", required = false) sortType: SortType? = SortType.NEWEST,
|
||||
@RequestParam("theme", required = false) theme: String? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
@@ -250,10 +252,11 @@ class AudioContentController(private val service: AudioContentService) {
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getLatestContentByTheme(
|
||||
theme = emptyList(),
|
||||
theme = if (theme == null) listOf() else listOf(theme),
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong(),
|
||||
sortType = sortType ?: SortType.NEWEST,
|
||||
isFree = isFree ?: false,
|
||||
isAdult = (isAdultContentVisible ?: true) && member.auth != null,
|
||||
isPointAvailableOnly = isPointAvailableOnly ?: false
|
||||
|
||||
@@ -109,7 +109,6 @@ interface AudioContentQueryRepository {
|
||||
): Int
|
||||
|
||||
fun findByThemeFor2Weeks(
|
||||
isFree: Boolean = false,
|
||||
cloudfrontHost: String,
|
||||
memberId: Long,
|
||||
theme: List<String> = emptyList(),
|
||||
@@ -120,7 +119,6 @@ interface AudioContentQueryRepository {
|
||||
): List<GetAudioContentMainItem>
|
||||
|
||||
fun totalCountNewContentFor2Weeks(
|
||||
isFree: Boolean = false,
|
||||
theme: List<String> = emptyList(),
|
||||
memberId: Long,
|
||||
isAdult: Boolean,
|
||||
@@ -182,6 +180,7 @@ interface AudioContentQueryRepository {
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
sortType: SortType,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean,
|
||||
orderByRandom: Boolean = false,
|
||||
@@ -243,6 +242,7 @@ class AudioContentQueryRepositoryImpl(
|
||||
SortType.NEWEST -> audioContent.releaseDate.desc()
|
||||
SortType.PRICE_HIGH -> audioContent.price.desc()
|
||||
SortType.PRICE_LOW -> audioContent.price.asc()
|
||||
SortType.POPULARITY -> audioContent.playCount.desc()
|
||||
}
|
||||
|
||||
var where = audioContent.member.id.eq(creatorId)
|
||||
@@ -464,6 +464,12 @@ class AudioContentQueryRepositoryImpl(
|
||||
audioContent.releaseDate.asc(),
|
||||
audioContent.id.asc()
|
||||
)
|
||||
|
||||
SortType.POPULARITY -> listOf(
|
||||
audioContent.playCount.desc(),
|
||||
audioContent.releaseDate.asc(),
|
||||
audioContent.id.asc()
|
||||
)
|
||||
}
|
||||
|
||||
var where = audioContent.isActive.isTrue
|
||||
@@ -695,7 +701,6 @@ class AudioContentQueryRepositoryImpl(
|
||||
}
|
||||
|
||||
override fun totalCountNewContentFor2Weeks(
|
||||
isFree: Boolean,
|
||||
theme: List<String>,
|
||||
memberId: Long,
|
||||
isAdult: Boolean,
|
||||
@@ -732,10 +737,6 @@ class AudioContentQueryRepositoryImpl(
|
||||
where = where.and(audioContentTheme.theme.`in`(theme))
|
||||
}
|
||||
|
||||
if (isFree) {
|
||||
where = where.and(audioContent.price.loe(0))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(audioContent.id)
|
||||
.from(audioContent)
|
||||
@@ -747,7 +748,6 @@ class AudioContentQueryRepositoryImpl(
|
||||
}
|
||||
|
||||
override fun findByThemeFor2Weeks(
|
||||
isFree: Boolean,
|
||||
cloudfrontHost: String,
|
||||
memberId: Long,
|
||||
theme: List<String>,
|
||||
@@ -787,10 +787,6 @@ class AudioContentQueryRepositoryImpl(
|
||||
where = where.and(audioContentTheme.theme.`in`(theme))
|
||||
}
|
||||
|
||||
if (isFree) {
|
||||
where = where.and(audioContent.price.loe(0))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetAudioContentMainItem(
|
||||
@@ -1309,6 +1305,7 @@ class AudioContentQueryRepositoryImpl(
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
sortType: SortType,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean,
|
||||
orderByRandom: Boolean,
|
||||
@@ -1354,7 +1351,22 @@ class AudioContentQueryRepositoryImpl(
|
||||
val orderBy = if (orderByRandom) {
|
||||
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
|
||||
} else {
|
||||
audioContent.releaseDate.desc()
|
||||
when (sortType) {
|
||||
SortType.NEWEST -> audioContent.releaseDate.desc()
|
||||
SortType.PRICE_HIGH -> if (isFree) {
|
||||
audioContent.releaseDate.desc()
|
||||
} else {
|
||||
audioContent.price.desc()
|
||||
}
|
||||
|
||||
SortType.PRICE_LOW -> if (isFree) {
|
||||
audioContent.releaseDate.asc()
|
||||
} else {
|
||||
audioContent.price.desc()
|
||||
}
|
||||
|
||||
SortType.POPULARITY -> audioContent.playCount.desc()
|
||||
}
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
@@ -1441,11 +1453,10 @@ class AudioContentQueryRepositoryImpl(
|
||||
isAdult: Boolean
|
||||
): AudioContent? {
|
||||
var where = audioContent.member.id.eq(creatorId)
|
||||
.and(
|
||||
audioContent.isActive.isTrue
|
||||
.and(audioContent.duration.isNotNull)
|
||||
.or(audioContent.releaseDate.isNotNull.and(audioContent.duration.isNotNull))
|
||||
)
|
||||
.and(audioContent.isActive.isTrue)
|
||||
.and(audioContent.duration.isNotNull)
|
||||
.and(audioContent.releaseDate.isNotNull)
|
||||
.and(audioContent.releaseDate.loe(LocalDateTime.now()))
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(audioContent.isAdult.isFalse)
|
||||
|
||||
@@ -988,6 +988,7 @@ class AudioContentService(
|
||||
contentType: ContentType,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20,
|
||||
sortType: SortType = SortType.NEWEST,
|
||||
isFree: Boolean = false,
|
||||
isAdult: Boolean = false,
|
||||
orderByRandom: Boolean = false,
|
||||
@@ -998,6 +999,7 @@ class AudioContentService(
|
||||
contentType = contentType,
|
||||
offset = offset,
|
||||
limit = limit,
|
||||
sortType = sortType,
|
||||
isFree = isFree,
|
||||
isAdult = isAdult,
|
||||
orderByRandom = orderByRandom,
|
||||
|
||||
@@ -99,7 +99,6 @@ class AudioContentMainController(
|
||||
|
||||
@GetMapping("/new/all")
|
||||
fun getNewContentAllByTheme(
|
||||
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
||||
@RequestParam("theme") theme: String,
|
||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@@ -110,7 +109,6 @@ class AudioContentMainController(
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getNewContentFor2WeeksByTheme(
|
||||
isFree = isFree ?: false,
|
||||
theme = theme,
|
||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
|
||||
@@ -28,16 +28,6 @@ class AudioContentMainService(
|
||||
@Cacheable(cacheNames = ["default"], key = "'themeList:' + ':' + #isAdult")
|
||||
fun getThemeList(isAdult: Boolean, contentType: ContentType): List<String> {
|
||||
return audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult, contentType = contentType)
|
||||
.filter {
|
||||
it != "모닝콜" &&
|
||||
it != "알람" &&
|
||||
it != "슬립콜" &&
|
||||
it != "다시듣기" &&
|
||||
it != "ASMR" &&
|
||||
it != "릴레이" &&
|
||||
it != "챌린지" &&
|
||||
it != "자기소개"
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@@ -64,7 +54,6 @@ class AudioContentMainService(
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getNewContentFor2WeeksByTheme(
|
||||
isFree: Boolean,
|
||||
theme: String,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
@@ -75,31 +64,19 @@ class AudioContentMainService(
|
||||
val themeList = if (theme.isBlank()) {
|
||||
audioContentThemeRepository.getActiveThemeOfContent(
|
||||
isAdult = isAdult,
|
||||
isFree = isFree,
|
||||
contentType = contentType
|
||||
).filter {
|
||||
it != "모닝콜" &&
|
||||
it != "알람" &&
|
||||
it != "슬립콜" &&
|
||||
it != "다시듣기" &&
|
||||
it != "ASMR" &&
|
||||
it != "릴레이" &&
|
||||
it != "챌린지" &&
|
||||
it != "자기소개"
|
||||
}
|
||||
)
|
||||
} else {
|
||||
listOf(theme)
|
||||
}
|
||||
|
||||
val totalCount = repository.totalCountNewContentFor2Weeks(
|
||||
isFree,
|
||||
themeList,
|
||||
memberId = member.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType
|
||||
)
|
||||
val items = repository.findByThemeFor2Weeks(
|
||||
isFree,
|
||||
cloudfrontHost = imageHost,
|
||||
memberId = member.id!!,
|
||||
theme = themeList,
|
||||
|
||||
@@ -58,6 +58,7 @@ class AudioContentCurationQueryRepository(private val queryFactory: JPAQueryFact
|
||||
SortType.NEWEST -> audioContent.createdAt.desc()
|
||||
SortType.PRICE_HIGH -> audioContent.price.desc()
|
||||
SortType.PRICE_LOW -> audioContent.price.asc()
|
||||
SortType.POPULARITY -> audioContent.playCount.desc()
|
||||
}
|
||||
|
||||
var where = audioContent.isActive.isTrue
|
||||
|
||||
@@ -39,6 +39,7 @@ interface ContentSeriesQueryRepository {
|
||||
contentType: ContentType,
|
||||
isOriginal: Boolean,
|
||||
isCompleted: Boolean,
|
||||
orderByRandom: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series>
|
||||
@@ -65,6 +66,7 @@ interface ContentSeriesQueryRepository {
|
||||
fun getOriginalAudioDramaList(
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
orderByRandom: Boolean = false,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<Series>
|
||||
@@ -139,6 +141,7 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
contentType: ContentType,
|
||||
isOriginal: Boolean,
|
||||
isCompleted: Boolean,
|
||||
orderByRandom: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series> {
|
||||
@@ -173,11 +176,22 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
val orderBy = if (orderByRandom) {
|
||||
listOf(Expressions.numberTemplate(Double::class.java, "function('rand')").asc())
|
||||
} else if (creatorId != null) {
|
||||
listOf(series.orders.asc(), series.createdAt.asc())
|
||||
} else {
|
||||
listOf(audioContent.releaseDate.max().desc(), series.createdAt.asc())
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(series)
|
||||
.innerJoin(series.member, member)
|
||||
.innerJoin(seriesContent).on(series.id.eq(seriesContent.series.id))
|
||||
.innerJoin(seriesContent.content, audioContent)
|
||||
.where(where)
|
||||
.orderBy(series.orders.asc(), series.createdAt.asc())
|
||||
.groupBy(series.id)
|
||||
.orderBy(*orderBy.toTypedArray())
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
@@ -353,6 +367,7 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
override fun getOriginalAudioDramaList(
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
orderByRandom: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series> {
|
||||
@@ -381,7 +396,13 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
.selectFrom(series)
|
||||
.innerJoin(series.member, member)
|
||||
.where(where)
|
||||
.orderBy(series.id.desc())
|
||||
.orderBy(
|
||||
if (orderByRandom) {
|
||||
Expressions.numberTemplate(Double::class.java, "function('rand')").asc()
|
||||
} else {
|
||||
series.id.desc()
|
||||
}
|
||||
)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
|
||||
@@ -37,10 +37,11 @@ class ContentSeriesService(
|
||||
fun getOriginalAudioDramaList(
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
orderByRandom: Boolean = false,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<GetSeriesListResponse.SeriesListItem> {
|
||||
val originalAudioDramaList = repository.getOriginalAudioDramaList(isAdult, contentType, offset, limit)
|
||||
val originalAudioDramaList = repository.getOriginalAudioDramaList(isAdult, contentType, orderByRandom, offset, limit)
|
||||
return seriesToSeriesListItem(originalAudioDramaList, isAdult, contentType)
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ class ContentSeriesService(
|
||||
creatorId: Long?,
|
||||
isOriginal: Boolean = false,
|
||||
isCompleted: Boolean = false,
|
||||
orderByRandom: Boolean = false,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member,
|
||||
@@ -75,6 +77,7 @@ class ContentSeriesService(
|
||||
contentType = contentType,
|
||||
isOriginal = isOriginal,
|
||||
isCompleted = isCompleted,
|
||||
orderByRandom = orderByRandom,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
||||
|
||||
@@ -42,6 +42,7 @@ class SeriesMainController(
|
||||
val completedSeriesList = contentSeriesService.getSeriesList(
|
||||
creatorId = null,
|
||||
isCompleted = true,
|
||||
orderByRandom = true,
|
||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
member = member
|
||||
|
||||
@@ -27,6 +27,26 @@ class AudioContentThemeController(private val service: AudioContentThemeService)
|
||||
ApiResponse.ok(service.getThemes())
|
||||
}
|
||||
|
||||
@GetMapping("/active")
|
||||
fun getActiveThemes(
|
||||
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
||||
@RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null,
|
||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getActiveThemeOfContent(
|
||||
isAdult = member.auth != null && (isAdultContentVisible ?: true),
|
||||
isFree = isFree ?: false,
|
||||
isPointAvailableOnly = isPointAvailableOnly ?: false,
|
||||
contentType = contentType ?: ContentType.ALL
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/content")
|
||||
fun getContentByTheme(
|
||||
@PathVariable id: Long,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.content.theme
|
||||
|
||||
import com.querydsl.core.types.dsl.CaseBuilder
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.content.ContentType
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
@@ -32,6 +33,7 @@ class AudioContentThemeQueryRepository(
|
||||
fun getActiveThemeOfContent(
|
||||
isAdult: Boolean = false,
|
||||
isFree: Boolean = false,
|
||||
isPointAvailableOnly: Boolean = false,
|
||||
contentType: ContentType
|
||||
): List<String> {
|
||||
var where = audioContent.isActive.isTrue
|
||||
@@ -59,15 +61,31 @@ class AudioContentThemeQueryRepository(
|
||||
where = where.and(audioContent.price.loe(0))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
if (isPointAvailableOnly) {
|
||||
where = where.and(audioContent.isPointAvailable.isTrue)
|
||||
}
|
||||
|
||||
val query = queryFactory
|
||||
.select(audioContentTheme.theme)
|
||||
.from(audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
.where(where)
|
||||
.groupBy(audioContentTheme.id)
|
||||
.orderBy(audioContentTheme.orders.asc())
|
||||
.fetch()
|
||||
|
||||
if (isFree) {
|
||||
query.orderBy(
|
||||
CaseBuilder()
|
||||
.`when`(audioContentTheme.theme.eq("자기소개")).then(0)
|
||||
.otherwise(1)
|
||||
.asc(),
|
||||
audioContentTheme.orders.asc()
|
||||
)
|
||||
} else {
|
||||
query.orderBy(audioContentTheme.orders.asc())
|
||||
}
|
||||
|
||||
return query.fetch()
|
||||
}
|
||||
|
||||
fun findThemeByIdAndActive(id: Long): AudioContentTheme? {
|
||||
|
||||
@@ -23,11 +23,13 @@ class AudioContentThemeService(
|
||||
fun getActiveThemeOfContent(
|
||||
isAdult: Boolean = false,
|
||||
isFree: Boolean = false,
|
||||
isPointAvailableOnly: Boolean = false,
|
||||
contentType: ContentType
|
||||
): List<String> {
|
||||
return queryRepository.getActiveThemeOfContent(
|
||||
isAdult = isAdult,
|
||||
isFree = isFree,
|
||||
isPointAvailableOnly = isPointAvailableOnly,
|
||||
contentType = contentType
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user