크리에이터 커뮤니티 #102
|
@ -137,7 +137,8 @@ class CreatorCommunityService(
|
||||||
return postList
|
return postList
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map {
|
.map {
|
||||||
val isLike = likeRepository.findByIdAndMemberId(id = it.id!!, memberId = memberId)?.isActive ?: false
|
val isLike =
|
||||||
|
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!!)
|
||||||
|
@ -197,7 +198,7 @@ class CreatorCommunityService(
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
fun communityPostLike(request: PostCommunityPostLikeRequest, member: Member): PostCommunityPostLikeResponse {
|
fun communityPostLike(request: PostCommunityPostLikeRequest, member: Member): PostCommunityPostLikeResponse {
|
||||||
var postLike = likeRepository.findByIdAndMemberId(id = request.postId, memberId = member.id!!)
|
var postLike = likeRepository.findByPostIdAndMemberId(postId = request.postId, memberId = member.id!!)
|
||||||
|
|
||||||
if (postLike == null) {
|
if (postLike == null) {
|
||||||
postLike = CreatorCommunityLike()
|
postLike = CreatorCommunityLike()
|
||||||
|
|
|
@ -1,21 +1,33 @@
|
||||||
package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.like
|
package kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.like
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
|
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.QCreatorCommunity.creatorCommunity
|
||||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.like.QCreatorCommunityLike.creatorCommunityLike
|
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.like.QCreatorCommunityLike.creatorCommunityLike
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
|
||||||
interface CreatorCommunityLikeRepository :
|
interface CreatorCommunityLikeRepository :
|
||||||
JpaRepository<CreatorCommunityLike, Long>, CreatorCommunityLikeQueryRepository {
|
JpaRepository<CreatorCommunityLike, Long>, CreatorCommunityLikeQueryRepository
|
||||||
fun findByIdAndMemberId(id: Long, memberId: Long): CreatorCommunityLike?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CreatorCommunityLikeQueryRepository {
|
interface CreatorCommunityLikeQueryRepository {
|
||||||
|
fun findByPostIdAndMemberId(postId: Long, memberId: Long): CreatorCommunityLike?
|
||||||
|
|
||||||
fun totalCountCommunityPostLikeByPostId(postId: Long): Int
|
fun totalCountCommunityPostLikeByPostId(postId: Long): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreatorCommunityLikeQueryRepositoryImpl(
|
class CreatorCommunityLikeQueryRepositoryImpl(
|
||||||
private val queryFactory: JPAQueryFactory
|
private val queryFactory: JPAQueryFactory
|
||||||
) : CreatorCommunityLikeQueryRepository {
|
) : CreatorCommunityLikeQueryRepository {
|
||||||
|
override fun findByPostIdAndMemberId(postId: Long, memberId: Long): CreatorCommunityLike? {
|
||||||
|
return queryFactory
|
||||||
|
.selectFrom(creatorCommunityLike)
|
||||||
|
.innerJoin(creatorCommunityLike.creatorCommunity, creatorCommunity)
|
||||||
|
.where(
|
||||||
|
creatorCommunityLike.creatorCommunity.id.eq(postId)
|
||||||
|
.and(creatorCommunityLike.member.id.eq(memberId))
|
||||||
|
)
|
||||||
|
.fetchFirst()
|
||||||
|
}
|
||||||
|
|
||||||
override fun totalCountCommunityPostLikeByPostId(postId: Long): Int {
|
override fun totalCountCommunityPostLikeByPostId(postId: Long): Int {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(creatorCommunityLike.id)
|
.select(creatorCommunityLike.id)
|
||||||
|
|
Loading…
Reference in New Issue