From 423cbe7315961420814aa933c17667e927884ad3 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 12 Aug 2025 03:16:29 +0900 Subject: [PATCH] =?UTF-8?q?feat(chat-character):=20=EC=BA=90=EB=A6=AD?= =?UTF-8?q?=ED=84=B0=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=8A=A4=ED=82=A4=EB=A7=88=20=EA=B0=84=EC=86=8C?= =?UTF-8?q?=ED=99=94=20=EB=B0=8F=20=ED=83=9C=EA=B7=B8=20=ED=8F=AC=EB=A7=B7?= =?UTF-8?q?=20=EA=B7=9C=EC=B9=99=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CharacterDetailResponse에서 불필요 필드 제거 - 제거: age, gender, speechPattern, speechStyle, appearance, memories, relationships, values, hobbies, goals - 성격(personalities), 배경(backgrounds)을 각각 첫 번째 항목 1개만 반환하도록 변경 - 단일 객체(Optional)로 응답: CharacterPersonalityResponse?, CharacterBackgroundResponse? - 태그 포맷 규칙 적용 - 태그에 # 프리픽스가 없으면 붙이고, 공백으로 연결하여 단일 문자열로 반환 - Controller 로직 정리 - 불필요 매핑 제거 및 DTO 스키마 변경에 맞춘 변환 로직 반영 --- .../controller/ChatCharacterController.kt | 43 +++++-------------- .../character/dto/CharacterDetailResponse.kt | 27 ++---------- 2 files changed, 13 insertions(+), 57 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/controller/ChatCharacterController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/controller/ChatCharacterController.kt index 5503bb8..a0ffc0f 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/controller/ChatCharacterController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/controller/ChatCharacterController.kt @@ -5,9 +5,7 @@ import kr.co.vividnext.sodalive.chat.character.dto.CharacterBackgroundResponse import kr.co.vividnext.sodalive.chat.character.dto.CharacterBannerResponse import kr.co.vividnext.sodalive.chat.character.dto.CharacterDetailResponse import kr.co.vividnext.sodalive.chat.character.dto.CharacterMainResponse -import kr.co.vividnext.sodalive.chat.character.dto.CharacterMemoryResponse import kr.co.vividnext.sodalive.chat.character.dto.CharacterPersonalityResponse -import kr.co.vividnext.sodalive.chat.character.dto.CharacterRelationshipResponse import kr.co.vividnext.sodalive.chat.character.dto.CurationSection import kr.co.vividnext.sodalive.chat.character.dto.RecentCharacter import kr.co.vividnext.sodalive.chat.character.service.ChatCharacterBannerService @@ -109,58 +107,37 @@ class ChatCharacterController( val character = service.getCharacterDetail(characterId) ?: throw SodaException("캐릭터를 찾을 수 없습니다.") - // 태그, 가치관, 취미, 목표 추출 - val tags = character.tagMappings.map { it.tag.tag } - val values = character.valueMappings.map { it.value.value } - val hobbies = character.hobbyMappings.map { it.hobby.hobby } - val goals = character.goalMappings.map { it.goal.goal } + // 태그 가공: # prefix 규칙 적용 후 공백으로 연결 + val tags = character.tagMappings + .map { it.tag.tag } + .joinToString(" ") { if (it.startsWith("#")) it else "#$it" } - // 메모리, 성격, 배경, 관계 변환 - val memories = character.memories.map { - CharacterMemoryResponse( - title = it.title, - content = it.content, - emotion = it.emotion - ) - } - - val personalities = character.personalities.map { + // 성격, 배경: 각각 첫 번째 항목만 선택 + val personality: CharacterPersonalityResponse? = character.personalities.firstOrNull()?.let { CharacterPersonalityResponse( trait = it.trait, description = it.description ) } - val backgrounds = character.backgrounds.map { + val background: CharacterBackgroundResponse? = character.backgrounds.firstOrNull()?.let { CharacterBackgroundResponse( topic = it.topic, description = it.description ) } - val relationships = character.relationships.map { CharacterRelationshipResponse(it.name, it.relationShip) } - // 응답 생성 ApiResponse.ok( CharacterDetailResponse( characterId = character.id!!, name = character.name, description = character.description, - age = character.age, - gender = character.gender, mbti = character.mbti, - speechPattern = character.speechPattern, - speechStyle = character.speechStyle, - appearance = character.appearance, imageUrl = "$imageHost/${character.imagePath ?: "profile/default-profile.png"}", - memories = memories, - personalities = personalities, - backgrounds = backgrounds, - relationships = relationships, - tags = tags, - values = values, - hobbies = hobbies, - goals = goals + personalities = personality, + backgrounds = background, + tags = tags ) ) } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/dto/CharacterDetailResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/dto/CharacterDetailResponse.kt index d093ca3..f8ba56f 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/dto/CharacterDetailResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/chat/character/dto/CharacterDetailResponse.kt @@ -4,27 +4,11 @@ data class CharacterDetailResponse( val characterId: Long, val name: String, val description: String, - val age: Int?, - val gender: String?, val mbti: String?, - val speechPattern: String?, - val speechStyle: String?, - val appearance: String?, val imageUrl: String, - val memories: List = emptyList(), - val personalities: List = emptyList(), - val backgrounds: List = emptyList(), - val relationships: List = emptyList(), - val tags: List = emptyList(), - val values: List = emptyList(), - val hobbies: List = emptyList(), - val goals: List = emptyList() -) - -data class CharacterMemoryResponse( - val title: String, - val content: String, - val emotion: String + val personalities: CharacterPersonalityResponse?, + val backgrounds: CharacterBackgroundResponse?, + val tags: String ) data class CharacterPersonalityResponse( @@ -36,8 +20,3 @@ data class CharacterBackgroundResponse( val topic: String, val description: String ) - -data class CharacterRelationshipResponse( - val name: String, - val relationShip: String -)