From 45e8b0d15558a3adde6feaf1d7ce46f197132bc3 Mon Sep 17 00:00:00 2001 From: Klaus Date: Thu, 29 Aug 2024 22:41:30 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=20=EB=93=B1=EB=A1=9D=20-=20=EB=B9=84=EB=B0=80=20?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EB=93=B1=EB=A1=9D=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 --- .../content/comment/AudioContentComment.kt | 1 + .../comment/AudioContentCommentController.kt | 1 + .../comment/AudioContentCommentService.kt | 21 +++++++++++++++++-- .../content/comment/RegisterCommentRequest.kt | 7 ++++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentComment.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentComment.kt index 0f345e3..a84e468 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentComment.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentComment.kt @@ -18,6 +18,7 @@ data class AudioContentComment( var comment: String, @Column(nullable = true) var donationCan: Int? = null, + val isSecret: Boolean = false, var isActive: Boolean = true ) : BaseEntity() { @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt index dc153e2..d400c55 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt @@ -27,6 +27,7 @@ class AudioContentCommentController(private val service: AudioContentCommentServ comment = request.comment, audioContentId = request.contentId, parentId = request.parentId, + isSecret = request.isSecret, member = member ) ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentService.kt index d41e3d6..0daafc3 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentService.kt @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.content.comment import kr.co.vividnext.sodalive.common.SodaException import kr.co.vividnext.sodalive.content.AudioContentRepository +import kr.co.vividnext.sodalive.content.order.OrderRepository import kr.co.vividnext.sodalive.fcm.FcmEvent import kr.co.vividnext.sodalive.fcm.FcmEventType import kr.co.vividnext.sodalive.member.Member @@ -20,12 +21,19 @@ class AudioContentCommentService( private val blockMemberRepository: BlockMemberRepository, private val audioContentRepository: AudioContentRepository, private val applicationEventPublisher: ApplicationEventPublisher, + private val orderRepository: OrderRepository, @Value("\${cloud.aws.cloud-front.host}") private val cloudFrontHost: String ) { @Transactional - fun registerComment(member: Member, comment: String, audioContentId: Long, parentId: Long? = null) { + fun registerComment( + member: Member, + comment: String, + audioContentId: Long, + parentId: Long? = null, + isSecret: Boolean = false + ) { val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId) ?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.") @@ -33,7 +41,16 @@ class AudioContentCommentService( val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = creator.id!!) if (isBlocked) throw SodaException("${creator.nickname}님의 요청으로 댓글쓰기가 제한됩니다.") - val audioContentComment = AudioContentComment(comment = comment) + val (isExistsAudioContent, _) = orderRepository.isExistOrderedAndOrderType( + memberId = member.id!!, + contentId = audioContent.id!! + ) + + if (isSecret && !isExistsAudioContent) { + throw SodaException("콘텐츠 구매 후 비밀댓글을 등록할 수 있습니다.") + } + + val audioContentComment = AudioContentComment(comment = comment, isSecret = isSecret) audioContentComment.audioContent = audioContent audioContentComment.member = member diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/RegisterCommentRequest.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/RegisterCommentRequest.kt index df29747..a5fc8ac 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/RegisterCommentRequest.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/RegisterCommentRequest.kt @@ -1,3 +1,8 @@ package kr.co.vividnext.sodalive.content.comment -data class RegisterCommentRequest(val comment: String, val contentId: Long, val parentId: Long?) +data class RegisterCommentRequest( + val comment: String, + val contentId: Long, + val parentId: Long?, + val isSecret: Boolean = false +)