캐릭터 챗봇 #338
| @@ -133,7 +133,7 @@ class AdminChatCharacterController( | ||||
|             memories = request.memories.map { Triple(it.title, it.content, it.emotion) }, | ||||
|             personalities = request.personalities.map { Pair(it.trait, it.description) }, | ||||
|             backgrounds = request.backgrounds.map { Pair(it.topic, it.description) }, | ||||
|             relationships = request.relationships.map { it.name to it.relationShip } | ||||
|             relationships = request.relationships | ||||
|         ) | ||||
|  | ||||
|         // 3. 이미지 저장 및 ChatCharacter에 이미지 path 설정 | ||||
|   | ||||
| @@ -53,7 +53,16 @@ data class ChatCharacterDetailResponse( | ||||
|                 hobbies = chatCharacter.hobbyMappings.map { it.hobby.hobby }, | ||||
|                 values = chatCharacter.valueMappings.map { it.value.value }, | ||||
|                 goals = chatCharacter.goalMappings.map { it.goal.goal }, | ||||
|                 relationships = chatCharacter.relationships.map { RelationshipResponse(it.name, it.relationShip) }, | ||||
|                 relationships = chatCharacter.relationships.map { | ||||
|                     RelationshipResponse( | ||||
|                         personName = it.personName, | ||||
|                         relationshipName = it.relationshipName, | ||||
|                         description = it.description, | ||||
|                         importance = it.importance, | ||||
|                         relationshipType = it.relationshipType, | ||||
|                         currentStatus = it.currentStatus | ||||
|                     ) | ||||
|                 }, | ||||
|                 personalities = chatCharacter.personalities.map { | ||||
|                     PersonalityResponse(it.trait, it.description) | ||||
|                 }, | ||||
| @@ -85,6 +94,10 @@ data class MemoryResponse( | ||||
| ) | ||||
|  | ||||
| data class RelationshipResponse( | ||||
|     val name: String, | ||||
|     val relationShip: String | ||||
|     val personName: String, | ||||
|     val relationshipName: String, | ||||
|     val description: String, | ||||
|     val importance: Int, | ||||
|     val relationshipType: String, | ||||
|     val currentStatus: String | ||||
| ) | ||||
|   | ||||
| @@ -20,8 +20,12 @@ data class ChatCharacterMemoryRequest( | ||||
| ) | ||||
|  | ||||
| data class ChatCharacterRelationshipRequest( | ||||
|     @JsonProperty("name") val name: String, | ||||
|     @JsonProperty("relationShip") val relationShip: String | ||||
|     @JsonProperty("personName") val personName: String, | ||||
|     @JsonProperty("relationshipName") val relationshipName: String, | ||||
|     @JsonProperty("description") val description: String, | ||||
|     @JsonProperty("importance") val importance: Int, | ||||
|     @JsonProperty("relationshipType") val relationshipType: String, | ||||
|     @JsonProperty("currentStatus") val currentStatus: String | ||||
| ) | ||||
|  | ||||
| data class ChatCharacterRegisterRequest( | ||||
|   | ||||
| @@ -127,8 +127,23 @@ class ChatCharacter( | ||||
|     } | ||||
|  | ||||
|     // 관계 추가 헬퍼 메소드 | ||||
|     fun addRelationship(name: String, relationShip: String) { | ||||
|         val relationship = ChatCharacterRelationship(name, relationShip, this) | ||||
|     fun addRelationship( | ||||
|         personName: String, | ||||
|         relationshipName: String, | ||||
|         description: String, | ||||
|         importance: Int, | ||||
|         relationshipType: String, | ||||
|         currentStatus: String | ||||
|     ) { | ||||
|         val relationship = ChatCharacterRelationship( | ||||
|             personName, | ||||
|             relationshipName, | ||||
|             description, | ||||
|             importance, | ||||
|             relationshipType, | ||||
|             currentStatus, | ||||
|             this | ||||
|         ) | ||||
|         relationships.add(relationship) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package kr.co.vividnext.sodalive.chat.character | ||||
|  | ||||
| import kr.co.vividnext.sodalive.common.BaseEntity | ||||
| import javax.persistence.Column | ||||
| import javax.persistence.Entity | ||||
| import javax.persistence.FetchType | ||||
| import javax.persistence.JoinColumn | ||||
| @@ -12,8 +13,19 @@ import javax.persistence.ManyToOne | ||||
|  | ||||
| @Entity | ||||
| class ChatCharacterRelationship( | ||||
|     var name: String, | ||||
|     val relationShip: String, | ||||
|     // 상대 인물 이름 | ||||
|     var personName: String, | ||||
|     // 관계명 (예: 친구, 동료 등) | ||||
|     var relationshipName: String, | ||||
|     // 관계 설명 | ||||
|     @Column(columnDefinition = "TEXT") | ||||
|     var description: String, | ||||
|     // 중요도 | ||||
|     var importance: Int, | ||||
|     // 관계 타입 (분류용) | ||||
|     var relationshipType: String, | ||||
|     // 현재 상태 | ||||
|     var currentStatus: String, | ||||
|  | ||||
|     @ManyToOne(fetch = FetchType.LAZY) | ||||
|     @JoinColumn(name = "chat_character_id") | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| package kr.co.vividnext.sodalive.chat.character.service | ||||
|  | ||||
| import kr.co.vividnext.sodalive.admin.chat.character.dto.ChatCharacterRelationshipRequest | ||||
| import kr.co.vividnext.sodalive.admin.chat.character.dto.ChatCharacterUpdateRequest | ||||
| import kr.co.vividnext.sodalive.chat.character.CharacterType | ||||
| import kr.co.vividnext.sodalive.chat.character.ChatCharacter | ||||
| @@ -372,8 +373,23 @@ class ChatCharacterService( | ||||
|      * 캐릭터에 관계 추가 | ||||
|      */ | ||||
|     @Transactional | ||||
|     fun addRelationshipToChatCharacter(chatCharacter: ChatCharacter, name: String, relationShip: String) { | ||||
|         chatCharacter.addRelationship(name, relationShip) | ||||
|     fun addRelationshipToChatCharacter( | ||||
|         chatCharacter: ChatCharacter, | ||||
|         personName: String, | ||||
|         relationshipName: String, | ||||
|         description: String, | ||||
|         importance: Int, | ||||
|         relationshipType: String, | ||||
|         currentStatus: String | ||||
|     ) { | ||||
|         chatCharacter.addRelationship( | ||||
|             personName, | ||||
|             relationshipName, | ||||
|             description, | ||||
|             importance, | ||||
|             relationshipType, | ||||
|             currentStatus | ||||
|         ) | ||||
|         saveChatCharacter(chatCharacter) | ||||
|     } | ||||
|  | ||||
| @@ -402,7 +418,7 @@ class ChatCharacterService( | ||||
|         memories: List<Triple<String, String, String>> = emptyList(), | ||||
|         personalities: List<Pair<String, String>> = emptyList(), | ||||
|         backgrounds: List<Pair<String, String>> = emptyList(), | ||||
|         relationships: List<Pair<String, String>> = emptyList() | ||||
|         relationships: List<ChatCharacterRelationshipRequest> = emptyList() | ||||
|     ): ChatCharacter { | ||||
|         val chatCharacter = createChatCharacter( | ||||
|             characterUUID = characterUUID, | ||||
| @@ -437,8 +453,15 @@ class ChatCharacterService( | ||||
|             chatCharacter.addBackground(topic, description) | ||||
|         } | ||||
|  | ||||
|         relationships.forEach { (name, relationShip) -> | ||||
|             chatCharacter.addRelationship(name, relationShip) | ||||
|         relationships.forEach { rr -> | ||||
|             chatCharacter.addRelationship( | ||||
|                 rr.personName, | ||||
|                 rr.relationshipName, | ||||
|                 rr.description, | ||||
|                 rr.importance, | ||||
|                 rr.relationshipType, | ||||
|                 rr.currentStatus | ||||
|             ) | ||||
|         } | ||||
|  | ||||
|         return saveChatCharacter(chatCharacter) | ||||
| @@ -536,8 +559,15 @@ class ChatCharacterService( | ||||
|  | ||||
|         if (request.relationships != null) { | ||||
|             chatCharacter.relationships.clear() | ||||
|             request.relationships.forEach { relationship -> | ||||
|                 chatCharacter.addRelationship(relationship.name, relationship.relationShip) | ||||
|             request.relationships.forEach { rr -> | ||||
|                 chatCharacter.addRelationship( | ||||
|                     rr.personName, | ||||
|                     rr.relationshipName, | ||||
|                     rr.description, | ||||
|                     rr.importance, | ||||
|                     rr.relationshipType, | ||||
|                     rr.currentStatus | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user