test #326
|
@ -9,17 +9,18 @@ import org.springframework.stereotype.Repository
|
||||||
interface UseCanRepository : JpaRepository<UseCan, Long>, UseCanQueryRepository
|
interface UseCanRepository : JpaRepository<UseCan, Long>, UseCanQueryRepository
|
||||||
|
|
||||||
interface UseCanQueryRepository {
|
interface UseCanQueryRepository {
|
||||||
fun isExistOrdered(postId: Long, memberId: Long): Boolean
|
fun isExistCommunityPostOrdered(postId: Long, memberId: Long): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
class UseCanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : UseCanQueryRepository {
|
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)
|
val useCanId = queryFactory.select(useCan.id)
|
||||||
.from(useCan)
|
.from(useCan)
|
||||||
.where(
|
.where(
|
||||||
useCan.member.id.eq(memberId)
|
useCan.member.id.eq(memberId)
|
||||||
.and(useCan.isRefund.isFalse)
|
.and(useCan.isRefund.isFalse)
|
||||||
.and(useCan.communityPost.id.eq(postId))
|
.and(useCan.communityPost.id.eq(postId))
|
||||||
|
.and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST))
|
||||||
)
|
)
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ class CreatorCommunityController(private val service: CreatorCommunityService) {
|
||||||
comment = request.comment,
|
comment = request.comment,
|
||||||
postId = request.postId,
|
postId = request.postId,
|
||||||
parentId = request.parentId,
|
parentId = request.parentId,
|
||||||
|
isSecret = request.isSecret,
|
||||||
member = member
|
member = member
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -212,7 +212,7 @@ class CreatorCommunityService(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId)
|
val existOrdered = useCanRepository.isExistCommunityPostOrdered(postId = it.id, memberId = memberId)
|
||||||
|
|
||||||
val audioUrl = if (
|
val audioUrl = if (
|
||||||
(
|
(
|
||||||
|
@ -285,7 +285,7 @@ class CreatorCommunityService(
|
||||||
null
|
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) {
|
val audioUrl = if ((post.price <= 0 || existOrdered) && post.audioPath != null) {
|
||||||
audioContentCloudFront.generateSignedURL(
|
audioContentCloudFront.generateSignedURL(
|
||||||
|
@ -347,11 +347,22 @@ class CreatorCommunityService(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@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)
|
val post = repository.findByIdOrNull(id = postId)
|
||||||
?: throw SodaException("잘못된 게시물 입니다.\n다시 시도해 주세요.")
|
?: 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.creatorCommunity = post
|
||||||
postComment.member = member
|
postComment.member = member
|
||||||
|
|
||||||
|
@ -465,7 +476,7 @@ class CreatorCommunityService(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId)
|
val existOrdered = useCanRepository.isExistCommunityPostOrdered(postId = it.id, memberId = memberId)
|
||||||
|
|
||||||
it.toCommunityPostListResponse(
|
it.toCommunityPostListResponse(
|
||||||
imageHost = imageHost,
|
imageHost = imageHost,
|
||||||
|
@ -499,7 +510,7 @@ class CreatorCommunityService(
|
||||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = post.member!!.id!!)
|
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = post.member!!.id!!)
|
||||||
if (isBlocked) throw SodaException("${post.member!!.nickname}님의 요청으로 접근이 제한됩니다.")
|
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) {
|
if (!existOrdered) {
|
||||||
canPaymentService.spendCan(
|
canPaymentService.spendCan(
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment
|
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
|
||||||
|
)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.persistence.OneToMany
|
||||||
data class CreatorCommunityComment(
|
data class CreatorCommunityComment(
|
||||||
@Column(columnDefinition = "TEXT", nullable = false)
|
@Column(columnDefinition = "TEXT", nullable = false)
|
||||||
var comment: String,
|
var comment: String,
|
||||||
|
val isSecret: Boolean = false,
|
||||||
var isActive: Boolean = true
|
var isActive: Boolean = true
|
||||||
) : BaseEntity() {
|
) : BaseEntity() {
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
|
Loading…
Reference in New Issue