콘텐츠 상단 고정 기능 추가 #120
@@ -554,6 +554,25 @@ class AudioContentService(
 | 
				
			|||||||
            null
 | 
					            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(
 | 
					        return GetAudioContentDetailResponse(
 | 
				
			||||||
            contentId = audioContent.id!!,
 | 
					            contentId = audioContent.id!!,
 | 
				
			||||||
            title = audioContent.title,
 | 
					            title = audioContent.title,
 | 
				
			||||||
@@ -579,6 +598,8 @@ class AudioContentService(
 | 
				
			|||||||
            likeCount = likeCount,
 | 
					            likeCount = likeCount,
 | 
				
			||||||
            commentList = commentList,
 | 
					            commentList = commentList,
 | 
				
			||||||
            commentCount = commentCount,
 | 
					            commentCount = commentCount,
 | 
				
			||||||
 | 
					            isPin = isPin,
 | 
				
			||||||
 | 
					            isAvailablePin = isAvailablePin,
 | 
				
			||||||
            creator = AudioContentCreator(
 | 
					            creator = AudioContentCreator(
 | 
				
			||||||
                creatorId = creatorId,
 | 
					                creatorId = creatorId,
 | 
				
			||||||
                nickname = creator.nickname,
 | 
					                nickname = creator.nickname,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,8 @@ data class GetAudioContentDetailResponse(
 | 
				
			|||||||
    val likeCount: Int,
 | 
					    val likeCount: Int,
 | 
				
			||||||
    val commentList: List<GetAudioContentCommentListItem>,
 | 
					    val commentList: List<GetAudioContentCommentListItem>,
 | 
				
			||||||
    val commentCount: Int,
 | 
					    val commentCount: Int,
 | 
				
			||||||
 | 
					    val isPin: Boolean,
 | 
				
			||||||
 | 
					    val isAvailablePin: Boolean,
 | 
				
			||||||
    val creator: AudioContentCreator
 | 
					    val creator: AudioContentCreator
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ interface PinContentRepository : JpaRepository<PinContent, Long>, PinContentQuer
 | 
				
			|||||||
interface PinContentQueryRepository {
 | 
					interface PinContentQueryRepository {
 | 
				
			||||||
    fun getPinContentList(memberId: Long): List<PinContent>
 | 
					    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 {
 | 
					class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : PinContentQueryRepository {
 | 
				
			||||||
@@ -21,13 +21,18 @@ class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) :
 | 
				
			|||||||
            .fetch()
 | 
					            .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
 | 
					        return queryFactory
 | 
				
			||||||
            .selectFrom(pinContent)
 | 
					            .selectFrom(pinContent)
 | 
				
			||||||
            .where(
 | 
					            .where(where)
 | 
				
			||||||
                pinContent.content.id.eq(contentId)
 | 
					 | 
				
			||||||
                    .and(pinContent.member.id.eq(memberId))
 | 
					 | 
				
			||||||
            )
 | 
					 | 
				
			||||||
            .fetchFirst()
 | 
					            .fetchFirst()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user