Compare commits
No commits in common. "b8afdffbe1d1ee1dd3c2493987f93a8b9da9d707" and "f6ba79f31c40daffe7404effa86f6a489f9871d7" have entirely different histories.
b8afdffbe1
...
f6ba79f31c
|
@ -2,7 +2,6 @@ package kr.co.vividnext.sodalive.live.room
|
||||||
|
|
||||||
import com.querydsl.core.types.Projections
|
import com.querydsl.core.types.Projections
|
||||||
import com.querydsl.core.types.dsl.CaseBuilder
|
import com.querydsl.core.types.dsl.CaseBuilder
|
||||||
import com.querydsl.core.types.dsl.Expressions
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.can.use.CanUsage
|
import kr.co.vividnext.sodalive.can.use.CanUsage
|
||||||
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
||||||
|
@ -50,7 +49,7 @@ interface LiveRoomQueryRepository {
|
||||||
fun getLiveRoom(id: Long): LiveRoom?
|
fun getLiveRoom(id: Long): LiveRoom?
|
||||||
fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom?
|
fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom?
|
||||||
fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse?
|
fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse?
|
||||||
fun getDonationTotal(roomId: Long): Int?
|
fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int?
|
||||||
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem>
|
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem>
|
||||||
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
|
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
|
||||||
fun getActiveRoomIdList(memberId: Long): Int
|
fun getActiveRoomIdList(memberId: Long): Int
|
||||||
|
@ -228,11 +227,14 @@ class LiveRoomQueryRepositoryImpl(
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getDonationTotal(roomId: Long): Int? {
|
override fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int? {
|
||||||
val where = liveRoom.id.eq(roomId)
|
var where = liveRoom.id.eq(roomId)
|
||||||
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
|
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
|
||||||
.and(useCan.isRefund.isFalse)
|
.and(useCan.isRefund.isFalse)
|
||||||
.and(useCan.isSecret.isFalse)
|
|
||||||
|
if (!isLiveCreator) {
|
||||||
|
where = where.and(useCan.isSecret.isFalse)
|
||||||
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(useCanCalculate.can.sum())
|
.select(useCanCalculate.can.sum())
|
||||||
|
@ -244,10 +246,14 @@ class LiveRoomQueryRepositoryImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> {
|
override fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> {
|
||||||
val where = liveRoom.id.eq(roomId)
|
var where = liveRoom.id.eq(roomId)
|
||||||
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
|
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
|
||||||
.and(useCan.isRefund.isFalse)
|
.and(useCan.isRefund.isFalse)
|
||||||
|
|
||||||
|
if (!isLiveCreator) {
|
||||||
|
where = where.and(useCan.isSecret.isFalse)
|
||||||
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
QGetLiveRoomDonationItem(
|
QGetLiveRoomDonationItem(
|
||||||
|
@ -257,31 +263,13 @@ class LiveRoomQueryRepositoryImpl(
|
||||||
.prepend(cloudFrontHost),
|
.prepend(cloudFrontHost),
|
||||||
member.nickname,
|
member.nickname,
|
||||||
member.id.coalesce(0),
|
member.id.coalesce(0),
|
||||||
Expressions.asNumber(
|
useCan.can.sum().add(useCan.rewardCan.sum())
|
||||||
CaseBuilder()
|
|
||||||
.`when`(useCan.isSecret.isFalse)
|
|
||||||
.then(useCan.can.add(useCan.rewardCan))
|
|
||||||
.otherwise(0)
|
|
||||||
).sum(),
|
|
||||||
Expressions.asNumber(
|
|
||||||
CaseBuilder()
|
|
||||||
.`when`(Expressions.asBoolean(isLiveCreator).isTrue)
|
|
||||||
.then(
|
|
||||||
Expressions.asNumber(
|
|
||||||
CaseBuilder()
|
|
||||||
.`when`(useCan.isSecret.isTrue)
|
|
||||||
.then(useCan.can.add(useCan.rewardCan))
|
|
||||||
.otherwise(0)
|
|
||||||
).sum()
|
|
||||||
)
|
|
||||||
.otherwise(0)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(useCan)
|
.from(useCan)
|
||||||
.innerJoin(useCan.room, liveRoom)
|
.innerJoin(useCan.room, liveRoom)
|
||||||
.join(useCan.member, member)
|
.join(useCan.member, member)
|
||||||
.groupBy(useCan.member.id)
|
.groupBy(useCan.member)
|
||||||
.where(where)
|
.where(where)
|
||||||
.orderBy(useCan.can.sum().add(useCan.rewardCan.sum()).desc())
|
.orderBy(useCan.can.sum().add(useCan.rewardCan.sum()).desc())
|
||||||
.fetch()
|
.fetch()
|
||||||
|
|
|
@ -973,8 +973,11 @@ class LiveRoomService(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDonationTotal(roomId: Long, memberId: Long): GetLiveRoomDonationTotalResponse {
|
fun getDonationTotal(roomId: Long, memberId: Long): GetLiveRoomDonationTotalResponse {
|
||||||
|
val room = repository.getLiveRoom(roomId)
|
||||||
|
?: return GetLiveRoomDonationTotalResponse(0)
|
||||||
|
val isLiveCreator = room.member!!.id == memberId
|
||||||
return GetLiveRoomDonationTotalResponse(
|
return GetLiveRoomDonationTotalResponse(
|
||||||
totalDonationCan = repository.getDonationTotal(roomId = roomId) ?: 0
|
totalDonationCan = repository.getDonationTotal(roomId = roomId, isLiveCreator = isLiveCreator) ?: 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1177,15 +1180,12 @@ class LiveRoomService(
|
||||||
val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.")
|
val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.")
|
||||||
val isLiveCreator = room.member!!.id == memberId
|
val isLiveCreator = room.member!!.id == memberId
|
||||||
val donationList = repository.getDonationList(roomId = room.id!!, isLiveCreator = isLiveCreator)
|
val donationList = repository.getDonationList(roomId = room.id!!, isLiveCreator = isLiveCreator)
|
||||||
.filter { it.secretCan > 0 || it.can > 0 }
|
|
||||||
val totalCan = donationList.sumOf { it.can }
|
val totalCan = donationList.sumOf { it.can }
|
||||||
val totalSecretCan = donationList.sumOf { it.secretCan }
|
|
||||||
|
|
||||||
return GetLiveRoomDonationStatusResponse(
|
return GetLiveRoomDonationStatusResponse(
|
||||||
donationList = donationList,
|
donationList = donationList,
|
||||||
totalCount = donationList.size,
|
totalCount = donationList.size,
|
||||||
totalCan = totalCan,
|
totalCan = totalCan
|
||||||
totalSecretCan = totalSecretCan
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,12 @@ import com.querydsl.core.annotations.QueryProjection
|
||||||
data class GetLiveRoomDonationStatusResponse(
|
data class GetLiveRoomDonationStatusResponse(
|
||||||
val donationList: List<GetLiveRoomDonationItem>,
|
val donationList: List<GetLiveRoomDonationItem>,
|
||||||
val totalCount: Int,
|
val totalCount: Int,
|
||||||
val totalCan: Int,
|
val totalCan: Int
|
||||||
val totalSecretCan: Int
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data class GetLiveRoomDonationItem @QueryProjection constructor(
|
data class GetLiveRoomDonationItem @QueryProjection constructor(
|
||||||
val profileImage: String,
|
val profileImage: String,
|
||||||
val nickname: String,
|
val nickname: String,
|
||||||
val userId: Long,
|
val userId: Long,
|
||||||
val can: Int,
|
val can: Int
|
||||||
val secretCan: Int
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue