Compare commits
3 Commits
a25b7d5cc2
...
0c153aeb6a
Author | SHA1 | Date |
---|---|---|
|
0c153aeb6a | |
|
2c4c19990a | |
|
dd0b751a43 |
|
@ -307,8 +307,11 @@ class ExplorerService(
|
|||
|
||||
val followerList = queryRepository.getFollowerList(creatorId, pageable.offset, pageable.pageSize.toLong())
|
||||
.map {
|
||||
val isFollow = if (it.role == MemberRole.CREATOR) {
|
||||
queryRepository.isFollow(creatorId = it.userId, memberId = member.id!!)
|
||||
val creatorFollowing = if (it.role == MemberRole.CREATOR) {
|
||||
queryRepository.getCreatorFollowing(
|
||||
creatorId = it.userId,
|
||||
memberId = member.id!!
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
@ -317,7 +320,8 @@ class ExplorerService(
|
|||
userId = it.userId,
|
||||
profileImage = it.profileImage,
|
||||
nickname = it.nickname,
|
||||
isFollow = isFollow
|
||||
isFollow = creatorFollowing?.isFollow ?: false,
|
||||
isNotify = creatorFollowing?.isNotify ?: false
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,5 +9,6 @@ data class GetFollowerListResponseItem(
|
|||
val userId: Long,
|
||||
val profileImage: String,
|
||||
val nickname: String,
|
||||
val isFollow: Boolean?
|
||||
val isFollow: Boolean?,
|
||||
val isNotify: Boolean?
|
||||
)
|
||||
|
|
|
@ -162,7 +162,7 @@ class LiveRoomController(
|
|||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.getDonationTotal(roomId))
|
||||
ApiResponse.ok(service.getDonationTotal(roomId, memberId = member.id!!))
|
||||
}
|
||||
|
||||
@PutMapping("/info/set/speaker")
|
||||
|
@ -232,7 +232,7 @@ class LiveRoomController(
|
|||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.getDonationStatus(roomId, member))
|
||||
ApiResponse.ok(service.getDonationStatus(roomId, memberId = member.id!!))
|
||||
}
|
||||
|
||||
@PostMapping("/quit")
|
||||
|
|
|
@ -11,6 +11,7 @@ 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
|
||||
|
@ -47,13 +48,18 @@ interface LiveRoomQueryRepository {
|
|||
|
||||
fun getLiveRoom(id: Long): LiveRoom?
|
||||
fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom?
|
||||
fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse?
|
||||
fun getDonationTotal(roomId: Long): Int?
|
||||
fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem>
|
||||
fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse?
|
||||
fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int?
|
||||
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem>
|
||||
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
|
||||
}
|
||||
|
||||
class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository {
|
||||
class LiveRoomQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val cloudFrontHost: String
|
||||
) : LiveRoomQueryRepository {
|
||||
override fun getLiveRoomListNow(
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
|
@ -200,7 +206,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L
|
|||
.fetchFirst()
|
||||
}
|
||||
|
||||
override fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? {
|
||||
override fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
|
@ -219,22 +225,33 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L
|
|||
.fetchFirst()
|
||||
}
|
||||
|
||||
override fun getDonationTotal(roomId: Long): Int? {
|
||||
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)
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(useCanCalculate.can.sum())
|
||||
.from(useCanCalculate)
|
||||
.innerJoin(useCanCalculate.useCan, useCan)
|
||||
.innerJoin(useCan.room, liveRoom)
|
||||
.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)
|
||||
)
|
||||
.where(where)
|
||||
.fetchOne()
|
||||
}
|
||||
|
||||
override fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem> {
|
||||
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)
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetLiveRoomDonationItem(
|
||||
|
@ -250,12 +267,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L
|
|||
.from(useCan)
|
||||
.join(useCan.member, member)
|
||||
.groupBy(useCan.member)
|
||||
.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)
|
||||
)
|
||||
.where(where)
|
||||
.orderBy(useCan.can.sum().add(useCan.rewardCan.sum()).desc())
|
||||
.fetch()
|
||||
}
|
||||
|
|
|
@ -690,7 +690,7 @@ class LiveRoomService(
|
|||
}
|
||||
|
||||
fun getRecentRoomInfo(member: Member): GetRecentRoomInfoResponse {
|
||||
return repository.getRecentRoomInfo(memberId = member.id!!, cloudFrontHost = cloudFrontHost)
|
||||
return repository.getRecentRoomInfo(memberId = member.id!!)
|
||||
?: throw SodaException("최근 데이터가 없습니다.")
|
||||
}
|
||||
|
||||
|
@ -965,9 +965,12 @@ class LiveRoomService(
|
|||
)
|
||||
}
|
||||
|
||||
fun getDonationTotal(roomId: 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(
|
||||
totalDonationCan = repository.getDonationTotal(roomId = roomId) ?: 0
|
||||
totalDonationCan = repository.getDonationTotal(roomId = roomId, isLiveCreator = isLiveCreator) ?: 0
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1166,9 +1169,10 @@ class LiveRoomService(
|
|||
}
|
||||
}
|
||||
|
||||
fun getDonationStatus(roomId: Long, member: Member): GetLiveRoomDonationStatusResponse {
|
||||
fun getDonationStatus(roomId: Long, memberId: Long): GetLiveRoomDonationStatusResponse {
|
||||
val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.")
|
||||
val donationList = repository.getDonationList(roomId = room.id!!, cloudFrontHost = cloudFrontHost)
|
||||
val isLiveCreator = room.member!!.id == memberId
|
||||
val donationList = repository.getDonationList(roomId = room.id!!, isLiveCreator = isLiveCreator)
|
||||
val totalCan = donationList.sumOf { it.can }
|
||||
|
||||
return GetLiveRoomDonationStatusResponse(
|
||||
|
|
Loading…
Reference in New Issue