parent
4a27a825a1
commit
da1c096b45
|
@ -34,11 +34,12 @@ interface AudioContentQueryRepository {
|
||||||
fun findBundleByContentId(contentId: Long): List<AudioContent>
|
fun findBundleByContentId(contentId: Long): List<AudioContent>
|
||||||
fun findByCreatorId(
|
fun findByCreatorId(
|
||||||
creatorId: Long,
|
creatorId: Long,
|
||||||
|
coverImageHost: String,
|
||||||
isAdult: Boolean = false,
|
isAdult: Boolean = false,
|
||||||
sortType: SortType = SortType.NEWEST,
|
sortType: SortType = SortType.NEWEST,
|
||||||
offset: Long = 0,
|
offset: Long = 0,
|
||||||
limit: Long = 10
|
limit: Long = 10
|
||||||
): List<AudioContent>
|
): List<GetAudioContentListItem>
|
||||||
|
|
||||||
fun findTotalCountByCreatorId(creatorId: Long, isAdult: Boolean = false): Int
|
fun findTotalCountByCreatorId(creatorId: Long, isAdult: Boolean = false): Int
|
||||||
fun getCreatorOtherContentList(
|
fun getCreatorOtherContentList(
|
||||||
|
@ -140,11 +141,12 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
|
|
||||||
override fun findByCreatorId(
|
override fun findByCreatorId(
|
||||||
creatorId: Long,
|
creatorId: Long,
|
||||||
|
coverImageHost: String,
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
sortType: SortType,
|
sortType: SortType,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<AudioContent> {
|
): List<GetAudioContentListItem> {
|
||||||
val orderBy = when (sortType) {
|
val orderBy = when (sortType) {
|
||||||
SortType.NEWEST -> audioContent.releaseDate.desc()
|
SortType.NEWEST -> audioContent.releaseDate.desc()
|
||||||
SortType.PRICE_HIGH -> audioContent.price.desc()
|
SortType.PRICE_HIGH -> audioContent.price.desc()
|
||||||
|
@ -162,7 +164,21 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(audioContent)
|
.select(
|
||||||
|
QGetAudioContentListItem(
|
||||||
|
audioContent.id,
|
||||||
|
audioContent.coverImage.prepend(coverImageHost),
|
||||||
|
audioContent.title,
|
||||||
|
audioContent.price,
|
||||||
|
audioContent.theme.theme,
|
||||||
|
audioContent.duration,
|
||||||
|
Expressions.constant(0),
|
||||||
|
Expressions.constant(0),
|
||||||
|
pinContent.id.isNotNull,
|
||||||
|
audioContent.isAdult,
|
||||||
|
audioContent.releaseDate.gt(LocalDateTime.now())
|
||||||
|
)
|
||||||
|
)
|
||||||
.from(audioContent)
|
.from(audioContent)
|
||||||
.leftJoin(pinContent)
|
.leftJoin(pinContent)
|
||||||
.on(audioContent.id.eq(pinContent.content.id).and(pinContent.isActive.ne(false)))
|
.on(audioContent.id.eq(pinContent.content.id).and(pinContent.isActive.ne(false)))
|
||||||
|
|
|
@ -627,6 +627,7 @@ class AudioContentService(
|
||||||
|
|
||||||
val audioContentList = repository.findByCreatorId(
|
val audioContentList = repository.findByCreatorId(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
|
coverImageHost = coverImageHost,
|
||||||
isAdult = member.auth != null,
|
isAdult = member.auth != null,
|
||||||
sortType = sortType,
|
sortType = sortType,
|
||||||
offset = offset,
|
offset = offset,
|
||||||
|
@ -636,23 +637,15 @@ class AudioContentService(
|
||||||
val items = audioContentList
|
val items = audioContentList
|
||||||
.map {
|
.map {
|
||||||
val commentCount = commentRepository
|
val commentCount = commentRepository
|
||||||
.totalCountCommentByContentId(it.id!!)
|
.totalCountCommentByContentId(it.contentId)
|
||||||
|
|
||||||
val likeCount = audioContentLikeRepository
|
val likeCount = audioContentLikeRepository
|
||||||
.totalCountAudioContentLike(it.id!!)
|
.totalCountAudioContentLike(it.contentId)
|
||||||
|
|
||||||
GetAudioContentListItem(
|
it.likeCount = likeCount
|
||||||
contentId = it.id!!,
|
it.commentCount = commentCount
|
||||||
coverImageUrl = "$coverImageHost/${it.coverImage!!}",
|
|
||||||
title = it.title,
|
it
|
||||||
price = it.price,
|
|
||||||
themeStr = it.theme!!.theme,
|
|
||||||
duration = it.duration,
|
|
||||||
likeCount = likeCount,
|
|
||||||
commentCount = commentCount,
|
|
||||||
isAdult = it.isAdult,
|
|
||||||
isScheduledToOpen = it.releaseDate != null && it.releaseDate!! > LocalDateTime.now()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetAudioContentListResponse(
|
return GetAudioContentListResponse(
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
package kr.co.vividnext.sodalive.content
|
package kr.co.vividnext.sodalive.content
|
||||||
|
|
||||||
|
import com.querydsl.core.annotations.QueryProjection
|
||||||
|
|
||||||
data class GetAudioContentListResponse(
|
data class GetAudioContentListResponse(
|
||||||
val totalCount: Int,
|
val totalCount: Int,
|
||||||
val items: List<GetAudioContentListItem>
|
val items: List<GetAudioContentListItem>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class GetAudioContentListItem(
|
data class GetAudioContentListItem @QueryProjection constructor(
|
||||||
val contentId: Long,
|
val contentId: Long,
|
||||||
val coverImageUrl: String,
|
val coverImageUrl: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val price: Int,
|
val price: Int,
|
||||||
val themeStr: String,
|
val themeStr: String,
|
||||||
val duration: String?,
|
val duration: String?,
|
||||||
val likeCount: Int,
|
var likeCount: Int = 0,
|
||||||
val commentCount: Int,
|
var commentCount: Int = 0,
|
||||||
|
val isPin: Boolean,
|
||||||
val isAdult: Boolean,
|
val isAdult: Boolean,
|
||||||
val isScheduledToOpen: Boolean
|
val isScheduledToOpen: Boolean
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue