Compare commits

..

No commits in common. "0c153aeb6a6742f7e5d02de7474f84bc1e387f80" and "a25b7d5cc22d51e0e4c314db16e2d6e97e969096" have entirely different histories.

5 changed files with 30 additions and 51 deletions

View File

@ -307,11 +307,8 @@ class ExplorerService(
val followerList = queryRepository.getFollowerList(creatorId, pageable.offset, pageable.pageSize.toLong())
.map {
val creatorFollowing = if (it.role == MemberRole.CREATOR) {
queryRepository.getCreatorFollowing(
creatorId = it.userId,
memberId = member.id!!
)
val isFollow = if (it.role == MemberRole.CREATOR) {
queryRepository.isFollow(creatorId = it.userId, memberId = member.id!!)
} else {
null
}
@ -320,8 +317,7 @@ class ExplorerService(
userId = it.userId,
profileImage = it.profileImage,
nickname = it.nickname,
isFollow = creatorFollowing?.isFollow ?: false,
isNotify = creatorFollowing?.isNotify ?: false
isFollow = isFollow
)
}

View File

@ -9,6 +9,5 @@ data class GetFollowerListResponseItem(
val userId: Long,
val profileImage: String,
val nickname: String,
val isFollow: Boolean?,
val isNotify: Boolean?
val isFollow: Boolean?
)

View File

@ -162,7 +162,7 @@ class LiveRoomController(
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(service.getDonationTotal(roomId, memberId = member.id!!))
ApiResponse.ok(service.getDonationTotal(roomId))
}
@PutMapping("/info/set/speaker")
@ -232,7 +232,7 @@ class LiveRoomController(
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(service.getDonationStatus(roomId, memberId = member.id!!))
ApiResponse.ok(service.getDonationStatus(roomId, member))
}
@PostMapping("/quit")

View File

@ -11,7 +11,6 @@ import kr.co.vividnext.sodalive.live.room.QQuarterLiveRankings.quarterLiveRankin
import kr.co.vividnext.sodalive.live.room.donation.GetLiveRoomDonationItem
import kr.co.vividnext.sodalive.live.room.donation.QGetLiveRoomDonationItem
import kr.co.vividnext.sodalive.member.QMember.member
import org.springframework.beans.factory.annotation.Value
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
import java.time.LocalDateTime
@ -48,18 +47,13 @@ interface LiveRoomQueryRepository {
fun getLiveRoom(id: Long): LiveRoom?
fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom?
fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse?
fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int?
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem>
fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse?
fun getDonationTotal(roomId: Long): Int?
fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem>
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
}
class LiveRoomQueryRepositoryImpl(
private val queryFactory: JPAQueryFactory,
@Value("\${cloud.aws.cloud-front.host}")
private val cloudFrontHost: String
) : LiveRoomQueryRepository {
class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository {
override fun getLiveRoomListNow(
offset: Long,
limit: Long,
@ -206,7 +200,7 @@ class LiveRoomQueryRepositoryImpl(
.fetchFirst()
}
override fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? {
override fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? {
return queryFactory
.select(
Projections.constructor(
@ -225,33 +219,22 @@ class LiveRoomQueryRepositoryImpl(
.fetchFirst()
}
override fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int? {
var where = liveRoom.id.eq(roomId)
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
.and(useCan.isRefund.isFalse)
if (!isLiveCreator) {
where = where.and(useCan.isSecret.isFalse)
}
override fun getDonationTotal(roomId: Long): Int? {
return queryFactory
.select(useCanCalculate.can.sum())
.from(useCanCalculate)
.innerJoin(useCanCalculate.useCan, useCan)
.innerJoin(useCan.room, liveRoom)
.where(where)
.where(
liveRoom.id.eq(roomId)
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
.and(useCan.isRefund.isFalse)
.and(useCan.isSecret.isFalse)
)
.fetchOne()
}
override fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> {
var where = liveRoom.id.eq(roomId)
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
.and(useCan.isRefund.isFalse)
if (!isLiveCreator) {
where = where.and(useCan.isSecret.isFalse)
}
override fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem> {
return queryFactory
.select(
QGetLiveRoomDonationItem(
@ -267,7 +250,12 @@ class LiveRoomQueryRepositoryImpl(
.from(useCan)
.join(useCan.member, member)
.groupBy(useCan.member)
.where(where)
.where(
useCan.room.id.eq(roomId)
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
.and(useCan.isRefund.isFalse)
.and(useCan.isSecret.isFalse)
)
.orderBy(useCan.can.sum().add(useCan.rewardCan.sum()).desc())
.fetch()
}

View File

@ -690,7 +690,7 @@ class LiveRoomService(
}
fun getRecentRoomInfo(member: Member): GetRecentRoomInfoResponse {
return repository.getRecentRoomInfo(memberId = member.id!!)
return repository.getRecentRoomInfo(memberId = member.id!!, cloudFrontHost = cloudFrontHost)
?: throw SodaException("최근 데이터가 없습니다.")
}
@ -965,12 +965,9 @@ class LiveRoomService(
)
}
fun getDonationTotal(roomId: Long, memberId: Long): GetLiveRoomDonationTotalResponse {
val room = repository.getLiveRoom(roomId)
?: return GetLiveRoomDonationTotalResponse(0)
val isLiveCreator = room.member!!.id == memberId
fun getDonationTotal(roomId: Long): GetLiveRoomDonationTotalResponse {
return GetLiveRoomDonationTotalResponse(
totalDonationCan = repository.getDonationTotal(roomId = roomId, isLiveCreator = isLiveCreator) ?: 0
totalDonationCan = repository.getDonationTotal(roomId = roomId) ?: 0
)
}
@ -1169,10 +1166,9 @@ class LiveRoomService(
}
}
fun getDonationStatus(roomId: Long, memberId: Long): GetLiveRoomDonationStatusResponse {
fun getDonationStatus(roomId: Long, member: Member): GetLiveRoomDonationStatusResponse {
val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.")
val isLiveCreator = room.member!!.id == memberId
val donationList = repository.getDonationList(roomId = room.id!!, isLiveCreator = isLiveCreator)
val donationList = repository.getDonationList(roomId = room.id!!, cloudFrontHost = cloudFrontHost)
val totalCan = donationList.sumOf { it.can }
return GetLiveRoomDonationStatusResponse(