| @@ -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 | ||||||
|             ) |             ) | ||||||
|         ) |         ) | ||||||
| @@ -158,6 +159,7 @@ class CreatorCommunityController(private val service: CreatorCommunityService) { | |||||||
|         ApiResponse.ok( |         ApiResponse.ok( | ||||||
|             service.getCommunityPostCommentList( |             service.getCommunityPostCommentList( | ||||||
|                 postId = postId, |                 postId = postId, | ||||||
|  |                 memberId = member.id!!, | ||||||
|                 timezone = timezone, |                 timezone = timezone, | ||||||
|                 offset = pageable.offset, |                 offset = pageable.offset, | ||||||
|                 limit = pageable.pageSize.toLong() |                 limit = pageable.pageSize.toLong() | ||||||
|   | |||||||
| @@ -28,6 +28,8 @@ interface CreatorCommunityQueryRepository { | |||||||
|     fun getLatestPostListFromCreatorsYouFollow(memberId: Long, isAdult: Boolean): List<SelectCommunityPostResponse> |     fun getLatestPostListFromCreatorsYouFollow(memberId: Long, isAdult: Boolean): List<SelectCommunityPostResponse> | ||||||
|  |  | ||||||
|     fun getCommunityPost(postId: Long, isAdult: Boolean): SelectCommunityPostResponse? |     fun getCommunityPost(postId: Long, isAdult: Boolean): SelectCommunityPostResponse? | ||||||
|  |  | ||||||
|  |     fun isCommunityCreator(postId: Long, memberId: Long): Boolean | ||||||
| } | } | ||||||
|  |  | ||||||
| class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CreatorCommunityQueryRepository { | class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CreatorCommunityQueryRepository { | ||||||
| @@ -195,4 +197,17 @@ class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFact | |||||||
|             .where(where) |             .where(where) | ||||||
|             .fetchFirst() |             .fetchFirst() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     override fun isCommunityCreator(postId: Long, memberId: Long): Boolean { | ||||||
|  |         return queryFactory | ||||||
|  |             .select(member.id) | ||||||
|  |             .from(creatorCommunity) | ||||||
|  |             .innerJoin(creatorCommunity.member, member) | ||||||
|  |             .where( | ||||||
|  |                 creatorCommunity.id.eq(postId) | ||||||
|  |                     .and(creatorCommunity.isActive.isTrue) | ||||||
|  |                     .and(member.id.eq(memberId)) | ||||||
|  |             ) | ||||||
|  |             .fetchFirst() != null | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -190,15 +190,20 @@ class CreatorCommunityService( | |||||||
|                     ?: false |                     ?: false | ||||||
|                 val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(it.id) |                 val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(it.id) | ||||||
|                 val commentCount = if (it.isCommentAvailable) { |                 val commentCount = if (it.isCommentAvailable) { | ||||||
|                     commentRepository.totalCountCommentByPostId(postId = it.id) |                     commentRepository.totalCountCommentByPostId( | ||||||
|  |                         postId = it.id, | ||||||
|  |                         memberId = memberId, | ||||||
|  |                         isContentCreator = it.creatorId == memberId | ||||||
|  |                     ) | ||||||
|                 } else { |                 } else { | ||||||
|                     0 |                     0 | ||||||
|                 } |                 } | ||||||
|                 val commentList = if (it.isCommentAvailable) { |                 val commentList = if (it.isCommentAvailable) { | ||||||
|                     commentRepository.findByPostId( |                     commentRepository.findByPostId( | ||||||
|                         cloudFrontHost = imageHost, |  | ||||||
|                         timezone = timezone, |  | ||||||
|                         id = it.id, |                         id = it.id, | ||||||
|  |                         memberId = memberId, | ||||||
|  |                         isContentCreator = it.creatorId == memberId, | ||||||
|  |                         timezone = timezone, | ||||||
|                         offset = 0, |                         offset = 0, | ||||||
|                         limit = 1 |                         limit = 1 | ||||||
|                     ) |                     ) | ||||||
| @@ -212,7 +217,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 ( | ||||||
|                     ( |                     ( | ||||||
| @@ -263,15 +268,20 @@ class CreatorCommunityService( | |||||||
|         val isLike = likeRepository.findByPostIdAndMemberId(postId = post.id, memberId = memberId)?.isActive ?: false |         val isLike = likeRepository.findByPostIdAndMemberId(postId = post.id, memberId = memberId)?.isActive ?: false | ||||||
|         val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(post.id) |         val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(post.id) | ||||||
|         val commentCount = if (post.isCommentAvailable) { |         val commentCount = if (post.isCommentAvailable) { | ||||||
|             commentRepository.totalCountCommentByPostId(postId = post.id) |             commentRepository.totalCountCommentByPostId( | ||||||
|  |                 postId = post.id, | ||||||
|  |                 memberId = memberId, | ||||||
|  |                 isContentCreator = post.creatorId == memberId | ||||||
|  |             ) | ||||||
|         } else { |         } else { | ||||||
|             0 |             0 | ||||||
|         } |         } | ||||||
|         val commentList = if (post.isCommentAvailable) { |         val commentList = if (post.isCommentAvailable) { | ||||||
|             commentRepository.findByPostId( |             commentRepository.findByPostId( | ||||||
|                 cloudFrontHost = imageHost, |  | ||||||
|                 timezone = timezone, |  | ||||||
|                 id = post.id, |                 id = post.id, | ||||||
|  |                 memberId = memberId, | ||||||
|  |                 isContentCreator = post.creatorId == memberId, | ||||||
|  |                 timezone = timezone, | ||||||
|                 offset = 0, |                 offset = 0, | ||||||
|                 limit = 1 |                 limit = 1 | ||||||
|             ) |             ) | ||||||
| @@ -285,7 +295,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 +357,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 | ||||||
|  |  | ||||||
| @@ -390,19 +411,25 @@ class CreatorCommunityService( | |||||||
|  |  | ||||||
|     fun getCommunityPostCommentList( |     fun getCommunityPostCommentList( | ||||||
|         postId: Long, |         postId: Long, | ||||||
|  |         memberId: Long, | ||||||
|         timezone: String, |         timezone: String, | ||||||
|         offset: Long, |         offset: Long, | ||||||
|         limit: Long |         limit: Long | ||||||
|     ): GetCommunityPostCommentListResponse { |     ): GetCommunityPostCommentListResponse { | ||||||
|         val commentList = commentRepository.findByPostId( |         val commentList = commentRepository.findByPostId( | ||||||
|             cloudFrontHost = imageHost, |  | ||||||
|             timezone = timezone, |  | ||||||
|             id = postId, |             id = postId, | ||||||
|  |             memberId = memberId, | ||||||
|  |             isContentCreator = repository.isCommunityCreator(postId, memberId), | ||||||
|  |             timezone = timezone, | ||||||
|             offset = offset, |             offset = offset, | ||||||
|             limit = limit |             limit = limit | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         val totalCount = commentRepository.totalCountCommentByPostId(postId = postId) |         val totalCount = commentRepository.totalCountCommentByPostId( | ||||||
|  |             postId = postId, | ||||||
|  |             memberId = memberId, | ||||||
|  |             isContentCreator = repository.isCommunityCreator(postId, memberId) | ||||||
|  |         ) | ||||||
|         return GetCommunityPostCommentListResponse(totalCount = totalCount, items = commentList) |         return GetCommunityPostCommentListResponse(totalCount = totalCount, items = commentList) | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -413,7 +440,6 @@ class CreatorCommunityService( | |||||||
|         limit: Long |         limit: Long | ||||||
|     ): GetCommunityPostCommentListResponse { |     ): GetCommunityPostCommentListResponse { | ||||||
|         val commentList = commentRepository.getCommunityCommentReplyList( |         val commentList = commentRepository.getCommunityCommentReplyList( | ||||||
|             cloudFrontHost = imageHost, |  | ||||||
|             commentId = commentId, |             commentId = commentId, | ||||||
|             timezone = timezone, |             timezone = timezone, | ||||||
|             offset = offset, |             offset = offset, | ||||||
| @@ -443,15 +469,20 @@ class CreatorCommunityService( | |||||||
|                     likeRepository.findByPostIdAndMemberId(postId = it.id, memberId = memberId)?.isActive ?: false |                     likeRepository.findByPostIdAndMemberId(postId = it.id, memberId = memberId)?.isActive ?: false | ||||||
|                 val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(it.id) |                 val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(it.id) | ||||||
|                 val commentCount = if (it.isCommentAvailable) { |                 val commentCount = if (it.isCommentAvailable) { | ||||||
|                     commentRepository.totalCountCommentByPostId(postId = it.id) |                     commentRepository.totalCountCommentByPostId( | ||||||
|  |                         postId = it.id, | ||||||
|  |                         memberId = memberId, | ||||||
|  |                         isContentCreator = it.creatorId == memberId | ||||||
|  |                     ) | ||||||
|                 } else { |                 } else { | ||||||
|                     0 |                     0 | ||||||
|                 } |                 } | ||||||
|                 val commentList = if (it.isCommentAvailable) { |                 val commentList = if (it.isCommentAvailable) { | ||||||
|                     commentRepository.findByPostId( |                     commentRepository.findByPostId( | ||||||
|                         cloudFrontHost = imageHost, |  | ||||||
|                         timezone = timezone, |  | ||||||
|                         id = it.id, |                         id = it.id, | ||||||
|  |                         memberId = memberId, | ||||||
|  |                         isContentCreator = it.creatorId == memberId, | ||||||
|  |                         timezone = timezone, | ||||||
|                         offset = 0, |                         offset = 0, | ||||||
|                         limit = 1 |                         limit = 1 | ||||||
|                     ) |                     ) | ||||||
| @@ -465,7 +496,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 +530,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( | ||||||
| @@ -514,15 +545,20 @@ class CreatorCommunityService( | |||||||
|         val isLike = likeRepository.findByPostIdAndMemberId(postId = post.id!!, memberId = memberId)?.isActive ?: false |         val isLike = likeRepository.findByPostIdAndMemberId(postId = post.id!!, memberId = memberId)?.isActive ?: false | ||||||
|         val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(post.id!!) |         val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(post.id!!) | ||||||
|         val commentCount = if (post.isCommentAvailable) { |         val commentCount = if (post.isCommentAvailable) { | ||||||
|             commentRepository.totalCountCommentByPostId(postId = post.id!!) |             commentRepository.totalCountCommentByPostId( | ||||||
|  |                 postId = post.id!!, | ||||||
|  |                 memberId = memberId, | ||||||
|  |                 isContentCreator = false | ||||||
|  |             ) | ||||||
|         } else { |         } else { | ||||||
|             0 |             0 | ||||||
|         } |         } | ||||||
|         val commentList = if (post.isCommentAvailable) { |         val commentList = if (post.isCommentAvailable) { | ||||||
|             commentRepository.findByPostId( |             commentRepository.findByPostId( | ||||||
|                 cloudFrontHost = imageHost, |  | ||||||
|                 timezone = timezone, |  | ||||||
|                 id = post.id!!, |                 id = post.id!!, | ||||||
|  |                 memberId = memberId, | ||||||
|  |                 isContentCreator = false, | ||||||
|  |                 timezone = timezone, | ||||||
|                 offset = 0, |                 offset = 0, | ||||||
|                 limit = 1 |                 limit = 1 | ||||||
|             ) |             ) | ||||||
|   | |||||||
| @@ -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) | ||||||
|   | |||||||
| @@ -1,29 +1,34 @@ | |||||||
| package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment | package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment | ||||||
|  |  | ||||||
|  | import com.querydsl.core.types.dsl.Expressions | ||||||
| import com.querydsl.jpa.impl.JPAQueryFactory | import com.querydsl.jpa.impl.JPAQueryFactory | ||||||
| import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment.QCreatorCommunityComment.creatorCommunityComment | import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment.QCreatorCommunityComment.creatorCommunityComment | ||||||
|  | import org.springframework.beans.factory.annotation.Value | ||||||
| import org.springframework.data.jpa.repository.JpaRepository | import org.springframework.data.jpa.repository.JpaRepository | ||||||
| import java.time.ZoneId | import java.time.LocalDateTime | ||||||
| import java.time.format.DateTimeFormatter |  | ||||||
|  |  | ||||||
| interface CreatorCommunityCommentRepository : | interface CreatorCommunityCommentRepository : | ||||||
|     JpaRepository<CreatorCommunityComment, Long>, CreatorCommunityCommentQueryRepository |     JpaRepository<CreatorCommunityComment, Long>, CreatorCommunityCommentQueryRepository | ||||||
|  |  | ||||||
| interface CreatorCommunityCommentQueryRepository { | interface CreatorCommunityCommentQueryRepository { | ||||||
|     fun findByPostId( |     fun findByPostId( | ||||||
|         cloudFrontHost: String, |  | ||||||
|         timezone: String, |  | ||||||
|         id: Long, |         id: Long, | ||||||
|  |         memberId: Long, | ||||||
|  |         isContentCreator: Boolean, | ||||||
|  |         timezone: String, | ||||||
|         offset: Long, |         offset: Long, | ||||||
|         limit: Long |         limit: Long | ||||||
|     ): List<GetCommunityPostCommentListItem> |     ): List<GetCommunityPostCommentListItem> | ||||||
|  |  | ||||||
|     fun commentReplyCountByCommentId(commentId: Long): Int |     fun commentReplyCountByCommentId(commentId: Long): Int | ||||||
|  |  | ||||||
|     fun totalCountCommentByPostId(postId: Long): Int |     fun totalCountCommentByPostId( | ||||||
|  |         postId: Long, | ||||||
|  |         memberId: Long, | ||||||
|  |         isContentCreator: Boolean | ||||||
|  |     ): Int | ||||||
|  |  | ||||||
|     fun getCommunityCommentReplyList( |     fun getCommunityCommentReplyList( | ||||||
|         cloudFrontHost: String, |  | ||||||
|         commentId: Long, |         commentId: Long, | ||||||
|         timezone: String, |         timezone: String, | ||||||
|         offset: Long, |         offset: Long, | ||||||
| @@ -32,47 +37,65 @@ interface CreatorCommunityCommentQueryRepository { | |||||||
| } | } | ||||||
|  |  | ||||||
| class CreatorCommunityCommentQueryRepositoryImpl( | class CreatorCommunityCommentQueryRepositoryImpl( | ||||||
|     private val queryFactory: JPAQueryFactory |     private val queryFactory: JPAQueryFactory, | ||||||
|  |  | ||||||
|  |     @Value("\${cloud.aws.cloud-front.host}") | ||||||
|  |     private val imageHost: String | ||||||
| ) : CreatorCommunityCommentQueryRepository { | ) : CreatorCommunityCommentQueryRepository { | ||||||
|     override fun findByPostId( |     override fun findByPostId( | ||||||
|         cloudFrontHost: String, |  | ||||||
|         timezone: String, |  | ||||||
|         id: Long, |         id: Long, | ||||||
|  |         memberId: Long, | ||||||
|  |         isContentCreator: Boolean, | ||||||
|  |         timezone: String, | ||||||
|         offset: Long, |         offset: Long, | ||||||
|         limit: Long |         limit: Long | ||||||
|     ): List<GetCommunityPostCommentListItem> { |     ): List<GetCommunityPostCommentListItem> { | ||||||
|         return queryFactory |         val formattedDate = Expressions.stringTemplate( | ||||||
|             .selectFrom(creatorCommunityComment) |             "DATE_FORMAT({0}, {1})", | ||||||
|             .where( |             Expressions.dateTimeTemplate( | ||||||
|                 creatorCommunityComment.isActive.isTrue |                 LocalDateTime::class.java, | ||||||
|                     .and(creatorCommunityComment.creatorCommunity.id.eq(id)) |                 "CONVERT_TZ({0},{1},{2})", | ||||||
|                     .and(creatorCommunityComment.parent.isNull) |                 creatorCommunityComment.createdAt, | ||||||
|  |                 "UTC", | ||||||
|  |                 timezone | ||||||
|  |             ), | ||||||
|  |             "%Y.%m.%d %W %h:%i %p" | ||||||
|  |         ) | ||||||
|  |  | ||||||
|  |         var where = creatorCommunityComment.isActive.isTrue | ||||||
|  |             .and(creatorCommunityComment.creatorCommunity.id.eq(id)) | ||||||
|  |             .and(creatorCommunityComment.parent.isNull) | ||||||
|  |  | ||||||
|  |         if (!isContentCreator) { | ||||||
|  |             where = where.and( | ||||||
|  |                 creatorCommunityComment.isSecret.isFalse | ||||||
|  |                     .or(creatorCommunityComment.member.id.eq(memberId)) | ||||||
|             ) |             ) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return queryFactory | ||||||
|  |             .select( | ||||||
|  |                 QGetCommunityPostCommentListItem( | ||||||
|  |                     creatorCommunityComment.id, | ||||||
|  |                     creatorCommunityComment.member.id, | ||||||
|  |                     creatorCommunityComment.member.nickname, | ||||||
|  |                     creatorCommunityComment.member.profileImage.prepend("/").prepend(imageHost), | ||||||
|  |                     creatorCommunityComment.comment, | ||||||
|  |                     creatorCommunityComment.isSecret, | ||||||
|  |                     formattedDate, | ||||||
|  |                     Expressions.constant(0) | ||||||
|  |                 ) | ||||||
|  |             ) | ||||||
|  |             .from(creatorCommunityComment) | ||||||
|  |             .where(where) | ||||||
|             .offset(offset) |             .offset(offset) | ||||||
|             .limit(limit) |             .limit(limit) | ||||||
|             .orderBy(creatorCommunityComment.createdAt.desc()) |             .orderBy(creatorCommunityComment.createdAt.desc()) | ||||||
|             .fetch() |             .fetch() | ||||||
|             .asSequence() |  | ||||||
|             .map { |             .map { | ||||||
|                 val date = it.createdAt!! |                 it.replyCount = commentReplyCountByCommentId(it.id) | ||||||
|                     .atZone(ZoneId.of("UTC")) |                 it | ||||||
|                     .withZoneSameInstant(ZoneId.of(timezone)) |  | ||||||
|  |  | ||||||
|                 GetCommunityPostCommentListItem( |  | ||||||
|                     id = it.id!!, |  | ||||||
|                     writerId = it.member!!.id!!, |  | ||||||
|                     nickname = it.member!!.nickname, |  | ||||||
|                     profileUrl = if (it.member!!.profileImage != null) { |  | ||||||
|                         "$cloudFrontHost/${it.member!!.profileImage}" |  | ||||||
|                     } else { |  | ||||||
|                         "$cloudFrontHost/profile/default-profile.png" |  | ||||||
|                     }, |  | ||||||
|                     comment = it.comment, |  | ||||||
|                     date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")), |  | ||||||
|                     replyCount = commentReplyCountByCommentId(it.id!!) |  | ||||||
|                 ) |  | ||||||
|             } |             } | ||||||
|             .toList() |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun commentReplyCountByCommentId(commentId: Long): Int { |     override fun commentReplyCountByCommentId(commentId: Long): Int { | ||||||
| @@ -87,27 +110,61 @@ class CreatorCommunityCommentQueryRepositoryImpl( | |||||||
|             .size |             .size | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun totalCountCommentByPostId(postId: Long): Int { |     override fun totalCountCommentByPostId( | ||||||
|  |         postId: Long, | ||||||
|  |         memberId: Long, | ||||||
|  |         isContentCreator: Boolean | ||||||
|  |     ): Int { | ||||||
|  |         var where = creatorCommunityComment.creatorCommunity.id.eq(postId) | ||||||
|  |             .and(creatorCommunityComment.isActive.isTrue) | ||||||
|  |             .and(creatorCommunityComment.parent.isNull) | ||||||
|  |  | ||||||
|  |         if (!isContentCreator) { | ||||||
|  |             where = where.and( | ||||||
|  |                 creatorCommunityComment.isSecret.isFalse | ||||||
|  |                     .or(creatorCommunityComment.member.id.eq(memberId)) | ||||||
|  |             ) | ||||||
|  |         } | ||||||
|  |  | ||||||
|         return queryFactory.select(creatorCommunityComment.id) |         return queryFactory.select(creatorCommunityComment.id) | ||||||
|             .from(creatorCommunityComment) |             .from(creatorCommunityComment) | ||||||
|             .where( |             .where(where) | ||||||
|                 creatorCommunityComment.creatorCommunity.id.eq(postId) |  | ||||||
|                     .and(creatorCommunityComment.isActive.isTrue) |  | ||||||
|                     .and(creatorCommunityComment.parent.isNull) |  | ||||||
|             ) |  | ||||||
|             .fetch() |             .fetch() | ||||||
|             .size |             .size | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun getCommunityCommentReplyList( |     override fun getCommunityCommentReplyList( | ||||||
|         cloudFrontHost: String, |  | ||||||
|         commentId: Long, |         commentId: Long, | ||||||
|         timezone: String, |         timezone: String, | ||||||
|         offset: Long, |         offset: Long, | ||||||
|         limit: Long |         limit: Long | ||||||
|     ): List<GetCommunityPostCommentListItem> { |     ): List<GetCommunityPostCommentListItem> { | ||||||
|  |         val formattedDate = Expressions.stringTemplate( | ||||||
|  |             "DATE_FORMAT({0}, {1})", | ||||||
|  |             Expressions.dateTimeTemplate( | ||||||
|  |                 LocalDateTime::class.java, | ||||||
|  |                 "CONVERT_TZ({0},{1},{2})", | ||||||
|  |                 creatorCommunityComment.createdAt, | ||||||
|  |                 "UTC", | ||||||
|  |                 timezone | ||||||
|  |             ), | ||||||
|  |             "%Y.%m.%d %W %h:%i %p" | ||||||
|  |         ) | ||||||
|  |  | ||||||
|         return queryFactory |         return queryFactory | ||||||
|             .selectFrom(creatorCommunityComment) |             .select( | ||||||
|  |                 QGetCommunityPostCommentListItem( | ||||||
|  |                     creatorCommunityComment.id, | ||||||
|  |                     creatorCommunityComment.member.id, | ||||||
|  |                     creatorCommunityComment.member.nickname, | ||||||
|  |                     creatorCommunityComment.member.profileImage.prepend("/").prepend(imageHost), | ||||||
|  |                     creatorCommunityComment.comment, | ||||||
|  |                     creatorCommunityComment.isSecret, | ||||||
|  |                     formattedDate, | ||||||
|  |                     Expressions.constant(0) | ||||||
|  |                 ) | ||||||
|  |             ) | ||||||
|  |             .from(creatorCommunityComment) | ||||||
|             .where( |             .where( | ||||||
|                 creatorCommunityComment.isActive.isTrue |                 creatorCommunityComment.isActive.isTrue | ||||||
|                     .and(creatorCommunityComment.parent.isNotNull) |                     .and(creatorCommunityComment.parent.isNotNull) | ||||||
| @@ -117,26 +174,5 @@ class CreatorCommunityCommentQueryRepositoryImpl( | |||||||
|             .limit(limit) |             .limit(limit) | ||||||
|             .orderBy(creatorCommunityComment.createdAt.desc()) |             .orderBy(creatorCommunityComment.createdAt.desc()) | ||||||
|             .fetch() |             .fetch() | ||||||
|             .asSequence() |  | ||||||
|             .map { |  | ||||||
|                 val date = it.createdAt!! |  | ||||||
|                     .atZone(ZoneId.of("UTC")) |  | ||||||
|                     .withZoneSameInstant(ZoneId.of(timezone)) |  | ||||||
|  |  | ||||||
|                 GetCommunityPostCommentListItem( |  | ||||||
|                     id = it.id!!, |  | ||||||
|                     writerId = it.member!!.id!!, |  | ||||||
|                     nickname = it.member!!.nickname, |  | ||||||
|                     profileUrl = if (it.member!!.profileImage != null) { |  | ||||||
|                         "$cloudFrontHost/${it.member!!.profileImage}" |  | ||||||
|                     } else { |  | ||||||
|                         "$cloudFrontHost/profile/default-profile.png" |  | ||||||
|                     }, |  | ||||||
|                     comment = it.comment, |  | ||||||
|                     date = date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd E hh:mm a")), |  | ||||||
|                     replyCount = commentReplyCountByCommentId(it.id!!) |  | ||||||
|                 ) |  | ||||||
|             } |  | ||||||
|             .toList() |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,16 +1,19 @@ | |||||||
| package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment | package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment | ||||||
|  |  | ||||||
|  | import com.querydsl.core.annotations.QueryProjection | ||||||
|  |  | ||||||
| data class GetCommunityPostCommentListResponse( | data class GetCommunityPostCommentListResponse( | ||||||
|     val totalCount: Int, |     val totalCount: Int, | ||||||
|     val items: List<GetCommunityPostCommentListItem> |     val items: List<GetCommunityPostCommentListItem> | ||||||
| ) | ) | ||||||
|  |  | ||||||
| data class GetCommunityPostCommentListItem( | data class GetCommunityPostCommentListItem @QueryProjection constructor( | ||||||
|     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 date: String, |     val date: String, | ||||||
|     val replyCount: Int |     var replyCount: Int | ||||||
| ) | ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user