diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/CreatorResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/CreatorResponse.kt index c5b8f8b..1252cca 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/CreatorResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/CreatorResponse.kt @@ -10,6 +10,8 @@ data class CreatorResponse( val youtubeUrl: String? = null, val websiteUrl: String? = null, val blogUrl: String? = null, + val isFollow: Boolean, + val isNotify: Boolean, val isNotification: Boolean, val notificationRecipientCount: Int ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt index 766c7fa..8ba7e48 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerQueryRepository.kt @@ -46,6 +46,18 @@ class ExplorerQueryRepository( @Value("\${cloud.aws.cloud-front.host}") private val cloudFrontHost: String ) { + fun getCreatorFollowing(creatorId: Long, memberId: Long): GetCreatorFollowingResponse { + return queryFactory + .select(QGetCreatorFollowingResponse(creatorFollowing.isActive, creatorFollowing.isNotify)) + .from(creatorFollowing) + .where( + creatorFollowing.isActive.isTrue + .and(creatorFollowing.creator.id.eq(creatorId)) + .and(creatorFollowing.member.id.eq(memberId)) + ) + .fetchFirst() + } + fun getNotificationUserIds(creatorId: Long): List { return queryFactory .select(creatorFollowing.member.id) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt index f6c620f..e40e2b6 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt @@ -145,7 +145,7 @@ class ExplorerService( if (isBlocked) throw SodaException("${creatorAccount.nickname}님의 요청으로 채널 접근이 제한됩니다.") val notificationUserIds = queryRepository.getNotificationUserIds(creatorId) - val isNotification = notificationUserIds.contains(member.id) + val creatorFollowing = queryRepository.getCreatorFollowing(creatorId = creatorId, memberId = member.id!!) val notificationRecipientCount = notificationUserIds.size // 후원랭킹 @@ -223,7 +223,9 @@ class ExplorerService( youtubeUrl = creatorAccount.youtubeUrl, websiteUrl = creatorAccount.websiteUrl, blogUrl = creatorAccount.blogUrl, - isNotification = isNotification, + isFollow = creatorFollowing.isFollow, + isNotify = creatorFollowing.isNotify, + isNotification = creatorFollowing.isFollow, notificationRecipientCount = notificationRecipientCount ), userDonationRanking = memberDonationRanking, diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/GetCreatorFollowingResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/GetCreatorFollowingResponse.kt new file mode 100644 index 0000000..2edb497 --- /dev/null +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/GetCreatorFollowingResponse.kt @@ -0,0 +1,5 @@ +package kr.co.vividnext.sodalive.explorer + +import com.querydsl.core.annotations.QueryProjection + +data class GetCreatorFollowingResponse @QueryProjection constructor(val isFollow: Boolean, val isNotify: Boolean)