Compare commits

..

No commits in common. "031fc8ba1b07baf9d8bef90cb094d7f50a3e2b19" and "c6853289ad33fcbba4d7bc4f5c8138932421a30d" have entirely different histories.

20 changed files with 55 additions and 138 deletions

View File

@ -603,7 +603,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
.and(audioContent.member.role.eq(MemberRole.CREATOR))
.and(audioContent.duration.isNotNull)
.and(audioContentTheme.isActive.isTrue)
.and(audioContent.limited.isNull)
if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse)

View File

@ -450,10 +450,8 @@ class AudioContentService(
val creator = explorerQueryRepository.getMember(creatorId)
?: throw SodaException("없는 사용자 입니다.")
val creatorFollowing = explorerQueryRepository.getCreatorFollowing(
creatorId = creatorId,
memberId = member.id!!
)
val notificationUserIds = explorerQueryRepository.getNotificationUserIds(creatorId)
val isFollowing = notificationUserIds.contains(member.id)
// 구매 여부 확인
val isExistsBundleAudioContent = bundleAudioContentList
@ -642,9 +640,7 @@ class AudioContentService(
} else {
"$coverImageHost/profile/default-profile.png"
},
isFollowing = creatorFollowing?.isFollow ?: false,
isFollow = creatorFollowing?.isFollow ?: false,
isNotify = creatorFollowing?.isNotify ?: false
isFollowing = isFollowing
)
)
}

View File

@ -47,7 +47,5 @@ data class AudioContentCreator(
val creatorId: Long,
val nickname: String,
val profileImageUrl: String,
val isFollowing: Boolean,
val isFollow: Boolean,
val isNotify: Boolean
val isFollowing: Boolean
)

View File

@ -61,7 +61,7 @@ class ContentSeriesService(
throw SodaException("잘못된 시리즈 입니다.\n다시 시도해 주세요")
}
val creatorFollowing = explorerQueryRepository.getCreatorFollowing(
val isFollow = explorerQueryRepository.isFollow(
creatorId = series.member!!.id!!,
memberId = member.id!!
)
@ -102,8 +102,7 @@ class ContentSeriesService(
creatorId = series.member!!.id!!,
nickname = series.member!!.nickname,
profileImage = "$coverImageHost/${series.member!!.profileImage}",
isFollow = creatorFollowing?.isFollow ?: false,
isNotify = creatorFollowing?.isNotify ?: false
isFollow = isFollow
),
rentalMinPrice = rentalMinPrice,
rentalMaxPrice = rentalMaxPrice,

View File

@ -27,7 +27,6 @@ data class GetSeriesDetailResponse(
val creatorId: Long,
val nickname: String,
val profileImage: String,
val isFollow: Boolean,
val isNotify: Boolean
val isFollow: Boolean
)
}

View File

@ -10,8 +10,6 @@ data class CreatorResponse(
val youtubeUrl: String? = null,
val websiteUrl: String? = null,
val blogUrl: String? = null,
val isFollow: Boolean,
val isNotify: Boolean,
val isNotification: Boolean,
val notificationRecipientCount: Int
)

View File

@ -46,18 +46,6 @@ class ExplorerQueryRepository(
@Value("\${cloud.aws.cloud-front.host}")
private val cloudFrontHost: String
) {
fun getCreatorFollowing(creatorId: Long, memberId: Long): GetCreatorFollowingResponse? {
return queryFactory
.select(QGetCreatorFollowingResponse(creatorFollowing.isActive, creatorFollowing.isNotify))
.from(creatorFollowing)
.where(
creatorFollowing.isActive.isTrue
.and(creatorFollowing.creator.id.eq(creatorId))
.and(creatorFollowing.member.id.eq(memberId))
)
.fetchFirst()
}
fun getNotificationUserIds(creatorId: Long): List<Long> {
return queryFactory
.select(creatorFollowing.member.id)

View File

@ -145,7 +145,7 @@ class ExplorerService(
if (isBlocked) throw SodaException("${creatorAccount.nickname}님의 요청으로 채널 접근이 제한됩니다.")
val notificationUserIds = queryRepository.getNotificationUserIds(creatorId)
val creatorFollowing = queryRepository.getCreatorFollowing(creatorId = creatorId, memberId = member.id!!)
val isNotification = notificationUserIds.contains(member.id)
val notificationRecipientCount = notificationUserIds.size
// 후원랭킹
@ -223,9 +223,7 @@ class ExplorerService(
youtubeUrl = creatorAccount.youtubeUrl,
websiteUrl = creatorAccount.websiteUrl,
blogUrl = creatorAccount.blogUrl,
isFollow = creatorFollowing?.isFollow ?: false,
isNotify = creatorFollowing?.isNotify ?: false,
isNotification = creatorFollowing?.isFollow ?: false,
isNotification = isNotification,
notificationRecipientCount = notificationRecipientCount
),
userDonationRanking = memberDonationRanking,
@ -307,11 +305,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,16 +315,7 @@ class ExplorerService(
userId = it.userId,
profileImage = it.profileImage,
nickname = it.nickname,
isFollow = creatorFollowing?.isFollow ?: if (it.role == MemberRole.CREATOR) {
false
} else {
null
},
isNotify = creatorFollowing?.isNotify ?: if (it.role == MemberRole.CREATOR) {
false
} else {
null
}
isFollow = isFollow
)
}

View File

@ -1,5 +0,0 @@
package kr.co.vividnext.sodalive.explorer
import com.querydsl.core.annotations.QueryProjection
data class GetCreatorFollowingResponse @QueryProjection constructor(val isFollow: Boolean, val isNotify: Boolean)

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

@ -1,16 +1,13 @@
package kr.co.vividnext.sodalive.live.recommend
import com.querydsl.core.annotations.QueryProjection
data class GetCreatorFollowingAllListResponse(
val totalCount: Int,
val items: List<GetCreatorFollowingAllListItem>
)
data class GetCreatorFollowingAllListItem @QueryProjection constructor(
data class GetCreatorFollowingAllListItem(
val creatorId: Long,
val nickname: String,
val profileImageUrl: String,
val isFollow: Boolean,
val isNotify: Boolean
val isFollow: Boolean
)

View File

@ -239,12 +239,12 @@ class LiveRecommendRepository(
return queryFactory
.select(
QGetCreatorFollowingAllListItem(
Projections.constructor(
GetCreatorFollowingAllListItem::class.java,
member.id,
member.nickname,
member.profileImage.prepend("/").prepend(cloudFrontHost),
Expressions.asBoolean(true),
creatorFollowing.isNotify
Expressions.asBoolean(true)
)
)
.from(creatorFollowing)

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(

View File

@ -142,14 +142,7 @@ class MemberController(private val service: MemberService) {
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(
service.creatorFollow(
creatorId = request.creatorId,
isNotify = request.isNotify ?: true,
isActive = request.isActive ?: true,
memberId = member.id!!
)
)
ApiResponse.ok(service.creatorFollow(creatorId = request.creatorId, memberId = member.id!!))
}
@PostMapping("/creator/unfollow")

View File

@ -146,7 +146,6 @@ class MemberQueryRepositoryImpl(
)
)
.and(creatorFollowing.member.pushToken.isNotNull)
.and(creatorFollowing.isNotify.isTrue)
.or(member.id.eq(4).and(member.pushToken.isNotNull))
if (isAuth) {
@ -191,7 +190,6 @@ class MemberQueryRepositoryImpl(
)
)
.and(creatorFollowing.member.pushToken.isNotNull)
.and(creatorFollowing.isNotify.isTrue)
.or(creatorFollowing.member.id.eq(4).and(member.pushToken.isNotNull))
if (isAuth) {
@ -261,7 +259,6 @@ class MemberQueryRepositoryImpl(
)
)
.and(creatorFollowing.member.pushToken.isNotNull)
.and(creatorFollowing.isNotify.isTrue)
.or(member.id.eq(4).and(member.pushToken.isNotNull))
if (isAuth) {
@ -375,7 +372,6 @@ class MemberQueryRepositoryImpl(
)
)
.and(creatorFollowing.member.pushToken.isNotNull)
.and(creatorFollowing.isNotify.isTrue)
val aosPushTokens = queryFactory
.select(creatorFollowing.member.pushToken)

View File

@ -331,7 +331,7 @@ class MemberService(
}
@Transactional
fun creatorFollow(creatorId: Long, isNotify: Boolean, isActive: Boolean, memberId: Long) {
fun creatorFollow(creatorId: Long, memberId: Long) {
val creatorFollowing = creatorFollowingRepository.findByCreatorIdAndMemberId(
creatorId = creatorId,
memberId = memberId
@ -340,14 +340,9 @@ class MemberService(
if (creatorFollowing == null) {
val creator = repository.findByIdOrNull(creatorId) ?: throw SodaException("크리에이터 정보를 확인해주세요.")
val member = repository.findByIdOrNull(memberId) ?: throw SodaException("로그인 정보를 확인해주세요.")
val newCreatorFollowing = CreatorFollowing()
newCreatorFollowing.member = member
newCreatorFollowing.creator = creator
creatorFollowingRepository.save(newCreatorFollowing)
creatorFollowingRepository.save(CreatorFollowing(creator = creator, member = member))
} else {
creatorFollowing.isNotify = isNotify && isActive
creatorFollowing.isActive = isActive
creatorFollowing.isActive = true
}
}

View File

@ -1,7 +1,3 @@
package kr.co.vividnext.sodalive.member.following
data class CreatorFollowRequest(
val creatorId: Long,
val isNotify: Boolean?,
val isActive: Boolean?
)
data class CreatorFollowRequest(val creatorId: Long)

View File

@ -8,17 +8,16 @@ import javax.persistence.JoinColumn
import javax.persistence.ManyToOne
@Entity
data class CreatorFollowing(
var isNotify: Boolean = true,
var isActive: Boolean = true
) : BaseEntity() {
class CreatorFollowing(
// 유저가 알림받기 한 크리에이터
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "creator_id", nullable = false)
var creator: Member? = null
var creator: Member,
// 크리에이터를 알림받기 한 유저
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
var member: Member? = null
}
var member: Member,
var isActive: Boolean = true
) : BaseEntity()