feat(chat-character): 캐릭터 상세 조회 응답 스키마 간소화 및 태그 포맷 규칙 적용
- CharacterDetailResponse에서 불필요 필드 제거 - 제거: age, gender, speechPattern, speechStyle, appearance, memories, relationships, values, hobbies, goals - 성격(personalities), 배경(backgrounds)을 각각 첫 번째 항목 1개만 반환하도록 변경 - 단일 객체(Optional)로 응답: CharacterPersonalityResponse?, CharacterBackgroundResponse? - 태그 포맷 규칙 적용 - 태그에 # 프리픽스가 없으면 붙이고, 공백으로 연결하여 단일 문자열로 반환 - Controller 로직 정리 - 불필요 매핑 제거 및 DTO 스키마 변경에 맞춘 변환 로직 반영
This commit is contained in:
		| @@ -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 | ||||
|             ) | ||||
|         ) | ||||
|     } | ||||
|   | ||||
| @@ -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<CharacterMemoryResponse> = emptyList(), | ||||
|     val personalities: List<CharacterPersonalityResponse> = emptyList(), | ||||
|     val backgrounds: List<CharacterBackgroundResponse> = emptyList(), | ||||
|     val relationships: List<CharacterRelationshipResponse> = emptyList(), | ||||
|     val tags: List<String> = emptyList(), | ||||
|     val values: List<String> = emptyList(), | ||||
|     val hobbies: List<String> = emptyList(), | ||||
|     val goals: List<String> = 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 | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user