parent
dd5c121f1f
commit
5759a51017
|
@ -652,6 +652,16 @@ class AudioContentService(
|
|||
audioContent.detail
|
||||
}
|
||||
|
||||
val buyerList = if (
|
||||
audioContent.member?.id == member.id &&
|
||||
audioContent.limited != null &&
|
||||
audioContent.remaining != null
|
||||
) {
|
||||
orderRepository.findBuyerListByContentId(id)
|
||||
} else {
|
||||
listOf()
|
||||
}
|
||||
|
||||
return GetAudioContentDetailResponse(
|
||||
contentId = audioContent.id!!,
|
||||
title = audioContent.title,
|
||||
|
@ -696,7 +706,8 @@ class AudioContentService(
|
|||
isNotify = creatorFollowing?.isNotify ?: false
|
||||
),
|
||||
previousContent = previousContent,
|
||||
nextContent = nextContent
|
||||
nextContent = nextContent,
|
||||
buyerList = buyerList
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ data class GetAudioContentDetailResponse(
|
|||
val isAvailablePin: Boolean,
|
||||
val creator: AudioContentCreator,
|
||||
val previousContent: OtherContentResponse?,
|
||||
val nextContent: OtherContentResponse?
|
||||
val nextContent: OtherContentResponse?,
|
||||
val buyerList: List<ContentBuyer>
|
||||
)
|
||||
|
||||
data class OtherContentResponse @QueryProjection constructor(
|
||||
|
@ -54,3 +55,8 @@ data class AudioContentCreator(
|
|||
val isFollow: Boolean,
|
||||
val isNotify: Boolean
|
||||
)
|
||||
|
||||
data class ContentBuyer @QueryProjection constructor(
|
||||
val nickname: String,
|
||||
val profileImageUrl: String
|
||||
)
|
||||
|
|
|
@ -2,13 +2,16 @@ package kr.co.vividnext.sodalive.content.order
|
|||
|
||||
import com.querydsl.core.types.dsl.Expressions
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.content.ContentBuyer
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.content.QContentBuyer
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.content.main.QGetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.content.order.QOrder.order
|
||||
import kr.co.vividnext.sodalive.content.playlist.ContentIdAndEndDateData
|
||||
import kr.co.vividnext.sodalive.content.playlist.QContentIdAndEndDateData
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.Duration
|
||||
|
@ -40,10 +43,16 @@ interface OrderQueryRepository {
|
|||
|
||||
fun findOrderedContent(contentIdList: List<Long>, memberId: Long): List<Long>
|
||||
fun findEndDateByContentId(contentIdList: List<Long>, memberId: Long): List<ContentIdAndEndDateData>
|
||||
fun findBuyerListByContentId(contentId: Long): List<ContentBuyer>
|
||||
}
|
||||
|
||||
@Repository
|
||||
class OrderQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : OrderQueryRepository {
|
||||
class OrderQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val imageHost: String
|
||||
) : OrderQueryRepository {
|
||||
override fun isExistOrdered(memberId: Long, contentId: Long): Boolean {
|
||||
return queryFactory
|
||||
.select(order.id)
|
||||
|
@ -253,4 +262,22 @@ class OrderQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Orde
|
|||
)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun findBuyerListByContentId(contentId: Long): List<ContentBuyer> {
|
||||
return queryFactory
|
||||
.select(
|
||||
QContentBuyer(
|
||||
member.nickname,
|
||||
member.profileImage.prepend("/").prepend(imageHost)
|
||||
)
|
||||
)
|
||||
.from(order)
|
||||
.innerJoin(order.member, member)
|
||||
.where(
|
||||
order.isActive.isTrue,
|
||||
order.audioContent.id.eq(contentId),
|
||||
member.isActive.isTrue
|
||||
)
|
||||
.fetch()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue