| @@ -185,6 +185,7 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) { | ||||
|                     member.nickname, | ||||
|                     Expressions.stringTemplate("substring({0}, 1, 10)", creatorCommunity.content), | ||||
|                     formattedDate, | ||||
|                     creatorCommunity.price, | ||||
|                     useCan.id.count(), | ||||
|                     useCan.can.add(useCan.rewardCan).sum() | ||||
|                 ) | ||||
|   | ||||
| @@ -7,6 +7,7 @@ data class GetCalculateCommunityPostQueryData @QueryProjection constructor( | ||||
|     val nickname: String, | ||||
|     val title: String, | ||||
|     val date: String, | ||||
|     val can: Int, | ||||
|     val numberOfPurchase: Long, | ||||
|     val totalCan: Int | ||||
| ) { | ||||
| @@ -21,6 +22,7 @@ data class GetCalculateCommunityPostQueryData @QueryProjection constructor( | ||||
|             nickname = nickname, | ||||
|             title = title, | ||||
|             date = date, | ||||
|             can = can, | ||||
|             numberOfPurchase = numberOfPurchase.toInt(), | ||||
|             totalCan = totalCan, | ||||
|             totalKrw = totalKrw, | ||||
|   | ||||
| @@ -6,6 +6,7 @@ data class GetCalculateCommunityPostResponse( | ||||
|     @JsonProperty("nickname") val nickname: String, | ||||
|     @JsonProperty("title") val title: String, | ||||
|     @JsonProperty("date") val date: String, | ||||
|     @JsonProperty("can") val can: Int, | ||||
|     @JsonProperty("numberOfPurchase") val numberOfPurchase: Int, | ||||
|     @JsonProperty("totalCan") val totalCan: Int, | ||||
|     @JsonProperty("totalKrw") val totalKrw: Int, | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.admin.live.signature | ||||
|  | ||||
| import kr.co.vividnext.sodalive.common.ApiResponse | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCanSortType | ||||
| import org.springframework.data.domain.Pageable | ||||
| import org.springframework.security.access.prepost.PreAuthorize | ||||
| import org.springframework.web.bind.annotation.GetMapping | ||||
| @@ -17,7 +18,10 @@ import org.springframework.web.multipart.MultipartFile | ||||
| @RequestMapping("/admin/live/signature-can") | ||||
| class AdminSignatureCanController(private val service: AdminSignatureCanService) { | ||||
|     @GetMapping | ||||
|     fun getSignatureCanList(pageable: Pageable) = ApiResponse.ok(data = service.getSignatureCanList(pageable)) | ||||
|     fun getSignatureCanList( | ||||
|         pageable: Pageable, | ||||
|         @RequestParam("sort-type", required = false) sortType: SignatureCanSortType? | ||||
|     ) = ApiResponse.ok(data = service.getSignatureCanList(pageable, sortType ?: SignatureCanSortType.NEWEST)) | ||||
|  | ||||
|     @PostMapping | ||||
|     fun createSignatureCan( | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.admin.live.signature | ||||
| import com.querydsl.jpa.impl.JPAQueryFactory | ||||
| import kr.co.vividnext.sodalive.live.signature.QSignatureCan.signatureCan | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCan | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCanSortType | ||||
| import kr.co.vividnext.sodalive.member.QMember.member | ||||
| import org.springframework.data.jpa.repository.JpaRepository | ||||
|  | ||||
| @@ -11,7 +12,12 @@ interface AdminSignatureCanRepository : JpaRepository<SignatureCan, Long>, Admin | ||||
| interface AdminSignatureCanQueryRepository { | ||||
|     fun getSignatureCanListTotalCount(): Int | ||||
|  | ||||
|     fun getSignatureCanList(imageHost: String, offset: Long, limit: Long): List<GetSignatureCanListItem> | ||||
|     fun getSignatureCanList( | ||||
|         sortType: SignatureCanSortType, | ||||
|         imageHost: String, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetSignatureCanListItem> | ||||
| } | ||||
|  | ||||
| class AdminSignatureCanQueryRepositoryImpl( | ||||
| @@ -25,7 +31,26 @@ class AdminSignatureCanQueryRepositoryImpl( | ||||
|             .size | ||||
|     } | ||||
|  | ||||
|     override fun getSignatureCanList(imageHost: String, offset: Long, limit: Long): List<GetSignatureCanListItem> { | ||||
|     override fun getSignatureCanList( | ||||
|         sortType: SignatureCanSortType, | ||||
|         imageHost: String, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetSignatureCanListItem> { | ||||
|         val orderBy = when (sortType) { | ||||
|             SignatureCanSortType.CAN_HIGH -> { | ||||
|                 signatureCan.can.desc() | ||||
|             } | ||||
|  | ||||
|             SignatureCanSortType.CAN_LOW -> { | ||||
|                 signatureCan.can.asc() | ||||
|             } | ||||
|  | ||||
|             else -> { | ||||
|                 signatureCan.id.desc() | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return queryFactory.select( | ||||
|             QGetSignatureCanListItem( | ||||
|                 signatureCan.id, | ||||
| @@ -41,7 +66,7 @@ class AdminSignatureCanQueryRepositoryImpl( | ||||
|             .where(signatureCan.isActive.isTrue) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|             .orderBy(signatureCan.id.desc()) | ||||
|             .orderBy(member.id.desc(), orderBy) | ||||
|             .fetch() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import com.amazonaws.services.s3.model.ObjectMetadata | ||||
| import kr.co.vividnext.sodalive.aws.s3.S3Uploader | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCan | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCanSortType | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| @@ -25,9 +26,13 @@ class AdminSignatureCanService( | ||||
|     @Value("\${cloud.aws.cloud-front.host}") | ||||
|     private val imageHost: String | ||||
| ) { | ||||
|     fun getSignatureCanList(pageable: Pageable): GetSignatureCanListResponse { | ||||
|     fun getSignatureCanList( | ||||
|         pageable: Pageable, | ||||
|         sortType: SignatureCanSortType | ||||
|     ): GetSignatureCanListResponse { | ||||
|         val totalCount = repository.getSignatureCanListTotalCount() | ||||
|         val items = repository.getSignatureCanList( | ||||
|             sortType = sortType, | ||||
|             imageHost = imageHost, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong() | ||||
|   | ||||
| @@ -187,7 +187,10 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|                     Expressions.constant(0), | ||||
|                     pinContent.id.isNotNull, | ||||
|                     audioContent.isAdult, | ||||
|                     audioContent.releaseDate.gt(LocalDateTime.now()) | ||||
|                     audioContent.releaseDate.gt(LocalDateTime.now()), | ||||
|                     Expressions.asBoolean(false), | ||||
|                     Expressions.asBoolean(false), | ||||
|                     audioContent.remaining.loe(0) | ||||
|                 ) | ||||
|             ) | ||||
|             .from(audioContent) | ||||
|   | ||||
| @@ -666,12 +666,24 @@ class AudioContentService( | ||||
|             .map { | ||||
|                 val commentCount = commentRepository | ||||
|                     .totalCountCommentByContentId(it.contentId) | ||||
|                 it.commentCount = commentCount | ||||
|  | ||||
|                 val likeCount = audioContentLikeRepository | ||||
|                     .totalCountAudioContentLike(it.contentId) | ||||
|  | ||||
|                 it.likeCount = likeCount | ||||
|                 it.commentCount = commentCount | ||||
|  | ||||
|                 val (isExistsAudioContent, orderType) = orderRepository.isExistOrderedAndOrderType( | ||||
|                     memberId = member.id!!, | ||||
|                     contentId = it.contentId | ||||
|                 ) | ||||
|  | ||||
|                 if (isExistsAudioContent) { | ||||
|                     if (orderType == OrderType.RENTAL) { | ||||
|                         it.isRented = true | ||||
|                     } else { | ||||
|                         it.isOwned = true | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 it | ||||
|             } | ||||
|   | ||||
| @@ -18,5 +18,8 @@ data class GetAudioContentListItem @QueryProjection constructor( | ||||
|     var commentCount: Int = 0, | ||||
|     val isPin: Boolean, | ||||
|     val isAdult: Boolean, | ||||
|     val isScheduledToOpen: Boolean | ||||
|     val isScheduledToOpen: Boolean, | ||||
|     var isRented: Boolean, | ||||
|     var isOwned: Boolean, | ||||
|     var isSoldOut: Boolean | ||||
| ) | ||||
|   | ||||
| @@ -65,8 +65,10 @@ class ContentSeriesQueryRepositoryImpl( | ||||
|  | ||||
|         return queryFactory | ||||
|             .selectFrom(series) | ||||
|             .innerJoin(series.contentList, seriesContent) | ||||
|             .innerJoin(seriesContent.content, audioContent) | ||||
|             .where(where) | ||||
|             .orderBy(series.orders.asc(), series.createdAt.asc()) | ||||
|             .orderBy(audioContent.releaseDate.desc(), series.orders.asc(), series.createdAt.asc()) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|             .fetch() | ||||
|   | ||||
| @@ -273,6 +273,7 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac | ||||
|                     member.nickname, | ||||
|                     Expressions.stringTemplate("substring({0}, 1, 10)", creatorCommunity.content), | ||||
|                     formattedDate, | ||||
|                     creatorCommunity.price, | ||||
|                     useCan.id.count(), | ||||
|                     useCan.can.add(useCan.rewardCan).sum() | ||||
|                 ) | ||||
|   | ||||
| @@ -185,19 +185,8 @@ class CreatorCommunityService( | ||||
|  | ||||
|                 val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId) | ||||
|  | ||||
|                 val content = if (it.price > 0 && memberId != it.creatorId) { | ||||
|                     if (existOrdered) { | ||||
|                         it.content | ||||
|                     } else { | ||||
|                         it.content.substring(0, 5).plus("...") | ||||
|                     } | ||||
|                 } else { | ||||
|                     it.content | ||||
|                 } | ||||
|  | ||||
|                 it.toCommunityPostListResponse( | ||||
|                     imageHost = imageHost, | ||||
|                     content = content, | ||||
|                     date = getTimeAgoString(it.date), | ||||
|                     isLike = isLike, | ||||
|                     existOrdered = if (memberId == it.creatorId) { | ||||
| @@ -251,19 +240,8 @@ class CreatorCommunityService( | ||||
|  | ||||
|         val existOrdered = useCanRepository.isExistOrdered(postId = post.id, memberId = memberId) | ||||
|  | ||||
|         val content = if (post.price > 0 && memberId != post.creatorId) { | ||||
|             if (existOrdered) { | ||||
|                 post.content | ||||
|             } else { | ||||
|                 post.content.substring(0, 5).plus("...") | ||||
|             } | ||||
|         } else { | ||||
|             post.content | ||||
|         } | ||||
|  | ||||
|         return post.toCommunityPostListResponse( | ||||
|             imageHost = imageHost, | ||||
|             content = content, | ||||
|             date = getTimeAgoString(post.date), | ||||
|             isLike = isLike, | ||||
|             existOrdered = if (memberId == post.creatorId) { | ||||
| @@ -404,10 +382,10 @@ class CreatorCommunityService( | ||||
|             } | ||||
|             .map { | ||||
|                 val isLike = | ||||
|                     likeRepository.findByPostIdAndMemberId(postId = it.id!!, memberId = memberId)?.isActive ?: false | ||||
|                 val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(it.id!!) | ||||
|                     likeRepository.findByPostIdAndMemberId(postId = it.id, memberId = memberId)?.isActive ?: false | ||||
|                 val likeCount = likeRepository.totalCountCommunityPostLikeByPostId(it.id) | ||||
|                 val commentCount = if (it.isCommentAvailable) { | ||||
|                     commentRepository.totalCountCommentByPostId(postId = it.id!!) | ||||
|                     commentRepository.totalCountCommentByPostId(postId = it.id) | ||||
|                 } else { | ||||
|                     0 | ||||
|                 } | ||||
| @@ -431,19 +409,8 @@ class CreatorCommunityService( | ||||
|  | ||||
|                 val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId) | ||||
|  | ||||
|                 val content = if (it.price > 0 && memberId != it.creatorId) { | ||||
|                     if (existOrdered) { | ||||
|                         it.content | ||||
|                     } else { | ||||
|                         it.content.substring(0, 5).plus("...") | ||||
|                     } | ||||
|                 } else { | ||||
|                     it.content | ||||
|                 } | ||||
|  | ||||
|                 it.toCommunityPostListResponse( | ||||
|                     imageHost = imageHost, | ||||
|                     content = content, | ||||
|                     date = getTimeAgoString(it.date), | ||||
|                     isLike = isLike, | ||||
|                     existOrdered = if (memberId == it.creatorId) { | ||||
|   | ||||
| @@ -17,7 +17,6 @@ data class SelectCommunityPostResponse @QueryProjection constructor( | ||||
| ) { | ||||
|     fun toCommunityPostListResponse( | ||||
|         imageHost: String, | ||||
|         content: String, | ||||
|         date: String, | ||||
|         isLike: Boolean, | ||||
|         existOrdered: Boolean, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user