캐릭터 챗봇 #338
| @@ -1,5 +1,8 @@ | ||||
| package kr.co.vividnext.sodalive.chat.room.dto | ||||
|  | ||||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||||
| import com.fasterxml.jackson.annotation.JsonProperty | ||||
|  | ||||
| /** | ||||
|  * 채팅방 생성 요청 DTO | ||||
|  */ | ||||
| @@ -46,10 +49,10 @@ data class ChatRoomListQueryDto( | ||||
| /** | ||||
|  * 외부 API 채팅 세션 생성 응답 DTO | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalChatSessionCreateResponse( | ||||
|     val success: Boolean, | ||||
|     val message: String?, | ||||
|     val data: ExternalChatSessionCreateData? | ||||
|     @JsonProperty("success") val success: Boolean, | ||||
|     @JsonProperty("data") val data: ExternalChatSessionCreateData? | ||||
| ) | ||||
|  | ||||
| /** | ||||
| @@ -57,21 +60,22 @@ data class ExternalChatSessionCreateResponse( | ||||
|  * 공통: sessionId, status | ||||
|  * 생성 전용: userId, characterId, character, createdAt | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalChatSessionCreateData( | ||||
|     val sessionId: String, | ||||
|     val userId: String, | ||||
|     val characterId: String, | ||||
|     val character: ExternalCharacterData, | ||||
|     val status: String, | ||||
|     val createdAt: String | ||||
|     @JsonProperty("sessionId") val sessionId: String, | ||||
|     @JsonProperty("userId") val userId: String, | ||||
|     @JsonProperty("character") val character: ExternalCharacterData, | ||||
|     @JsonProperty("status") val status: String, | ||||
|     @JsonProperty("createdAt") val createdAt: String, | ||||
|     @JsonProperty("message") val message: String? | ||||
| ) | ||||
|  | ||||
| /** | ||||
|  * 외부 API 채팅 세션 조회 응답 DTO | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalChatSessionGetResponse( | ||||
|     val success: Boolean, | ||||
|     val message: String?, | ||||
|     val data: ExternalChatSessionGetData? | ||||
| ) | ||||
|  | ||||
| @@ -79,19 +83,23 @@ data class ExternalChatSessionGetResponse( | ||||
|  * 외부 API 채팅 세션 조회 데이터 DTO | ||||
|  * 세션 조회에서 사용하는 공통 필드만 포함 | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalChatSessionGetData( | ||||
|     val sessionId: String, | ||||
|     val status: String | ||||
|     @JsonProperty("sessionId") val sessionId: String, | ||||
|     @JsonProperty("userId") val userId: String, | ||||
|     @JsonProperty("characterId") val characterId: String, | ||||
|     @JsonProperty("status") val status: String | ||||
| ) | ||||
|  | ||||
| /** | ||||
|  * 외부 API 캐릭터 데이터 DTO | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalCharacterData( | ||||
|     val id: String, | ||||
|     val name: String, | ||||
|     val age: String, | ||||
|     val gender: String | ||||
|     @JsonProperty("id") val id: String, | ||||
|     @JsonProperty("name") val name: String, | ||||
|     @JsonProperty("age") val age: String, | ||||
|     @JsonProperty("gender") val gender: String | ||||
| ) | ||||
|  | ||||
| /** | ||||
| @@ -111,26 +119,28 @@ data class SendChatMessageResponse( | ||||
| /** | ||||
|  * 외부 API 채팅 전송 응답 DTO | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalChatSendResponse( | ||||
|     val success: Boolean, | ||||
|     val message: String?, | ||||
|     val data: ExternalChatSendData? | ||||
|     @JsonProperty("success") val success: Boolean, | ||||
|     @JsonProperty("data") val data: ExternalChatSendData? | ||||
| ) | ||||
|  | ||||
| /** | ||||
|  * 외부 API 채팅 전송 데이터 DTO | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalChatSendData( | ||||
|     val sessionId: String, | ||||
|     val characterResponse: ExternalCharacterMessage | ||||
|     @JsonProperty("sessionId") val sessionId: String, | ||||
|     @JsonProperty("characterResponse") val characterResponse: ExternalCharacterMessage | ||||
| ) | ||||
|  | ||||
| /** | ||||
|  * 외부 API 캐릭터 메시지 DTO | ||||
|  */ | ||||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||||
| data class ExternalCharacterMessage( | ||||
|     val id: String, | ||||
|     val content: String, | ||||
|     val timestamp: String, | ||||
|     val messageType: String | ||||
|     @JsonProperty("id") val id: String, | ||||
|     @JsonProperty("content") val content: String, | ||||
|     @JsonProperty("timestamp") val timestamp: String, | ||||
|     @JsonProperty("messageType") val messageType: String | ||||
| ) | ||||
|   | ||||
| @@ -165,21 +165,21 @@ class ChatRoomService( | ||||
|  | ||||
|             // success가 false이면 throw | ||||
|             if (!apiResponse.success) { | ||||
|                 throw SodaException(apiResponse.message ?: "채팅방 생성에 실패했습니다. 다시 시도해 주세요.") | ||||
|                 throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.") | ||||
|             } | ||||
|  | ||||
|             // success가 true이면 파라미터로 넘긴 값과 일치하는지 확인 | ||||
|             val data = apiResponse.data ?: throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.") | ||||
|  | ||||
|             if (data.userId != userId && data.characterId != characterUUID && data.status != "active") { | ||||
|             if (data.userId != userId && data.character.id != characterUUID && data.status != "active") { | ||||
|                 throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.") | ||||
|             } | ||||
|  | ||||
|             // 세션 ID 반환 | ||||
|             return data.sessionId | ||||
|         } catch (e: Exception) { | ||||
|             e.printStackTrace() | ||||
|             throw SodaException("${e.message}, 채팅방 생성에 실패했습니다. 다시 시도해 주세요.") | ||||
|             log.error(e.message) | ||||
|             throw SodaException("채팅방 생성에 실패했습니다. 다시 시도해 주세요.") | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -484,7 +484,7 @@ class ChatRoomService( | ||||
|         ) | ||||
|  | ||||
|         if (!apiResponse.success) { | ||||
|             throw SodaException(apiResponse.message ?: "메시지 전송을 실패했습니다.") | ||||
|             throw SodaException("메시지 전송을 실패했습니다.") | ||||
|         } | ||||
|         val data = apiResponse.data ?: throw SodaException("메시지 전송을 실패했습니다.") | ||||
|         val characterContent = data.characterResponse.content | ||||
|   | ||||
		Reference in New Issue
	
	Block a user