Merge pull request '주문목록 - 크리에이터 닉네임 추가' (#29) from test into main

Reviewed-on: #29
This commit is contained in:
klaus 2023-09-08 16:29:30 +00:00
commit f4618877d4
11 changed files with 47 additions and 34 deletions

View File

@ -67,18 +67,19 @@ class AudioContentCommentService(
val audioContentComment = repository.findByIdOrNull(request.commentId) val audioContentComment = repository.findByIdOrNull(request.commentId)
?: throw SodaException("잘못된 접근 입니다.\n확인 후 다시 시도해 주세요.") ?: throw SodaException("잘못된 접근 입니다.\n확인 후 다시 시도해 주세요.")
if (audioContentComment.audioContent!!.member!!.id!! != member.id!!) { if (audioContentComment.member!!.id!! == member.id!!) {
if (audioContentComment.member == null || audioContentComment.member!!.id!! != member.id!!) {
throw SodaException("잘못된 접근 입니다.\n확인 후 다시 시도해 주세요.")
}
if (request.comment != null) { if (request.comment != null) {
audioContentComment.comment = request.comment audioContentComment.comment = request.comment
} }
} }
if (request.isActive != null) { if (
audioContentComment.isActive = request.isActive audioContentComment.member!!.id!! == member.id!! ||
audioContentComment.audioContent!!.member!!.id!! != member.id!!
) {
if (request.isActive != null) {
audioContentComment.isActive = request.isActive
}
} }
} }

View File

@ -10,6 +10,7 @@ data class GetAudioContentOrderListResponse(
data class GetAudioContentOrderListItem @QueryProjection constructor( data class GetAudioContentOrderListItem @QueryProjection constructor(
val contentId: Long, val contentId: Long,
val coverImageUrl: String, val coverImageUrl: String,
val creatorNickname: String,
val title: String, val title: String,
val themeStr: String, val themeStr: String,
val duration: String?, val duration: String?,

View File

@ -126,6 +126,7 @@ class OrderQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Orde
QGetAudioContentOrderListItem( QGetAudioContentOrderListItem(
audioContent.id, audioContent.id,
audioContent.coverImage.prepend("/").prepend(coverImageHost), audioContent.coverImage.prepend("/").prepend(coverImageHost),
audioContent.member.nickname,
audioContent.title, audioContent.title,
audioContent.theme.theme, audioContent.theme.theme,
audioContent.duration, audioContent.duration,

View File

@ -451,6 +451,7 @@ class ExplorerQueryRepository(
GetCheersResponseItem( GetCheersResponseItem(
cheersId = it.id!!, cheersId = it.id!!,
memberId = it.member!!.id!!,
nickname = it.member!!.nickname, nickname = it.member!!.nickname,
profileUrl = if (it.member!!.profileImage != null) { profileUrl = if (it.member!!.profileImage != null) {
"$cloudFrontHost/${it.member!!.profileImage}" "$cloudFrontHost/${it.member!!.profileImage}"
@ -467,6 +468,7 @@ class ExplorerQueryRepository(
GetCheersResponseItem( GetCheersResponseItem(
cheersId = cheers.id!!, cheersId = cheers.id!!,
memberId = cheers.member!!.id!!,
nickname = cheers.member!!.nickname, nickname = cheers.member!!.nickname,
profileUrl = if (cheers.member!!.profileImage != null) { profileUrl = if (cheers.member!!.profileImage != null) {
"$cloudFrontHost/${cheers.member!!.profileImage}" "$cloudFrontHost/${cheers.member!!.profileImage}"
@ -593,13 +595,10 @@ class ExplorerQueryRepository(
.fetchFirst() .fetchFirst()
} }
fun getCheers(cheersId: Long, memberId: Long): CreatorCheers? { fun getCheers(cheersId: Long): CreatorCheers? {
return queryFactory return queryFactory
.selectFrom(creatorCheers) .selectFrom(creatorCheers)
.where( .where(creatorCheers.id.eq(cheersId))
creatorCheers.id.eq(cheersId)
.and(creatorCheers.member.id.eq(memberId))
)
.fetchFirst() .fetchFirst()
} }

View File

@ -368,10 +368,23 @@ class ExplorerService(
@Transactional @Transactional
fun modifyCheers(request: PutWriteCheersRequest, member: Member) { fun modifyCheers(request: PutWriteCheersRequest, member: Member) {
val cheers = queryRepository.getCheers(request.cheersId, member.id!!) val cheers = queryRepository.getCheers(request.cheersId)
?: throw SodaException("잘못된 요청입니다.") ?: throw SodaException("잘못된 요청입니다.")
cheers.cheers = request.content if (cheers.member!!.id!! == member.id!!) {
if (request.content != null) {
cheers.cheers = request.content
}
}
if (
cheers.creator!!.id!! == member.id!! ||
cheers.member!!.id!! == member.id!!
) {
if (request.isActive != null) {
cheers.isActive = request.isActive
}
}
} }
@Transactional @Transactional

View File

@ -7,6 +7,7 @@ data class GetCheersResponse(
data class GetCheersResponseItem( data class GetCheersResponseItem(
val cheersId: Long, val cheersId: Long,
val memberId: Long,
val nickname: String, val nickname: String,
val profileUrl: String, val profileUrl: String,
val content: String, val content: String,

View File

@ -13,7 +13,7 @@ import javax.persistence.OneToMany
data class CreatorCheers( data class CreatorCheers(
@Column(columnDefinition = "TEXT", nullable = false) @Column(columnDefinition = "TEXT", nullable = false)
var cheers: String, var cheers: String,
val isActive: Boolean = true var isActive: Boolean = true
) : BaseEntity() { ) : BaseEntity() {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id", nullable = true) @JoinColumn(name = "parent_id", nullable = true)

View File

@ -2,5 +2,6 @@ package kr.co.vividnext.sodalive.explorer.profile
data class PutWriteCheersRequest( data class PutWriteCheersRequest(
val cheersId: Long, val cheersId: Long,
val content: String val content: String? = null,
val isActive: Boolean? = null
) )

View File

@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.fcm
import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository
import kr.co.vividnext.sodalive.member.MemberRepository import kr.co.vividnext.sodalive.member.MemberRepository
import org.slf4j.LoggerFactory
import org.springframework.scheduling.annotation.Async import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Component import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Propagation
@ -34,6 +35,8 @@ class FcmSendListener(
private val memberRepository: MemberRepository, private val memberRepository: MemberRepository,
private val contentCommentRepository: AudioContentCommentRepository private val contentCommentRepository: AudioContentCommentRepository
) { ) {
private val logger = LoggerFactory.getLogger(this::class.java)
@Async @Async
@TransactionalEventListener @TransactionalEventListener
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
@ -117,10 +120,12 @@ class FcmSendListener(
if (fcmEvent.container.isNotBlank()) { if (fcmEvent.container.isNotBlank()) {
val pushTokens = memberRepository.getStartLiveRoomNotificationRecipientPushTokens( val pushTokens = memberRepository.getStartLiveRoomNotificationRecipientPushTokens(
creatorId = fcmEvent.creatorId!!, creatorId = fcmEvent.creatorId!!,
roomId = fcmEvent.roomId!!,
isAuth = fcmEvent.isAuth, isAuth = fcmEvent.isAuth,
container = fcmEvent.container container = fcmEvent.container
) )
logger.info("토큰 - $pushTokens")
for (tokens in pushTokens) { for (tokens in pushTokens) {
pushService.send( pushService.send(
tokens = tokens, tokens = tokens,

View File

@ -250,7 +250,7 @@ class LiveRoomService(
message = if (createdRoom.channelName != null) { message = if (createdRoom.channelName != null) {
"라이브를 시작했습니다. - ${createdRoom.title}" "라이브를 시작했습니다. - ${createdRoom.title}"
} else { } else {
"라이브를 개설했습니다. - ${createdRoom.title}" "라이브를 예약했습니다. - ${createdRoom.title}"
}, },
isAuth = createdRoom.isAdult, isAuth = createdRoom.isAdult,
roomId = createdRoom.id, roomId = createdRoom.id,
@ -266,7 +266,7 @@ class LiveRoomService(
message = if (createdRoom.channelName != null) { message = if (createdRoom.channelName != null) {
"라이브를 시작했습니다. - ${createdRoom.title}" "라이브를 시작했습니다. - ${createdRoom.title}"
} else { } else {
"라이브를 개설했습니다. - ${createdRoom.title}" "라이브를 예약했습니다. - ${createdRoom.title}"
}, },
isAuth = createdRoom.isAdult, isAuth = createdRoom.isAdult,
roomId = createdRoom.id, roomId = createdRoom.id,

View File

@ -34,6 +34,7 @@ interface MemberQueryRepository {
fun getStartLiveRoomNotificationRecipientPushTokens( fun getStartLiveRoomNotificationRecipientPushTokens(
creatorId: Long, creatorId: Long,
roomId: Long,
isAuth: Boolean, isAuth: Boolean,
container: String container: String
): List<List<String>> ): List<List<String>>
@ -146,12 +147,10 @@ class MemberQueryRepositoryImpl(
override fun getStartLiveRoomNotificationRecipientPushTokens( override fun getStartLiveRoomNotificationRecipientPushTokens(
creatorId: Long, creatorId: Long,
roomId: Long,
isAuth: Boolean, isAuth: Boolean,
container: String container: String
): List<List<String>> { ): List<List<String>> {
val member = QMember.member
val creator = QMember.member
var where = creatorFollowing.isActive.isTrue var where = creatorFollowing.isActive.isTrue
.and(creatorFollowing.creator.id.eq(creatorId)) .and(creatorFollowing.creator.id.eq(creatorId))
.and(creatorFollowing.member.notification.live.isTrue) .and(creatorFollowing.member.notification.live.isTrue)
@ -165,26 +164,21 @@ class MemberQueryRepositoryImpl(
.and(creatorFollowing.member.pushToken.isNotNull) .and(creatorFollowing.member.pushToken.isNotNull)
if (isAuth) { if (isAuth) {
where = where.and(member.auth.isNotNull) where = where.and(creatorFollowing.member.auth.isNotNull)
} }
val followingMemberPushToken = queryFactory val followingMemberPushToken = queryFactory
.select(creatorFollowing.member.pushToken) .select(creatorFollowing.member.pushToken)
.from(creatorFollowing) .from(creatorFollowing)
.innerJoin(creatorFollowing.creator, creator)
.innerJoin(creatorFollowing.member, member)
.innerJoin(member.notification, memberNotification)
.leftJoin(member.auth, auth)
.where(where) .where(where)
.fetch() .fetch()
.toSet()
.chunked(500)
where = liveReservation.isActive.isTrue where = liveReservation.isActive.isTrue
.and(liveReservation.member.notification.live.isTrue) .and(liveReservation.member.notification.live.isTrue)
.and(liveReservation.member.container.eq(container)) .and(liveReservation.member.container.eq(container))
.and(liveReservation.member.email.notIn("admin@sodalive.net")) .and(liveReservation.member.email.notIn("admin@sodalive.net"))
.and(liveReservation.member.pushToken.isNotNull) .and(liveReservation.member.pushToken.isNotNull)
.and(liveReservation.room.id.eq(roomId))
.and( .and(
liveReservation.member.id.notIn( liveReservation.member.id.notIn(
blockMemberRepository.getBlockedMemberList(creatorId) blockMemberRepository.getBlockedMemberList(creatorId)
@ -192,21 +186,18 @@ class MemberQueryRepositoryImpl(
) )
if (isAuth) { if (isAuth) {
where = where.and(member.auth.isNotNull) where = where.and(liveReservation.member.auth.isNotNull)
} }
val reservationMemberPushToken = queryFactory val reservationMemberPushToken = queryFactory
.select(liveReservation.member.pushToken) .select(liveReservation.member.pushToken)
.from(liveReservation) .from(liveReservation)
.innerJoin(liveReservation.member, member)
.innerJoin(liveReservation.room, liveRoom)
.innerJoin(liveRoom.member, creator)
.where(where) .where(where)
.fetch() .fetch()
return (followingMemberPushToken + reservationMemberPushToken)
.toSet() .toSet()
.chunked(500) .chunked(500)
return followingMemberPushToken + reservationMemberPushToken
} }
override fun getUploadContentNotificationRecipientPushTokens( override fun getUploadContentNotificationRecipientPushTokens(