feat(fantalk): 팬톡 작성 수정 응답을 반환한다

This commit is contained in:
2026-07-09 06:00:35 +09:00
parent ae380e8922
commit b5b682e340
4 changed files with 261 additions and 9 deletions

View File

@@ -31,6 +31,7 @@ import kr.co.vividnext.sodalive.member.Member
import kr.co.vividnext.sodalive.member.MemberRole
import kr.co.vividnext.sodalive.member.MemberService
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
import kr.co.vividnext.sodalive.v2.api.creator.channel.fantalk.dto.CreatorChannelFanTalkResponse
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.ApplicationEventPublisher
import org.springframework.data.domain.Pageable
@@ -579,7 +580,7 @@ class ExplorerService(
}
@Transactional
fun writeCheers(request: PostWriteCheersRequest, member: Member) {
fun writeCheers(request: PostWriteCheersRequest, member: Member): CreatorChannelFanTalkResponse {
val creator = queryRepository.getMember(request.creatorId)
?: throw SodaException(messageKey = "member.validation.user_not_found")
@@ -605,18 +606,20 @@ class ExplorerService(
cheers.parent = parent
}
cheersRepository.save(cheers)
val savedCheers = cheersRepository.save(cheers)
// 언어 코드가 지정되지 않은 경우, 파파고 언어 감지 API를 통해 비동기로 언어를 식별한다.
if (request.languageCode.isNullOrBlank()) {
applicationEventPublisher.publishEvent(
LanguageDetectEvent(
id = cheers.id!!,
id = savedCheers.id!!,
query = request.content,
targetType = LanguageDetectTargetType.CREATOR_CHEERS
)
)
}
return CreatorChannelFanTalkResponse.from(savedCheers, cloudFrontHost)
}
fun getCreatorProfileCheers(
@@ -639,24 +642,29 @@ class ExplorerService(
}
@Transactional
fun modifyCheers(request: PutWriteCheersRequest, member: Member) {
fun modifyCheers(request: PutWriteCheersRequest, member: Member): CreatorChannelFanTalkResponse {
val cheers = queryRepository.getCheers(request.cheersId)
?: throw SodaException(messageKey = "common.error.invalid_request")
val isWriter = cheers.member!!.id!! == member.id!!
val isCreator = cheers.creator!!.id!! == member.id!!
if (cheers.member!!.id!! == member.id!!) {
if (!isWriter && !isCreator) {
throw SodaException(messageKey = "common.error.invalid_request")
}
if (isWriter) {
if (request.content != null) {
cheers.cheers = request.content
}
}
if (
cheers.creator!!.id!! == member.id!! ||
cheers.member!!.id!! == member.id!!
) {
if (isCreator || isWriter) {
if (request.isActive != null) {
cheers.isActive = request.isActive
}
}
return CreatorChannelFanTalkResponse.from(cheers, cloudFrontHost)
}
@Transactional

View File

@@ -1,7 +1,10 @@
package kr.co.vividnext.sodalive.v2.api.creator.channel.fantalk.dto
import com.fasterxml.jackson.annotation.JsonProperty
import kr.co.vividnext.sodalive.explorer.profile.CreatorCheers
import kr.co.vividnext.sodalive.extensions.removeDeletedNicknamePrefix
import kr.co.vividnext.sodalive.extensions.toUtcIso
import kr.co.vividnext.sodalive.v2.common.domain.toCdnUrl
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.domain.CreatorChannelFanTalk
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.domain.CreatorChannelFanTalkReply
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.domain.CreatorChannelFanTalkTab
@@ -48,6 +51,20 @@ data class CreatorChannelFanTalkResponse(
creatorReplies = fanTalk.creatorReplies.map(CreatorChannelFanTalkReplyResponse::from)
)
}
fun from(fanTalk: CreatorCheers, cloudFrontHost: String): CreatorChannelFanTalkResponse {
val writer = fanTalk.member!!
return CreatorChannelFanTalkResponse(
fanTalkId = fanTalk.id!!,
writerId = writer.id!!,
writerNickname = writer.nickname.removeDeletedNicknamePrefix(),
writerProfileImageUrl = writer.profileImage.toCdnUrl(cloudFrontHost)
?: "$cloudFrontHost/profile/default-profile.png",
content = fanTalk.cheers,
createdAtUtc = fanTalk.createdAt!!.toUtcIso(),
creatorReplies = emptyList()
)
}
}
}