parent
711842f00d
commit
443818efb5
|
@ -554,6 +554,25 @@ class AudioContentService(
|
|||
null
|
||||
}
|
||||
|
||||
val pinContent = pinContentRepository.findByContentIdAndMemberId(
|
||||
contentId = id,
|
||||
memberId = member.id!!,
|
||||
active = true
|
||||
)
|
||||
|
||||
val isPin = if (member.id!! == audioContent.member!!.id!!) {
|
||||
pinContent != null
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
val pinContentListCount = pinContentRepository.getPinContentList(memberId = member.id!!).size
|
||||
val isAvailablePin = if (member.id!! == audioContent.member!!.id!!) {
|
||||
pinContentListCount < 3
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
return GetAudioContentDetailResponse(
|
||||
contentId = audioContent.id!!,
|
||||
title = audioContent.title,
|
||||
|
@ -579,6 +598,8 @@ class AudioContentService(
|
|||
likeCount = likeCount,
|
||||
commentList = commentList,
|
||||
commentCount = commentCount,
|
||||
isPin = isPin,
|
||||
isAvailablePin = isAvailablePin,
|
||||
creator = AudioContentCreator(
|
||||
creatorId = creatorId,
|
||||
nickname = creator.nickname,
|
||||
|
|
|
@ -29,6 +29,8 @@ data class GetAudioContentDetailResponse(
|
|||
val likeCount: Int,
|
||||
val commentList: List<GetAudioContentCommentListItem>,
|
||||
val commentCount: Int,
|
||||
val isPin: Boolean,
|
||||
val isAvailablePin: Boolean,
|
||||
val creator: AudioContentCreator
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ interface PinContentRepository : JpaRepository<PinContent, Long>, PinContentQuer
|
|||
interface PinContentQueryRepository {
|
||||
fun getPinContentList(memberId: Long): List<PinContent>
|
||||
|
||||
fun findByContentIdAndMemberId(contentId: Long, memberId: Long): PinContent?
|
||||
fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean? = null): PinContent?
|
||||
}
|
||||
|
||||
class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : PinContentQueryRepository {
|
||||
|
@ -21,13 +21,18 @@ class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) :
|
|||
.fetch()
|
||||
}
|
||||
|
||||
override fun findByContentIdAndMemberId(contentId: Long, memberId: Long): PinContent? {
|
||||
override fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean?): PinContent? {
|
||||
var where = pinContent.content.id.eq(contentId)
|
||||
.and(pinContent.member.id.eq(memberId))
|
||||
|
||||
if (active != null) {
|
||||
where = where
|
||||
.and(pinContent.isActive.eq(active))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(pinContent)
|
||||
.where(
|
||||
pinContent.content.id.eq(contentId)
|
||||
.and(pinContent.member.id.eq(memberId))
|
||||
)
|
||||
.where(where)
|
||||
.fetchFirst()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue