parent
c8d7bdb8b7
commit
45e8b0d155
|
@ -18,6 +18,7 @@ data class AudioContentComment(
|
||||||
var comment: String,
|
var comment: String,
|
||||||
@Column(nullable = true)
|
@Column(nullable = true)
|
||||||
var donationCan: Int? = null,
|
var donationCan: Int? = null,
|
||||||
|
val isSecret: Boolean = false,
|
||||||
var isActive: Boolean = true
|
var isActive: Boolean = true
|
||||||
) : BaseEntity() {
|
) : BaseEntity() {
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
|
|
@ -27,6 +27,7 @@ class AudioContentCommentController(private val service: AudioContentCommentServ
|
||||||
comment = request.comment,
|
comment = request.comment,
|
||||||
audioContentId = request.contentId,
|
audioContentId = request.contentId,
|
||||||
parentId = request.parentId,
|
parentId = request.parentId,
|
||||||
|
isSecret = request.isSecret,
|
||||||
member = member
|
member = member
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.content.comment
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
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.FcmEvent
|
||||||
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
import kr.co.vividnext.sodalive.fcm.FcmEventType
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
@ -20,12 +21,19 @@ class AudioContentCommentService(
|
||||||
private val blockMemberRepository: BlockMemberRepository,
|
private val blockMemberRepository: BlockMemberRepository,
|
||||||
private val audioContentRepository: AudioContentRepository,
|
private val audioContentRepository: AudioContentRepository,
|
||||||
private val applicationEventPublisher: ApplicationEventPublisher,
|
private val applicationEventPublisher: ApplicationEventPublisher,
|
||||||
|
private val orderRepository: OrderRepository,
|
||||||
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val cloudFrontHost: String
|
private val cloudFrontHost: String
|
||||||
) {
|
) {
|
||||||
@Transactional
|
@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)
|
val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId)
|
||||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
||||||
|
|
||||||
|
@ -33,7 +41,16 @@ class AudioContentCommentService(
|
||||||
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = creator.id!!)
|
val isBlocked = blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = creator.id!!)
|
||||||
if (isBlocked) throw SodaException("${creator.nickname}님의 요청으로 댓글쓰기가 제한됩니다.")
|
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.audioContent = audioContent
|
||||||
audioContentComment.member = member
|
audioContentComment.member = member
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
package kr.co.vividnext.sodalive.content.comment
|
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
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue