parent
d241b4fa7a
commit
87f22f45aa
|
@ -86,7 +86,7 @@ class AdminContentService(
|
||||||
?: throw SodaException("없는 콘텐츠 입니다.")
|
?: throw SodaException("없는 콘텐츠 입니다.")
|
||||||
|
|
||||||
if (request.isDefaultCoverImage) {
|
if (request.isDefaultCoverImage) {
|
||||||
audioContent.coverImage = "profile/default_profile.png"
|
audioContent.coverImage = "`profile/default_profile.png`"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.isActive != null) {
|
if (request.isActive != null) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.can.use
|
||||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
import kr.co.vividnext.sodalive.common.BaseEntity
|
||||||
import kr.co.vividnext.sodalive.content.AudioContent
|
import kr.co.vividnext.sodalive.content.AudioContent
|
||||||
import kr.co.vividnext.sodalive.content.order.Order
|
import kr.co.vividnext.sodalive.content.order.Order
|
||||||
|
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunity
|
||||||
import kr.co.vividnext.sodalive.live.room.LiveRoom
|
import kr.co.vividnext.sodalive.live.room.LiveRoom
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import javax.persistence.CascadeType
|
import javax.persistence.CascadeType
|
||||||
|
@ -42,10 +43,14 @@ data class UseCan(
|
||||||
@JoinColumn(name = "order_id", nullable = true)
|
@JoinColumn(name = "order_id", nullable = true)
|
||||||
var order: Order? = null
|
var order: Order? = null
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "content_id", nullable = true)
|
@JoinColumn(name = "content_id", nullable = true)
|
||||||
var audioContent: AudioContent? = null
|
var audioContent: AudioContent? = null
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "creator_community_id", nullable = true)
|
||||||
|
var communityPost: CreatorCommunity? = null
|
||||||
|
|
||||||
@OneToMany(mappedBy = "useCan", cascade = [CascadeType.ALL])
|
@OneToMany(mappedBy = "useCan", cascade = [CascadeType.ALL])
|
||||||
val useCanCalculates: MutableList<UseCanCalculate> = mutableListOf()
|
val useCanCalculates: MutableList<UseCanCalculate> = mutableListOf()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,28 @@
|
||||||
package kr.co.vividnext.sodalive.can.use
|
package kr.co.vividnext.sodalive.can.use
|
||||||
|
|
||||||
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
|
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
interface UseCanRepository : JpaRepository<UseCan, Long>
|
interface UseCanRepository : JpaRepository<UseCan, Long>, UseCanQueryRepository
|
||||||
|
|
||||||
|
interface UseCanQueryRepository {
|
||||||
|
fun isExistOrdered(postId: Long, memberId: Long): Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
class UseCanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : UseCanQueryRepository {
|
||||||
|
override fun isExistOrdered(postId: Long, memberId: Long): Boolean {
|
||||||
|
val useCanId = queryFactory.select(useCan.id)
|
||||||
|
.from(useCan)
|
||||||
|
.where(
|
||||||
|
useCan.member.id.eq(memberId)
|
||||||
|
.and(useCan.isRefund.isFalse)
|
||||||
|
.and(useCan.communityPost.id.eq(postId))
|
||||||
|
)
|
||||||
|
.fetchFirst()
|
||||||
|
|
||||||
|
return useCanId != null && useCanId > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@ interface CreatorCommunityQueryRepository {
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long,
|
limit: Long,
|
||||||
isAdult: Boolean
|
isAdult: Boolean
|
||||||
): List<CreatorCommunity>
|
): List<SelectCommunityPostResponse>
|
||||||
|
|
||||||
fun findByIdAndActive(postId: Long, isAdult: Boolean): CreatorCommunity?
|
fun findByIdAndActive(postId: Long, isAdult: Boolean): CreatorCommunity?
|
||||||
fun getLatestPostListFromCreatorsYouFollow(memberId: Long, isAdult: Boolean): List<CreatorCommunity>
|
fun getLatestPostListFromCreatorsYouFollow(memberId: Long, isAdult: Boolean): List<SelectCommunityPostResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CreatorCommunityQueryRepository {
|
class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CreatorCommunityQueryRepository {
|
||||||
|
@ -42,7 +42,7 @@ class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFact
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long,
|
limit: Long,
|
||||||
isAdult: Boolean
|
isAdult: Boolean
|
||||||
): List<CreatorCommunity> {
|
): List<SelectCommunityPostResponse> {
|
||||||
var where = creatorCommunity.member.id.eq(creatorId)
|
var where = creatorCommunity.member.id.eq(creatorId)
|
||||||
.and(creatorCommunity.isActive.isTrue)
|
.and(creatorCommunity.isActive.isTrue)
|
||||||
|
|
||||||
|
@ -51,7 +51,20 @@ class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFact
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.selectFrom(creatorCommunity)
|
.select(
|
||||||
|
QSelectCommunityPostResponse(
|
||||||
|
creatorCommunity.id,
|
||||||
|
creatorCommunity.member.id,
|
||||||
|
creatorCommunity.member.nickname,
|
||||||
|
creatorCommunity.member.profileImage.coalesce("profile/default_profile.png"),
|
||||||
|
creatorCommunity.imagePath,
|
||||||
|
creatorCommunity.content,
|
||||||
|
creatorCommunity.createdAt,
|
||||||
|
creatorCommunity.isCommentAvailable,
|
||||||
|
creatorCommunity.price
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.from(creatorCommunity)
|
||||||
.innerJoin(creatorCommunity.member, member)
|
.innerJoin(creatorCommunity.member, member)
|
||||||
.where(where)
|
.where(where)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
|
@ -74,7 +87,10 @@ class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFact
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLatestPostListFromCreatorsYouFollow(memberId: Long, isAdult: Boolean): List<CreatorCommunity> {
|
override fun getLatestPostListFromCreatorsYouFollow(
|
||||||
|
memberId: Long,
|
||||||
|
isAdult: Boolean
|
||||||
|
): List<SelectCommunityPostResponse> {
|
||||||
val creatorCommunity = QCreatorCommunity.creatorCommunity
|
val creatorCommunity = QCreatorCommunity.creatorCommunity
|
||||||
val latest = QCreatorCommunity.creatorCommunity
|
val latest = QCreatorCommunity.creatorCommunity
|
||||||
|
|
||||||
|
@ -110,7 +126,21 @@ class CreatorCommunityQueryRepositoryImpl(private val queryFactory: JPAQueryFact
|
||||||
)
|
)
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.selectFrom(creatorCommunity)
|
.select(
|
||||||
|
QSelectCommunityPostResponse(
|
||||||
|
creatorCommunity.id,
|
||||||
|
creatorCommunity.member.id,
|
||||||
|
creatorCommunity.member.nickname,
|
||||||
|
creatorCommunity.member.profileImage.coalesce("profile/default_profile.png"),
|
||||||
|
creatorCommunity.imagePath,
|
||||||
|
creatorCommunity.content,
|
||||||
|
creatorCommunity.createdAt,
|
||||||
|
creatorCommunity.isCommentAvailable,
|
||||||
|
creatorCommunity.price
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.from(creatorCommunity)
|
||||||
|
.innerJoin(creatorCommunity.member, member)
|
||||||
.where(where)
|
.where(where)
|
||||||
.orderBy(creatorCommunity.createdAt.desc())
|
.orderBy(creatorCommunity.createdAt.desc())
|
||||||
.limit(10)
|
.limit(10)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity
|
||||||
import com.amazonaws.services.s3.model.ObjectMetadata
|
import com.amazonaws.services.s3.model.ObjectMetadata
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||||
|
import kr.co.vividnext.sodalive.can.use.UseCanRepository
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment.CreatorCommunityComment
|
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment.CreatorCommunityComment
|
||||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment.CreatorCommunityCommentRepository
|
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.comment.CreatorCommunityCommentRepository
|
||||||
|
@ -32,6 +33,7 @@ class CreatorCommunityService(
|
||||||
private val blockMemberRepository: BlockMemberRepository,
|
private val blockMemberRepository: BlockMemberRepository,
|
||||||
private val likeRepository: CreatorCommunityLikeRepository,
|
private val likeRepository: CreatorCommunityLikeRepository,
|
||||||
private val commentRepository: CreatorCommunityCommentRepository,
|
private val commentRepository: CreatorCommunityCommentRepository,
|
||||||
|
private val useCanRepository: UseCanRepository,
|
||||||
|
|
||||||
private val s3Uploader: S3Uploader,
|
private val s3Uploader: S3Uploader,
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
|
@ -138,6 +140,10 @@ class CreatorCommunityService(
|
||||||
limit: Long,
|
limit: Long,
|
||||||
isAdult: Boolean
|
isAdult: Boolean
|
||||||
): List<GetCommunityPostListResponse> {
|
): List<GetCommunityPostListResponse> {
|
||||||
|
if (blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = creatorId)) {
|
||||||
|
return listOf()
|
||||||
|
}
|
||||||
|
|
||||||
val postList = repository.getCommunityPostList(
|
val postList = repository.getCommunityPostList(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
offset = offset,
|
offset = offset,
|
||||||
|
@ -147,18 +153,12 @@ class CreatorCommunityService(
|
||||||
|
|
||||||
return postList
|
return postList
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter {
|
|
||||||
!blockMemberRepository.isBlocked(
|
|
||||||
blockedMemberId = memberId,
|
|
||||||
memberId = creatorId
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.map {
|
.map {
|
||||||
val isLike =
|
val isLike = likeRepository.findByPostIdAndMemberId(postId = it.id, memberId = memberId)?.isActive
|
||||||
likeRepository.findByPostIdAndMemberId(postId = it.id!!, memberId = memberId)?.isActive ?: 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)
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ class CreatorCommunityService(
|
||||||
commentRepository.findByPostId(
|
commentRepository.findByPostId(
|
||||||
cloudFrontHost = imageHost,
|
cloudFrontHost = imageHost,
|
||||||
timezone = timezone,
|
timezone = timezone,
|
||||||
id = it.id!!,
|
id = it.id,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
limit = 1
|
limit = 1
|
||||||
)
|
)
|
||||||
|
@ -180,25 +180,35 @@ class CreatorCommunityService(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCommunityPostListResponse(
|
val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId)
|
||||||
postId = it.id!!,
|
|
||||||
creatorId = it.member!!.id!!,
|
val content = if (it.price > 0) {
|
||||||
creatorNickname = it.member!!.nickname,
|
if (existOrdered) {
|
||||||
creatorProfileUrl = if (it.member!!.profileImage != null) {
|
it.content
|
||||||
"$imageHost/${it.member!!.profileImage}"
|
|
||||||
} else {
|
} else {
|
||||||
"$imageHost/profile/default-profile.png"
|
it.content.substring(0, 5).plus("...")
|
||||||
},
|
}
|
||||||
|
} else {
|
||||||
|
it.content
|
||||||
|
}
|
||||||
|
|
||||||
|
GetCommunityPostListResponse(
|
||||||
|
postId = it.id,
|
||||||
|
creatorId = it.creatorId,
|
||||||
|
creatorNickname = it.creatorNickname,
|
||||||
|
creatorProfileUrl = "$imageHost/${it.creatorProfileUrl}",
|
||||||
imageUrl = if (it.imagePath != null) {
|
imageUrl = if (it.imagePath != null) {
|
||||||
"$imageHost/${it.imagePath!!}"
|
"$imageHost/${it.imagePath}"
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
},
|
},
|
||||||
content = it.content,
|
content = content,
|
||||||
date = getTimeAgoString(it.createdAt!!),
|
price = it.price,
|
||||||
|
date = getTimeAgoString(it.date),
|
||||||
isCommentAvailable = it.isCommentAvailable,
|
isCommentAvailable = it.isCommentAvailable,
|
||||||
isAdult = it.isAdult,
|
isAdult = false,
|
||||||
isLike = isLike,
|
isLike = isLike,
|
||||||
|
existOrdered = existOrdered,
|
||||||
likeCount = likeCount,
|
likeCount = likeCount,
|
||||||
commentCount = commentCount,
|
commentCount = commentCount,
|
||||||
firstComment = firstComment
|
firstComment = firstComment
|
||||||
|
@ -244,6 +254,18 @@ class CreatorCommunityService(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val existOrdered = useCanRepository.isExistOrdered(postId = post.id!!, memberId = memberId)
|
||||||
|
|
||||||
|
val content = if (post.price > 0) {
|
||||||
|
if (existOrdered) {
|
||||||
|
post.content
|
||||||
|
} else {
|
||||||
|
post.content.substring(0, 5).plus("...")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
post.content
|
||||||
|
}
|
||||||
|
|
||||||
return GetCommunityPostListResponse(
|
return GetCommunityPostListResponse(
|
||||||
postId = post.id!!,
|
postId = post.id!!,
|
||||||
creatorId = post.member!!.id!!,
|
creatorId = post.member!!.id!!,
|
||||||
|
@ -258,11 +280,13 @@ class CreatorCommunityService(
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
},
|
},
|
||||||
content = post.content,
|
content = content,
|
||||||
|
price = post.price,
|
||||||
date = getTimeAgoString(post.createdAt!!),
|
date = getTimeAgoString(post.createdAt!!),
|
||||||
isCommentAvailable = post.isCommentAvailable,
|
isCommentAvailable = post.isCommentAvailable,
|
||||||
isAdult = post.isAdult,
|
isAdult = post.isAdult,
|
||||||
isLike = isLike,
|
isLike = isLike,
|
||||||
|
existOrdered = existOrdered,
|
||||||
likeCount = likeCount,
|
likeCount = likeCount,
|
||||||
commentCount = commentCount,
|
commentCount = commentCount,
|
||||||
firstComment = firstComment
|
firstComment = firstComment
|
||||||
|
@ -392,7 +416,7 @@ class CreatorCommunityService(
|
||||||
.filter {
|
.filter {
|
||||||
!blockMemberRepository.isBlocked(
|
!blockMemberRepository.isBlocked(
|
||||||
blockedMemberId = memberId,
|
blockedMemberId = memberId,
|
||||||
memberId = it.member!!.id!!
|
memberId = it.creatorId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.map {
|
.map {
|
||||||
|
@ -422,25 +446,35 @@ class CreatorCommunityService(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCommunityPostListResponse(
|
val existOrdered = useCanRepository.isExistOrdered(postId = it.id, memberId = memberId)
|
||||||
postId = it.id!!,
|
|
||||||
creatorId = it.member!!.id!!,
|
val content = if (it.price > 0) {
|
||||||
creatorNickname = it.member!!.nickname,
|
if (existOrdered) {
|
||||||
creatorProfileUrl = if (it.member!!.profileImage != null) {
|
it.content
|
||||||
"$imageHost/${it.member!!.profileImage}"
|
|
||||||
} else {
|
} else {
|
||||||
"$imageHost/profile/default-profile.png"
|
it.content.substring(0, 5).plus("...")
|
||||||
},
|
}
|
||||||
|
} else {
|
||||||
|
it.content
|
||||||
|
}
|
||||||
|
|
||||||
|
GetCommunityPostListResponse(
|
||||||
|
postId = it.id,
|
||||||
|
creatorId = it.creatorId,
|
||||||
|
creatorNickname = it.creatorNickname,
|
||||||
|
creatorProfileUrl = "$imageHost/${it.creatorProfileUrl}",
|
||||||
imageUrl = if (it.imagePath != null) {
|
imageUrl = if (it.imagePath != null) {
|
||||||
"$imageHost/${it.imagePath!!}"
|
"$imageHost/${it.imagePath}"
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
},
|
},
|
||||||
content = it.content,
|
content = content,
|
||||||
date = getTimeAgoString(it.createdAt!!),
|
price = it.price,
|
||||||
|
date = getTimeAgoString(it.date),
|
||||||
isCommentAvailable = it.isCommentAvailable,
|
isCommentAvailable = it.isCommentAvailable,
|
||||||
isAdult = it.isAdult,
|
isAdult = false,
|
||||||
isLike = isLike,
|
isLike = isLike,
|
||||||
|
existOrdered = existOrdered,
|
||||||
likeCount = likeCount,
|
likeCount = likeCount,
|
||||||
commentCount = commentCount,
|
commentCount = commentCount,
|
||||||
firstComment = firstComment
|
firstComment = firstComment
|
||||||
|
|
|
@ -10,10 +10,12 @@ data class GetCommunityPostListResponse @QueryProjection constructor(
|
||||||
val creatorProfileUrl: String,
|
val creatorProfileUrl: String,
|
||||||
val imageUrl: String?,
|
val imageUrl: String?,
|
||||||
val content: String,
|
val content: String,
|
||||||
|
val price: Int,
|
||||||
val date: String,
|
val date: String,
|
||||||
val isCommentAvailable: Boolean,
|
val isCommentAvailable: Boolean,
|
||||||
val isAdult: Boolean,
|
val isAdult: Boolean,
|
||||||
val isLike: Boolean,
|
val isLike: Boolean,
|
||||||
|
val existOrdered: Boolean,
|
||||||
val likeCount: Int,
|
val likeCount: Int,
|
||||||
val commentCount: Int,
|
val commentCount: Int,
|
||||||
val firstComment: GetCommunityPostCommentListItem?
|
val firstComment: GetCommunityPostCommentListItem?
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity
|
||||||
|
|
||||||
|
import com.querydsl.core.annotations.QueryProjection
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
|
data class SelectCommunityPostResponse @QueryProjection constructor(
|
||||||
|
val id: Long,
|
||||||
|
val creatorId: Long,
|
||||||
|
val creatorNickname: String,
|
||||||
|
val creatorProfileUrl: String,
|
||||||
|
val imagePath: String?,
|
||||||
|
val content: String,
|
||||||
|
val date: LocalDateTime,
|
||||||
|
val isCommentAvailable: Boolean,
|
||||||
|
val price: Int
|
||||||
|
)
|
Loading…
Reference in New Issue