From 8e01ced1f5286283489d0bcb2d23f8c2ed5fda90 Mon Sep 17 00:00:00 2001 From: Klaus <klaus@vividnext.co.kr> Date: Thu, 12 Jun 2025 16:10:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=BB=A4=EB=AE=A4=EB=8B=88=ED=8B=B0=20?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20-=20=EC=9C=A0=EB=A3=8C=20=EC=BB=A4?= =?UTF-8?q?=EB=AE=A4=EB=8B=88=ED=8B=B0=20=EA=B8=80=EC=9D=84=20=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=9C=20=EA=B2=BD=EC=9A=B0=20=EB=B9=84=EB=B0=80=20?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=93=B0=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/can/use/UseCanRepository.kt | 5 ++-- .../CreatorCommunityController.kt | 1 + .../CreatorCommunityService.kt | 23 ++++++++++++++----- .../CreateCommunityPostCommentRequest.kt | 7 +++++- .../comment/CreatorCommunityComment.kt | 1 + 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/use/UseCanRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/use/UseCanRepository.kt index eeac478..07bdce1 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/use/UseCanRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/use/UseCanRepository.kt @@ -9,17 +9,18 @@ import org.springframework.stereotype.Repository interface UseCanRepository : JpaRepository<UseCan, Long>, UseCanQueryRepository interface UseCanQueryRepository { - fun isExistOrdered(postId: Long, memberId: Long): Boolean + fun isExistCommunityPostOrdered(postId: Long, memberId: Long): Boolean } class UseCanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : UseCanQueryRepository { - override fun isExistOrdered(postId: Long, memberId: Long): Boolean { + override fun isExistCommunityPostOrdered(postId: Long, memberId: Long): Boolean { val useCanId = queryFactory.select(useCan.id) .from(useCan) .where( useCan.member.id.eq(memberId) .and(useCan.isRefund.isFalse) .and(useCan.communityPost.id.eq(postId)) + .and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST)) ) .fetchFirst() diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt index 85c61b8..62ce8ca 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt @@ -129,6 +129,7 @@ class CreatorCommunityController(private val service: CreatorCommunityService) { comment = request.comment, postId = request.postId, parentId = request.parentId, + isSecret = request.isSecret, member = member ) ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt index 7e483f9..06a7c96 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt @@ -212,7 +212,7 @@ class CreatorCommunityService( null } - val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId) + val existOrdered = useCanRepository.isExistCommunityPostOrdered(postId = it.id, memberId = memberId) val audioUrl = if ( ( @@ -285,7 +285,7 @@ class CreatorCommunityService( null } - val existOrdered = useCanRepository.isExistOrdered(postId = post.id, memberId = memberId) + val existOrdered = useCanRepository.isExistCommunityPostOrdered(postId = post.id, memberId = memberId) val audioUrl = if ((post.price <= 0 || existOrdered) && post.audioPath != null) { audioContentCloudFront.generateSignedURL( @@ -347,11 +347,22 @@ class CreatorCommunityService( } @Transactional - fun createCommunityPostComment(comment: String, postId: Long, parentId: Long?, member: Member) { + fun createCommunityPostComment( + member: Member, + comment: String, + postId: Long, + parentId: Long? = null, + isSecret: Boolean = false + ) { val post = repository.findByIdOrNull(id = postId) ?: throw SodaException("잘못된 게시물 입니다.\n다시 시도해 주세요.") + val isExistOrdered = useCanRepository.isExistCommunityPostOrdered(postId = postId, memberId = member.id!!) - val postComment = CreatorCommunityComment(comment = comment) + if (isSecret && !isExistOrdered) { + throw SodaException("게시글을 구매 후 비밀댓글을 등록할 수 있습니다.") + } + + val postComment = CreatorCommunityComment(comment = comment, isSecret = isSecret) postComment.creatorCommunity = post postComment.member = member @@ -465,7 +476,7 @@ class CreatorCommunityService( null } - val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId) + val existOrdered = useCanRepository.isExistCommunityPostOrdered(postId = it.id, memberId = memberId) it.toCommunityPostListResponse( imageHost = imageHost, @@ -499,7 +510,7 @@ class CreatorCommunityService( val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = post.member!!.id!!) if (isBlocked) throw SodaException("${post.member!!.nickname}님의 요청으로 접근이 제한됩니다.") - val existOrdered = useCanRepository.isExistOrdered(postId = postId, memberId = memberId) + val existOrdered = useCanRepository.isExistCommunityPostOrdered(postId = postId, memberId = memberId) if (!existOrdered) { canPaymentService.spendCan( diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreateCommunityPostCommentRequest.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreateCommunityPostCommentRequest.kt index 5e833d6..bd01576 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreateCommunityPostCommentRequest.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreateCommunityPostCommentRequest.kt @@ -1,3 +1,8 @@ package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment -data class CreateCommunityPostCommentRequest(val comment: String, val postId: Long, val parentId: Long?) +data class CreateCommunityPostCommentRequest( + val comment: String, + val postId: Long, + val parentId: Long?, + val isSecret: Boolean = false +) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreatorCommunityComment.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreatorCommunityComment.kt index 6e65c0a..84af1c1 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreatorCommunityComment.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/comment/CreatorCommunityComment.kt @@ -14,6 +14,7 @@ import javax.persistence.OneToMany data class CreatorCommunityComment( @Column(columnDefinition = "TEXT", nullable = false) var comment: String, + val isSecret: Boolean = false, var isActive: Boolean = true ) : BaseEntity() { @ManyToOne(fetch = FetchType.LAZY)