라이브 방 - 아고라 설정 및 라이브 방 관련 API
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package kr.co.vividnext.sodalive.explorer
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.can.use.CanUsage
|
||||
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
||||
import kr.co.vividnext.sodalive.live.room.QLiveRoom.liveRoom
|
||||
import kr.co.vividnext.sodalive.member.QMember
|
||||
import kr.co.vividnext.sodalive.member.following.QCreatorFollowing.creatorFollowing
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
class ExplorerQueryRepository(
|
||||
private val queryFactory: JPAQueryFactory,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val cloudFrontHost: String
|
||||
) {
|
||||
fun getNotificationUserIds(creatorId: Long): List<Long> {
|
||||
return queryFactory
|
||||
.select(creatorFollowing.member.id)
|
||||
.from(creatorFollowing)
|
||||
.where(
|
||||
creatorFollowing.isActive.isTrue
|
||||
.and(creatorFollowing.creator.id.eq(creatorId))
|
||||
)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
fun getMemberDonationRanking(
|
||||
creatorId: Long,
|
||||
limit: Long,
|
||||
offset: Long = 0,
|
||||
withDonationCoin: Boolean
|
||||
): List<MemberDonationRankingResponse> {
|
||||
val creator = QMember("creator")
|
||||
val member = QMember("user")
|
||||
|
||||
val donation = useCan.rewardCan.add(useCan.can).sum()
|
||||
return queryFactory
|
||||
.select(member, donation)
|
||||
.from(useCan)
|
||||
.join(useCan.room, liveRoom)
|
||||
.join(liveRoom.member, creator)
|
||||
.join(useCan.member, member)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.where(
|
||||
useCan.canUsage.eq(CanUsage.DONATION)
|
||||
.and(useCan.isRefund.isFalse)
|
||||
.and(creator.id.eq(creatorId))
|
||||
)
|
||||
.groupBy(useCan.member.id)
|
||||
.orderBy(donation.desc(), member.id.desc())
|
||||
.fetch()
|
||||
.map {
|
||||
val account = it.get(member)!!
|
||||
val donationCoin = it.get(donation)!!
|
||||
MemberDonationRankingResponse(
|
||||
account.id!!,
|
||||
account.nickname,
|
||||
if (account.profileImage != null) {
|
||||
"$cloudFrontHost/${account.profileImage}"
|
||||
} else {
|
||||
"$cloudFrontHost/profile/default-profile.png"
|
||||
},
|
||||
if (withDonationCoin) donationCoin else 0
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package kr.co.vividnext.sodalive.explorer
|
||||
|
||||
data class MemberDonationRankingResponse(
|
||||
val userId: Long,
|
||||
val nickname: String,
|
||||
val profileImage: String,
|
||||
val donationCoin: Int
|
||||
)
|
Reference in New Issue
Block a user