feat(character-comment): 캐릭터 댓글 등록 시 언어 코드를 입력 받을 수 있는 기능 추가

This commit is contained in:
2025-11-25 16:10:20 +09:00
parent da9b89a6cf
commit a2998002e5
4 changed files with 14 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ import javax.persistence.Table
data class CharacterComment( data class CharacterComment(
@Column(columnDefinition = "TEXT", nullable = false) @Column(columnDefinition = "TEXT", nullable = false)
var comment: String, var comment: String,
var languageCode: String?,
var isActive: Boolean = true var isActive: Boolean = true
) : BaseEntity() { ) : BaseEntity() {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)

View File

@@ -47,7 +47,7 @@ class CharacterCommentController(
if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.") if (member.auth == null) throw SodaException("본인인증을 하셔야 합니다.")
if (request.comment.isBlank()) throw SodaException("댓글 내용을 입력해주세요.") if (request.comment.isBlank()) throw SodaException("댓글 내용을 입력해주세요.")
val id = service.addReply(characterId, commentId, member, request.comment) val id = service.addReply(characterId, commentId, member, request.comment, request.languageCode)
ApiResponse.ok(id) ApiResponse.ok(id)
} }

View File

@@ -2,7 +2,8 @@ package kr.co.vividnext.sodalive.chat.character.comment
// Request DTOs // Request DTOs
data class CreateCharacterCommentRequest( data class CreateCharacterCommentRequest(
val comment: String val comment: String,
val languageCode: String? = null
) )
// Response DTOs // Response DTOs

View File

@@ -57,12 +57,12 @@ class CharacterCommentService(
} }
@Transactional @Transactional
fun addComment(characterId: Long, member: Member, text: String): Long { fun addComment(characterId: Long, member: Member, text: String, languageCode: String? = null): Long {
val character = chatCharacterRepository.findById(characterId).orElseThrow { SodaException("캐릭터를 찾을 수 없습니다.") } val character = chatCharacterRepository.findById(characterId).orElseThrow { SodaException("캐릭터를 찾을 수 없습니다.") }
if (!character.isActive) throw SodaException("비활성화된 캐릭터입니다.") if (!character.isActive) throw SodaException("비활성화된 캐릭터입니다.")
if (text.isBlank()) throw SodaException("댓글 내용을 입력해주세요.") if (text.isBlank()) throw SodaException("댓글 내용을 입력해주세요.")
val entity = CharacterComment(comment = text) val entity = CharacterComment(comment = text, languageCode = languageCode)
entity.chatCharacter = character entity.chatCharacter = character
entity.member = member entity.member = member
commentRepository.save(entity) commentRepository.save(entity)
@@ -70,7 +70,13 @@ class CharacterCommentService(
} }
@Transactional @Transactional
fun addReply(characterId: Long, parentCommentId: Long, member: Member, text: String): Long { fun addReply(
characterId: Long,
parentCommentId: Long,
member: Member,
text: String,
languageCode: String? = null
): Long {
val character = chatCharacterRepository.findById(characterId).orElseThrow { SodaException("캐릭터를 찾을 수 없습니다.") } val character = chatCharacterRepository.findById(characterId).orElseThrow { SodaException("캐릭터를 찾을 수 없습니다.") }
if (!character.isActive) throw SodaException("비활성화된 캐릭터입니다.") if (!character.isActive) throw SodaException("비활성화된 캐릭터입니다.")
val parent = commentRepository.findById(parentCommentId).orElseThrow { SodaException("댓글을 찾을 수 없습니다.") } val parent = commentRepository.findById(parentCommentId).orElseThrow { SodaException("댓글을 찾을 수 없습니다.") }
@@ -78,7 +84,7 @@ class CharacterCommentService(
if (!parent.isActive) throw SodaException("비활성화된 댓글입니다.") if (!parent.isActive) throw SodaException("비활성화된 댓글입니다.")
if (text.isBlank()) throw SodaException("댓글 내용을 입력해주세요.") if (text.isBlank()) throw SodaException("댓글 내용을 입력해주세요.")
val entity = CharacterComment(comment = text) val entity = CharacterComment(comment = text, languageCode = languageCode)
entity.chatCharacter = character entity.chatCharacter = character
entity.member = member entity.member = member
entity.parent = parent entity.parent = parent