feat(chat-character): 관계 name 필드 추가에 따른 등록/수정/조회 로직 및 DTO 반영

- 관계 스키마를 name, relationShip 구조로 일원화
- Admin/사용자 컨트롤러 조회 응답에서 관계를 객체로 반환하도록 수정
- 등록/수정 요청 DTO에 ChatCharacterRelationshipRequest(name, relationShip) 추가
- 서비스 계층 create/update/add 메소드 시그니처 및 매핑 로직 업데이트
- description 한 줄 소개 사용 전제 하의 관련 사용부 점검(엔티티 컬럼 구성은 기존 유지)
This commit is contained in:
2025-08-12 02:13:46 +09:00
parent c525ec0330
commit 2dc5a29220
8 changed files with 33 additions and 17 deletions

View File

@@ -14,8 +14,7 @@ class ChatCharacter(
// 캐릭터 이름 (API 키 내에서 유일해야 함)
var name: String,
// 캐릭터 설명
@Column(columnDefinition = "TEXT", nullable = false)
// 캐릭터 한 줄 소개
var description: String,
// AI 시스템 프롬프트
@@ -113,8 +112,8 @@ class ChatCharacter(
}
// 관계 추가 헬퍼 메소드
fun addRelationship(relationShip: String) {
val relationship = ChatCharacterRelationship(relationShip, this)
fun addRelationship(name: String, relationShip: String) {
val relationship = ChatCharacterRelationship(name, relationShip, this)
relationships.add(relationship)
}
}

View File

@@ -12,6 +12,7 @@ import javax.persistence.ManyToOne
@Entity
class ChatCharacterRelationship(
var name: String,
val relationShip: String,
@ManyToOne(fetch = FetchType.LAZY)

View File

@@ -7,6 +7,7 @@ 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
@@ -137,7 +138,7 @@ class ChatCharacterController(
)
}
val relationships = character.relationships.map { it.relationShip }
val relationships = character.relationships.map { CharacterRelationshipResponse(it.name, it.relationShip) }
// 응답 생성
ApiResponse.ok(

View File

@@ -14,7 +14,7 @@ data class CharacterDetailResponse(
val memories: List<CharacterMemoryResponse> = emptyList(),
val personalities: List<CharacterPersonalityResponse> = emptyList(),
val backgrounds: List<CharacterBackgroundResponse> = emptyList(),
val relationships: List<String> = emptyList(),
val relationships: List<CharacterRelationshipResponse> = emptyList(),
val tags: List<String> = emptyList(),
val values: List<String> = emptyList(),
val hobbies: List<String> = emptyList(),
@@ -36,3 +36,8 @@ data class CharacterBackgroundResponse(
val topic: String,
val description: String
)
data class CharacterRelationshipResponse(
val name: String,
val relationShip: String
)

View File

@@ -266,8 +266,8 @@ class ChatCharacterService(
* 캐릭터에 관계 추가
*/
@Transactional
fun addRelationshipToChatCharacter(chatCharacter: ChatCharacter, relationShip: String) {
chatCharacter.addRelationship(relationShip)
fun addRelationshipToChatCharacter(chatCharacter: ChatCharacter, name: String, relationShip: String) {
chatCharacter.addRelationship(name, relationShip)
saveChatCharacter(chatCharacter)
}
@@ -293,7 +293,7 @@ class ChatCharacterService(
memories: List<Triple<String, String, String>> = emptyList(),
personalities: List<Pair<String, String>> = emptyList(),
backgrounds: List<Pair<String, String>> = emptyList(),
relationships: List<String> = emptyList()
relationships: List<Pair<String, String>> = emptyList()
): ChatCharacter {
val chatCharacter = createChatCharacter(
characterUUID, name, description, systemPrompt, age, gender, mbti,
@@ -313,8 +313,8 @@ class ChatCharacterService(
chatCharacter.addBackground(topic, description)
}
relationships.forEach { relationShip ->
chatCharacter.addRelationship(relationShip)
relationships.forEach { (name, relationShip) ->
chatCharacter.addRelationship(name, relationShip)
}
return saveChatCharacter(chatCharacter)
@@ -412,7 +412,7 @@ class ChatCharacterService(
if (request.relationships != null) {
chatCharacter.relationships.clear()
request.relationships.forEach { relationship ->
chatCharacter.addRelationship(relationship)
chatCharacter.addRelationship(relationship.name, relationship.relationShip)
}
}