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.member.role.eq(MemberRole.CREATOR))
.and(audioContent.duration.isNotNull) .and(audioContent.duration.isNotNull)
.and(audioContentTheme.isActive.isTrue) .and(audioContentTheme.isActive.isTrue)
.and(audioContent.limited.isNull)
if (!isAdult) { if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse) where = where.and(audioContent.isAdult.isFalse)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,18 +46,6 @@ class ExplorerQueryRepository(
@Value("\${cloud.aws.cloud-front.host}") @Value("\${cloud.aws.cloud-front.host}")
private val cloudFrontHost: String 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> { fun getNotificationUserIds(creatorId: Long): List<Long> {
return queryFactory return queryFactory
.select(creatorFollowing.member.id) .select(creatorFollowing.member.id)

View File

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

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 userId: Long,
val profileImage: String, val profileImage: String,
val nickname: String, val nickname: String,
val isFollow: Boolean?, val isFollow: Boolean?
val isNotify: Boolean?
) )

View File

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

View File

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

View File

@ -162,7 +162,7 @@ class LiveRoomController(
) = run { ) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.") if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(service.getDonationTotal(roomId, memberId = member.id!!)) ApiResponse.ok(service.getDonationTotal(roomId))
} }
@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, memberId = member.id!!)) ApiResponse.ok(service.getDonationStatus(roomId, member))
} }
@PostMapping("/quit") @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.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
@ -48,18 +47,13 @@ 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): GetRecentRoomInfoResponse? fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse?
fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int? fun getDonationTotal(roomId: Long): Int?
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem>
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom> fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
} }
class LiveRoomQueryRepositoryImpl( class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository {
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,
@ -206,7 +200,7 @@ class LiveRoomQueryRepositoryImpl(
.fetchFirst() .fetchFirst()
} }
override fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? { override fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse? {
return queryFactory return queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
@ -225,33 +219,22 @@ class LiveRoomQueryRepositoryImpl(
.fetchFirst() .fetchFirst()
} }
override fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int? { override fun getDonationTotal(roomId: Long): 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, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> { override fun getDonationList(roomId: Long, cloudFrontHost: String): 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(
@ -267,7 +250,12 @@ class LiveRoomQueryRepositoryImpl(
.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()
} }

View File

@ -690,7 +690,7 @@ class LiveRoomService(
} }
fun getRecentRoomInfo(member: Member): GetRecentRoomInfoResponse { fun getRecentRoomInfo(member: Member): GetRecentRoomInfoResponse {
return repository.getRecentRoomInfo(memberId = member.id!!) return repository.getRecentRoomInfo(memberId = member.id!!, cloudFrontHost = cloudFrontHost)
?: throw SodaException("최근 데이터가 없습니다.") ?: throw SodaException("최근 데이터가 없습니다.")
} }
@ -965,12 +965,9 @@ class LiveRoomService(
) )
} }
fun getDonationTotal(roomId: Long, memberId: Long): GetLiveRoomDonationTotalResponse { fun getDonationTotal(roomId: 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, 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 room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.")
val isLiveCreator = room.member!!.id == memberId val donationList = repository.getDonationList(roomId = room.id!!, cloudFrontHost = cloudFrontHost)
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(

View File

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

View File

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

View File

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

View File

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

View File

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