feat(community): 채널 커뮤니티 좋아요 조회를 추가한다

This commit is contained in:
2026-06-30 01:09:56 +09:00
parent 16ec1240bb
commit fc7143d0bb
2 changed files with 35 additions and 4 deletions

View File

@@ -186,6 +186,7 @@ class DefaultCreatorChannelCommunityQueryRepository(
val postIds = map { it.postId }
val orderedPostIds = orderedCommunityPostIds(creatorId, viewerId, postIds)
val likeCounts = communityLikeCounts(postIds)
val likedPostIds = likedCommunityPostIds(viewerId, postIds)
val commentAvailablePostIds = filter { it.isCommentAvailable }.map { it.postId }
val commentCounts = communityCommentCounts(commentAvailablePostIds, creatorId, viewerId)
@@ -206,7 +207,8 @@ class DefaultCreatorChannelCommunityQueryRepository(
isCommentAvailable = row.isCommentAvailable,
likeCount = likeCounts[postId] ?: 0,
commentCount = commentCounts[postId] ?: 0,
isPinned = isPinned
isPinned = isPinned,
isLiked = postId in likedPostIds
)
}
}
@@ -233,6 +235,22 @@ class DefaultCreatorChannelCommunityQueryRepository(
.toSet()
}
private fun likedCommunityPostIds(viewerId: Long, postIds: List<Long>): Set<Long> {
if (postIds.isEmpty()) return emptySet()
return queryFactory
.select(creatorCommunityLike.creatorCommunity.id)
.distinct()
.from(creatorCommunityLike)
.where(
creatorCommunityLike.member.id.eq(viewerId),
creatorCommunityLike.creatorCommunity.id.`in`(postIds),
creatorCommunityLike.isActive.isTrue
)
.fetch()
.toSet()
}
private fun communityLikeCounts(postIds: List<Long>): Map<Long, Int> {
if (postIds.isEmpty()) return emptyMap()