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