Compare commits
No commits in common. "1e4b47f98995065d97cbfc4f399c5d2c19b0760d" and "ff255dbfae6941678de599ff54693be11e6c202f" have entirely different histories.
1e4b47f989
...
ff255dbfae
|
@ -111,8 +111,6 @@ interface AudioContentQueryRepository {
|
||||||
fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration>
|
fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration>
|
||||||
|
|
||||||
fun getNotReleaseContentId(): List<Long>
|
fun getNotReleaseContentId(): List<Long>
|
||||||
|
|
||||||
fun isContentCreator(contentId: Long, memberId: Long): Boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -723,19 +721,4 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
.where(where)
|
.where(where)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isContentCreator(contentId: Long, memberId: Long): Boolean {
|
|
||||||
val foundedContentId = queryFactory
|
|
||||||
.select(audioContent.id)
|
|
||||||
.from(audioContent)
|
|
||||||
.innerJoin(audioContent.member, member)
|
|
||||||
.where(
|
|
||||||
audioContent.isActive.isTrue
|
|
||||||
.and(audioContent.id.eq(contentId))
|
|
||||||
.and(audioContent.member.id.eq(memberId))
|
|
||||||
)
|
|
||||||
.fetchOne()
|
|
||||||
|
|
||||||
return foundedContentId != null && foundedContentId == contentId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,8 +492,6 @@ class AudioContentService(
|
||||||
commentRepository.findByContentId(
|
commentRepository.findByContentId(
|
||||||
cloudFrontHost = coverImageHost,
|
cloudFrontHost = coverImageHost,
|
||||||
contentId = audioContent.id!!,
|
contentId = audioContent.id!!,
|
||||||
memberId = member.id!!,
|
|
||||||
isContentCreator = creatorId == member.id!!,
|
|
||||||
timezone = timezone,
|
timezone = timezone,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
limit = 1
|
limit = 1
|
||||||
|
@ -504,11 +502,7 @@ class AudioContentService(
|
||||||
|
|
||||||
// 댓글 수
|
// 댓글 수
|
||||||
val commentCount = if (audioContent.isCommentAvailable) {
|
val commentCount = if (audioContent.isCommentAvailable) {
|
||||||
commentRepository.totalCountCommentByContentId(
|
commentRepository.totalCountCommentByContentId(contentId = audioContent.id!!)
|
||||||
contentId = audioContent.id!!,
|
|
||||||
memberId = member.id!!,
|
|
||||||
isContentCreator = creatorId == member.id!!
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -672,11 +666,7 @@ class AudioContentService(
|
||||||
val items = audioContentList
|
val items = audioContentList
|
||||||
.map {
|
.map {
|
||||||
val commentCount = commentRepository
|
val commentCount = commentRepository
|
||||||
.totalCountCommentByContentId(
|
.totalCountCommentByContentId(it.contentId)
|
||||||
it.contentId,
|
|
||||||
memberId = member.id!!,
|
|
||||||
isContentCreator = creatorId == member.id!!
|
|
||||||
)
|
|
||||||
it.commentCount = commentCount
|
it.commentCount = commentCount
|
||||||
|
|
||||||
val likeCount = audioContentLikeRepository
|
val likeCount = audioContentLikeRepository
|
||||||
|
|
|
@ -18,7 +18,6 @@ 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,7 +27,6 @@ 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
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -55,7 +54,6 @@ class AudioContentCommentController(private val service: AudioContentCommentServ
|
||||||
ApiResponse.ok(
|
ApiResponse.ok(
|
||||||
service.getCommentList(
|
service.getCommentList(
|
||||||
audioContentId = audioContentId,
|
audioContentId = audioContentId,
|
||||||
memberId = member.id!!,
|
|
||||||
timezone = timezone,
|
timezone = timezone,
|
||||||
pageable = pageable
|
pageable = pageable
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,14 +16,12 @@ interface AudioContentCommentQueryRepository {
|
||||||
fun findByContentId(
|
fun findByContentId(
|
||||||
cloudFrontHost: String,
|
cloudFrontHost: String,
|
||||||
contentId: Long,
|
contentId: Long,
|
||||||
memberId: Long,
|
|
||||||
isContentCreator: Boolean,
|
|
||||||
timezone: String,
|
timezone: String,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Int
|
limit: Int
|
||||||
): List<GetAudioContentCommentListItem>
|
): List<GetAudioContentCommentListItem>
|
||||||
|
|
||||||
fun totalCountCommentByContentId(contentId: Long, memberId: Long, isContentCreator: Boolean): Int
|
fun totalCountCommentByContentId(contentId: Long): Int
|
||||||
fun commentReplyCountByAudioContentCommentId(commentId: Long): Int
|
fun commentReplyCountByAudioContentCommentId(commentId: Long): Int
|
||||||
fun getAudioContentCommentReplyList(
|
fun getAudioContentCommentReplyList(
|
||||||
cloudFrontHost: String,
|
cloudFrontHost: String,
|
||||||
|
@ -47,32 +45,21 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||||
override fun findByContentId(
|
override fun findByContentId(
|
||||||
cloudFrontHost: String,
|
cloudFrontHost: String,
|
||||||
contentId: Long,
|
contentId: Long,
|
||||||
memberId: Long,
|
|
||||||
isContentCreator: Boolean,
|
|
||||||
timezone: String,
|
timezone: String,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Int
|
limit: Int
|
||||||
): List<GetAudioContentCommentListItem> {
|
): List<GetAudioContentCommentListItem> {
|
||||||
var where = audioContentComment.audioContent.id.eq(contentId)
|
return queryFactory.selectFrom(audioContentComment)
|
||||||
|
.where(
|
||||||
|
audioContentComment.audioContent.id.eq(contentId)
|
||||||
.and(audioContentComment.isActive.isTrue)
|
.and(audioContentComment.isActive.isTrue)
|
||||||
.and(audioContentComment.parent.isNull)
|
.and(audioContentComment.parent.isNull)
|
||||||
|
|
||||||
if (!isContentCreator) {
|
|
||||||
where = where.and(
|
|
||||||
audioContentComment.isSecret.isFalse
|
|
||||||
.or(audioContentComment.member.id.eq(memberId))
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
return queryFactory
|
|
||||||
.selectFrom(audioContentComment)
|
|
||||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
|
||||||
.innerJoin(audioContentComment.member, member)
|
|
||||||
.where(where)
|
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit.toLong())
|
.limit(limit.toLong())
|
||||||
.orderBy(audioContentComment.createdAt.desc())
|
.orderBy(audioContentComment.createdAt.desc())
|
||||||
.fetch()
|
.fetch()
|
||||||
|
.asSequence()
|
||||||
.map {
|
.map {
|
||||||
val date = it.createdAt!!
|
val date = it.createdAt!!
|
||||||
.atZone(ZoneId.of("UTC"))
|
.atZone(ZoneId.of("UTC"))
|
||||||
|
@ -88,32 +75,22 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||||
"$cloudFrontHost/profile/default-profile.png"
|
"$cloudFrontHost/profile/default-profile.png"
|
||||||
},
|
},
|
||||||
comment = it.comment,
|
comment = it.comment,
|
||||||
isSecret = it.isSecret,
|
|
||||||
donationCan = it.donationCan ?: 0,
|
donationCan = it.donationCan ?: 0,
|
||||||
date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")),
|
date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")),
|
||||||
replyCount = commentReplyCountByAudioContentCommentId(it.id!!)
|
replyCount = commentReplyCountByAudioContentCommentId(it.id!!)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun totalCountCommentByContentId(contentId: Long, memberId: Long, isContentCreator: Boolean): Int {
|
override fun totalCountCommentByContentId(contentId: Long): Int {
|
||||||
var where = audioContentComment.audioContent.id.eq(contentId)
|
return queryFactory.select(audioContentComment.id)
|
||||||
.and(audioContentComment.isActive.isTrue)
|
|
||||||
.and(audioContentComment.parent.isNull)
|
|
||||||
|
|
||||||
if (!isContentCreator) {
|
|
||||||
where = where.and(
|
|
||||||
audioContentComment.isSecret.isFalse
|
|
||||||
.or(audioContentComment.member.id.eq(memberId))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return queryFactory
|
|
||||||
.select(audioContentComment.id)
|
|
||||||
.from(audioContentComment)
|
.from(audioContentComment)
|
||||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
.where(
|
||||||
.innerJoin(audioContentComment.member, member)
|
audioContentComment.audioContent.id.eq(contentId)
|
||||||
.where(where)
|
.and(audioContentComment.parent.isNull)
|
||||||
|
.and(audioContentComment.isActive.isTrue)
|
||||||
|
)
|
||||||
.fetch()
|
.fetch()
|
||||||
.size
|
.size
|
||||||
}
|
}
|
||||||
|
@ -163,7 +140,6 @@ class AudioContentCommentQueryRepositoryImpl(
|
||||||
"$cloudFrontHost/profile/default-profile.png"
|
"$cloudFrontHost/profile/default-profile.png"
|
||||||
},
|
},
|
||||||
comment = it.comment,
|
comment = it.comment,
|
||||||
isSecret = it.isSecret,
|
|
||||||
donationCan = it.donationCan ?: 0,
|
donationCan = it.donationCan ?: 0,
|
||||||
date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")),
|
date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")),
|
||||||
replyCount = 0
|
replyCount = 0
|
||||||
|
|
|
@ -2,7 +2,6 @@ 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
|
||||||
|
@ -21,19 +20,12 @@ 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(
|
fun registerComment(member: Member, comment: String, audioContentId: Long, parentId: Long? = null) {
|
||||||
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다시 시도해 주세요.")
|
||||||
|
|
||||||
|
@ -41,16 +33,7 @@ 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 (isExistsAudioContent, _) = orderRepository.isExistOrderedAndOrderType(
|
val audioContentComment = AudioContentComment(comment = comment)
|
||||||
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
|
||||||
|
|
||||||
|
@ -107,27 +90,16 @@ class AudioContentCommentService(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCommentList(
|
fun getCommentList(audioContentId: Long, timezone: String, pageable: Pageable): GetAudioContentCommentListResponse {
|
||||||
audioContentId: Long,
|
val commentList =
|
||||||
memberId: Long,
|
repository.findByContentId(
|
||||||
timezone: String,
|
|
||||||
pageable: Pageable
|
|
||||||
): GetAudioContentCommentListResponse {
|
|
||||||
val isContentCreator = audioContentRepository.isContentCreator(audioContentId, memberId)
|
|
||||||
val commentList = repository.findByContentId(
|
|
||||||
cloudFrontHost = cloudFrontHost,
|
cloudFrontHost = cloudFrontHost,
|
||||||
contentId = audioContentId,
|
contentId = audioContentId,
|
||||||
memberId = memberId,
|
|
||||||
isContentCreator = isContentCreator,
|
|
||||||
timezone = timezone,
|
timezone = timezone,
|
||||||
offset = pageable.offset,
|
offset = pageable.offset,
|
||||||
limit = pageable.pageSize
|
limit = pageable.pageSize
|
||||||
)
|
)
|
||||||
val totalCount = repository.totalCountCommentByContentId(
|
val totalCount = repository.totalCountCommentByContentId(audioContentId)
|
||||||
contentId = audioContentId,
|
|
||||||
memberId = memberId,
|
|
||||||
isContentCreator = isContentCreator
|
|
||||||
)
|
|
||||||
|
|
||||||
return GetAudioContentCommentListResponse(totalCount, commentList)
|
return GetAudioContentCommentListResponse(totalCount, commentList)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
package kr.co.vividnext.sodalive.content.comment
|
package kr.co.vividnext.sodalive.content.comment
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
|
|
||||||
data class GetAudioContentCommentListResponse(
|
data class GetAudioContentCommentListResponse(
|
||||||
val totalCount: Int,
|
val totalCount: Int,
|
||||||
val items: List<GetAudioContentCommentListItem>
|
val items: List<GetAudioContentCommentListItem>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class GetAudioContentCommentListItem @QueryProjection constructor(
|
data class GetAudioContentCommentListItem(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val writerId: Long,
|
val writerId: Long,
|
||||||
val nickname: String,
|
val nickname: String,
|
||||||
val profileUrl: String,
|
val profileUrl: String,
|
||||||
val comment: String,
|
val comment: String,
|
||||||
val isSecret: Boolean,
|
|
||||||
val donationCan: Int,
|
val donationCan: Int,
|
||||||
val date: String,
|
val date: String,
|
||||||
val replyCount: Int
|
val replyCount: Int
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
package kr.co.vividnext.sodalive.content.comment
|
package kr.co.vividnext.sodalive.content.comment
|
||||||
|
|
||||||
data class RegisterCommentRequest(
|
data class RegisterCommentRequest(val comment: String, val contentId: Long, val parentId: Long?)
|
||||||
val comment: String,
|
|
||||||
val contentId: Long,
|
|
||||||
val parentId: Long?,
|
|
||||||
val isSecret: Boolean = false
|
|
||||||
)
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ data class GetAudioContentOrderListResponse(
|
||||||
data class GetAudioContentOrderListItem @QueryProjection constructor(
|
data class GetAudioContentOrderListItem @QueryProjection constructor(
|
||||||
val contentId: Long,
|
val contentId: Long,
|
||||||
val coverImageUrl: String,
|
val coverImageUrl: String,
|
||||||
val creatorId: Long,
|
|
||||||
val creatorNickname: String,
|
val creatorNickname: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val themeStr: String,
|
val themeStr: String,
|
||||||
|
|
|
@ -126,7 +126,6 @@ class OrderQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Orde
|
||||||
QGetAudioContentOrderListItem(
|
QGetAudioContentOrderListItem(
|
||||||
audioContent.id,
|
audioContent.id,
|
||||||
audioContent.coverImage.prepend("/").prepend(coverImageHost),
|
audioContent.coverImage.prepend("/").prepend(coverImageHost),
|
||||||
audioContent.member.id,
|
|
||||||
audioContent.member.nickname,
|
audioContent.member.nickname,
|
||||||
audioContent.title,
|
audioContent.title,
|
||||||
audioContent.theme.theme,
|
audioContent.theme.theme,
|
||||||
|
|
|
@ -98,13 +98,10 @@ class OrderService(
|
||||||
offset = offset,
|
offset = offset,
|
||||||
limit = limit
|
limit = limit
|
||||||
)
|
)
|
||||||
|
.asSequence()
|
||||||
.map {
|
.map {
|
||||||
val commentCount = audioContentCommentQueryRepository
|
val commentCount = audioContentCommentQueryRepository
|
||||||
.totalCountCommentByContentId(
|
.totalCountCommentByContentId(it.contentId)
|
||||||
it.contentId,
|
|
||||||
memberId = member.id!!,
|
|
||||||
isContentCreator = it.creatorId == member.id!!
|
|
||||||
)
|
|
||||||
|
|
||||||
val likeCount = audioContentLikeQueryRepository
|
val likeCount = audioContentLikeQueryRepository
|
||||||
.totalCountAudioContentLike(it.contentId)
|
.totalCountAudioContentLike(it.contentId)
|
||||||
|
@ -113,6 +110,7 @@ class OrderService(
|
||||||
it.likeCount = likeCount
|
it.likeCount = likeCount
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
.toList()
|
||||||
|
|
||||||
return GetAudioContentOrderListResponse(
|
return GetAudioContentOrderListResponse(
|
||||||
totalCount = totalCount,
|
totalCount = totalCount,
|
||||||
|
|
Loading…
Reference in New Issue