Compare commits
10 Commits
3a57ad23bb
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 587f3d6b58 | |||
| 76806e2e90 | |||
| 39c51825da | |||
| 9b6167d46d | |||
| 9a58b7b95f | |||
| 26eae4b06e | |||
| 008ee3b4e5 | |||
| 60989391f6 | |||
| 88d90eec2f | |||
| b6eb13df06 |
@@ -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
|
||||
|
||||
@@ -180,6 +180,7 @@ interface AudioContentQueryRepository {
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
sortType: SortType,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean,
|
||||
orderByRandom: Boolean = false,
|
||||
@@ -241,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)
|
||||
@@ -462,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
|
||||
@@ -1297,6 +1305,7 @@ class AudioContentQueryRepositoryImpl(
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
sortType: SortType,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean,
|
||||
orderByRandom: Boolean,
|
||||
@@ -1342,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
|
||||
@@ -1429,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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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