From 9516ce1c0faa03bdf590bbe0c480461065996076 Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 13 Sep 2024 12:02:43 +0900 Subject: [PATCH] =?UTF-8?q?=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=ED=94=84=EB=A1=9C=ED=95=84=20API=20-=20=EC=95=8C=EB=A6=BC?= =?UTF-8?q?=EA=B3=BC=20=ED=8C=94=EB=A1=9C=EC=9A=B0=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EA=B0=92=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vividnext/sodalive/explorer/CreatorResponse.kt | 2 ++ .../sodalive/explorer/ExplorerQueryRepository.kt | 12 ++++++++++++ .../vividnext/sodalive/explorer/ExplorerService.kt | 6 ++++-- .../sodalive/explorer/GetCreatorFollowingResponse.kt | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/kr/co/vividnext/sodalive/explorer/GetCreatorFollowingResponse.kt 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)