Compare commits

...

3 Commits

Author SHA1 Message Date
Klaus 0c153aeb6a 크리에이터 내 채널 - 팔로워 리스트
- 알림설정 여부 추가
2024-09-20 01:10:29 +09:00
Klaus 2c4c19990a 라이브 - 후원현황 API
- 방장은 비밀후원 내역도 반영되도록 수정
2024-09-20 01:04:02 +09:00
Klaus dd0b751a43 라이브
- repository 호출 메소드에서 파라미터로 넘기던 cloudFrontHost 제거
2024-09-20 00:56:27 +09:00
5 changed files with 51 additions and 30 deletions

View File

@ -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
)
}

View File

@ -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?
)

View File

@ -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")

View File

@ -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()
}

View File

@ -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(