fix(chat-character): 관계 스키마 변경에 따라 엔티티/CRUD/응답 DTO 수정
- ChatCharacterRelationship 엔티티를 personName, relationshipName, description(TEXT), importance, relationshipType, currentStatus로 변경 - ChatCharacter.addRelationship 및 Service 메서드 시그니처를 새 스키마에 맞게 수정 - 등록/수정 플로우에서 relationships 매핑 로직 업데이트 - Admin 상세 응답 DTO(RelationshipResponse) 및 매핑 업데이트 - 전체 빌드 성공
This commit is contained in:
parent
3ac4ebded3
commit
e6d63592ec
|
@ -133,7 +133,7 @@ class AdminChatCharacterController(
|
||||||
memories = request.memories.map { Triple(it.title, it.content, it.emotion) },
|
memories = request.memories.map { Triple(it.title, it.content, it.emotion) },
|
||||||
personalities = request.personalities.map { Pair(it.trait, it.description) },
|
personalities = request.personalities.map { Pair(it.trait, it.description) },
|
||||||
backgrounds = request.backgrounds.map { Pair(it.topic, 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 설정
|
// 3. 이미지 저장 및 ChatCharacter에 이미지 path 설정
|
||||||
|
|
|
@ -53,7 +53,16 @@ data class ChatCharacterDetailResponse(
|
||||||
hobbies = chatCharacter.hobbyMappings.map { it.hobby.hobby },
|
hobbies = chatCharacter.hobbyMappings.map { it.hobby.hobby },
|
||||||
values = chatCharacter.valueMappings.map { it.value.value },
|
values = chatCharacter.valueMappings.map { it.value.value },
|
||||||
goals = chatCharacter.goalMappings.map { it.goal.goal },
|
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 {
|
personalities = chatCharacter.personalities.map {
|
||||||
PersonalityResponse(it.trait, it.description)
|
PersonalityResponse(it.trait, it.description)
|
||||||
},
|
},
|
||||||
|
@ -85,6 +94,10 @@ data class MemoryResponse(
|
||||||
)
|
)
|
||||||
|
|
||||||
data class RelationshipResponse(
|
data class RelationshipResponse(
|
||||||
val name: String,
|
val personName: String,
|
||||||
val relationShip: 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(
|
data class ChatCharacterRelationshipRequest(
|
||||||
@JsonProperty("name") val name: String,
|
@JsonProperty("personName") val personName: String,
|
||||||
@JsonProperty("relationShip") val relationShip: 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(
|
data class ChatCharacterRegisterRequest(
|
||||||
|
|
|
@ -127,8 +127,23 @@ class ChatCharacter(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 관계 추가 헬퍼 메소드
|
// 관계 추가 헬퍼 메소드
|
||||||
fun addRelationship(name: String, relationShip: String) {
|
fun addRelationship(
|
||||||
val relationship = ChatCharacterRelationship(name, relationShip, this)
|
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)
|
relationships.add(relationship)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package kr.co.vividnext.sodalive.chat.character
|
package kr.co.vividnext.sodalive.chat.character
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
import kr.co.vividnext.sodalive.common.BaseEntity
|
||||||
|
import javax.persistence.Column
|
||||||
import javax.persistence.Entity
|
import javax.persistence.Entity
|
||||||
import javax.persistence.FetchType
|
import javax.persistence.FetchType
|
||||||
import javax.persistence.JoinColumn
|
import javax.persistence.JoinColumn
|
||||||
|
@ -12,8 +13,19 @@ import javax.persistence.ManyToOne
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
class ChatCharacterRelationship(
|
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)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "chat_character_id")
|
@JoinColumn(name = "chat_character_id")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package kr.co.vividnext.sodalive.chat.character.service
|
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.admin.chat.character.dto.ChatCharacterUpdateRequest
|
||||||
import kr.co.vividnext.sodalive.chat.character.CharacterType
|
import kr.co.vividnext.sodalive.chat.character.CharacterType
|
||||||
import kr.co.vividnext.sodalive.chat.character.ChatCharacter
|
import kr.co.vividnext.sodalive.chat.character.ChatCharacter
|
||||||
|
@ -372,8 +373,23 @@ class ChatCharacterService(
|
||||||
* 캐릭터에 관계 추가
|
* 캐릭터에 관계 추가
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
fun addRelationshipToChatCharacter(chatCharacter: ChatCharacter, name: String, relationShip: String) {
|
fun addRelationshipToChatCharacter(
|
||||||
chatCharacter.addRelationship(name, relationShip)
|
chatCharacter: ChatCharacter,
|
||||||
|
personName: String,
|
||||||
|
relationshipName: String,
|
||||||
|
description: String,
|
||||||
|
importance: Int,
|
||||||
|
relationshipType: String,
|
||||||
|
currentStatus: String
|
||||||
|
) {
|
||||||
|
chatCharacter.addRelationship(
|
||||||
|
personName,
|
||||||
|
relationshipName,
|
||||||
|
description,
|
||||||
|
importance,
|
||||||
|
relationshipType,
|
||||||
|
currentStatus
|
||||||
|
)
|
||||||
saveChatCharacter(chatCharacter)
|
saveChatCharacter(chatCharacter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +418,7 @@ class ChatCharacterService(
|
||||||
memories: List<Triple<String, String, String>> = emptyList(),
|
memories: List<Triple<String, String, String>> = emptyList(),
|
||||||
personalities: List<Pair<String, String>> = emptyList(),
|
personalities: List<Pair<String, String>> = emptyList(),
|
||||||
backgrounds: List<Pair<String, String>> = emptyList(),
|
backgrounds: List<Pair<String, String>> = emptyList(),
|
||||||
relationships: List<Pair<String, String>> = emptyList()
|
relationships: List<ChatCharacterRelationshipRequest> = emptyList()
|
||||||
): ChatCharacter {
|
): ChatCharacter {
|
||||||
val chatCharacter = createChatCharacter(
|
val chatCharacter = createChatCharacter(
|
||||||
characterUUID = characterUUID,
|
characterUUID = characterUUID,
|
||||||
|
@ -437,8 +453,15 @@ class ChatCharacterService(
|
||||||
chatCharacter.addBackground(topic, description)
|
chatCharacter.addBackground(topic, description)
|
||||||
}
|
}
|
||||||
|
|
||||||
relationships.forEach { (name, relationShip) ->
|
relationships.forEach { rr ->
|
||||||
chatCharacter.addRelationship(name, relationShip)
|
chatCharacter.addRelationship(
|
||||||
|
rr.personName,
|
||||||
|
rr.relationshipName,
|
||||||
|
rr.description,
|
||||||
|
rr.importance,
|
||||||
|
rr.relationshipType,
|
||||||
|
rr.currentStatus
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return saveChatCharacter(chatCharacter)
|
return saveChatCharacter(chatCharacter)
|
||||||
|
@ -536,8 +559,15 @@ class ChatCharacterService(
|
||||||
|
|
||||||
if (request.relationships != null) {
|
if (request.relationships != null) {
|
||||||
chatCharacter.relationships.clear()
|
chatCharacter.relationships.clear()
|
||||||
request.relationships.forEach { relationship ->
|
request.relationships.forEach { rr ->
|
||||||
chatCharacter.addRelationship(relationship.name, relationship.relationShip)
|
chatCharacter.addRelationship(
|
||||||
|
rr.personName,
|
||||||
|
rr.relationshipName,
|
||||||
|
rr.description,
|
||||||
|
rr.importance,
|
||||||
|
rr.relationshipType,
|
||||||
|
rr.currentStatus
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue