feat: 커뮤니티 댓글

- 유료 커뮤니티 글을 구매한 경우 비밀 댓글 쓰기 기능 추가
This commit is contained in:
Klaus 2025-06-12 16:10:32 +09:00
parent 640f5ce6f5
commit 8e01ced1f5
5 changed files with 28 additions and 9 deletions

View File

@ -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()

View File

@ -129,6 +129,7 @@ class CreatorCommunityController(private val service: CreatorCommunityService) {
comment = request.comment,
postId = request.postId,
parentId = request.parentId,
isSecret = request.isSecret,
member = member
)
)

View File

@ -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(

View File

@ -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
)

View File

@ -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)