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())
|
val followerList = queryRepository.getFollowerList(creatorId, pageable.offset, pageable.pageSize.toLong())
|
||||||
.map {
|
.map {
|
||||||
val isFollow = if (it.role == MemberRole.CREATOR) {
|
val creatorFollowing = if (it.role == MemberRole.CREATOR) {
|
||||||
queryRepository.isFollow(creatorId = it.userId, memberId = member.id!!)
|
queryRepository.getCreatorFollowing(
|
||||||
|
creatorId = it.userId,
|
||||||
|
memberId = member.id!!
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
@ -317,7 +320,8 @@ class ExplorerService(
|
||||||
userId = it.userId,
|
userId = it.userId,
|
||||||
profileImage = it.profileImage,
|
profileImage = it.profileImage,
|
||||||
nickname = it.nickname,
|
nickname = it.nickname,
|
||||||
isFollow = isFollow
|
isFollow = creatorFollowing?.isFollow ?: false,
|
||||||
|
isNotify = creatorFollowing?.isNotify ?: false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,6 @@ data class GetFollowerListResponseItem(
|
||||||
val userId: Long,
|
val userId: Long,
|
||||||
val profileImage: String,
|
val profileImage: String,
|
||||||
val nickname: String,
|
val nickname: String,
|
||||||
val isFollow: Boolean?
|
val isFollow: Boolean?,
|
||||||
|
val isNotify: Boolean?
|
||||||
)
|
)
|
||||||
|
|
|
@ -162,7 +162,7 @@ class LiveRoomController(
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
ApiResponse.ok(service.getDonationTotal(roomId))
|
ApiResponse.ok(service.getDonationTotal(roomId, memberId = member.id!!))
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/info/set/speaker")
|
@PutMapping("/info/set/speaker")
|
||||||
|
@ -232,7 +232,7 @@ class LiveRoomController(
|
||||||
) = run {
|
) = run {
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
ApiResponse.ok(service.getDonationStatus(roomId, member))
|
ApiResponse.ok(service.getDonationStatus(roomId, memberId = member.id!!))
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/quit")
|
@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.GetLiveRoomDonationItem
|
||||||
import kr.co.vividnext.sodalive.live.room.donation.QGetLiveRoomDonationItem
|
import kr.co.vividnext.sodalive.live.room.donation.QGetLiveRoomDonationItem
|
||||||
import kr.co.vividnext.sodalive.member.QMember.member
|
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.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
@ -47,13 +48,18 @@ 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, cloudFrontHost: String): GetRecentRoomInfoResponse?
|
fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse?
|
||||||
fun getDonationTotal(roomId: Long): Int?
|
fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int?
|
||||||
fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem>
|
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem>
|
||||||
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
|
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(
|
override fun getLiveRoomListNow(
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long,
|
limit: Long,
|
||||||
|
@ -200,7 +206,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? {
|
override fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
Projections.constructor(
|
Projections.constructor(
|
||||||
|
@ -219,22 +225,33 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L
|
||||||
.fetchFirst()
|
.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
|
return queryFactory
|
||||||
.select(useCanCalculate.can.sum())
|
.select(useCanCalculate.can.sum())
|
||||||
.from(useCanCalculate)
|
.from(useCanCalculate)
|
||||||
.innerJoin(useCanCalculate.useCan, useCan)
|
.innerJoin(useCanCalculate.useCan, useCan)
|
||||||
.innerJoin(useCan.room, liveRoom)
|
.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()
|
.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
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
QGetLiveRoomDonationItem(
|
QGetLiveRoomDonationItem(
|
||||||
|
@ -250,12 +267,7 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L
|
||||||
.from(useCan)
|
.from(useCan)
|
||||||
.join(useCan.member, member)
|
.join(useCan.member, member)
|
||||||
.groupBy(useCan.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())
|
.orderBy(useCan.can.sum().add(useCan.rewardCan.sum()).desc())
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,7 +690,7 @@ class LiveRoomService(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRecentRoomInfo(member: Member): GetRecentRoomInfoResponse {
|
fun getRecentRoomInfo(member: Member): GetRecentRoomInfoResponse {
|
||||||
return repository.getRecentRoomInfo(memberId = member.id!!, cloudFrontHost = cloudFrontHost)
|
return repository.getRecentRoomInfo(memberId = member.id!!)
|
||||||
?: throw SodaException("최근 데이터가 없습니다.")
|
?: 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(
|
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 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 }
|
val totalCan = donationList.sumOf { it.can }
|
||||||
|
|
||||||
return GetLiveRoomDonationStatusResponse(
|
return GetLiveRoomDonationStatusResponse(
|
||||||
|
|
Loading…
Reference in New Issue