캐릭터 챗봇 #338
| @@ -0,0 +1,22 @@ | |||||||
|  | package kr.co.vividnext.sodalive.chat.room | ||||||
|  |  | ||||||
|  | import kr.co.vividnext.sodalive.common.BaseEntity | ||||||
|  | import javax.persistence.Entity | ||||||
|  | import javax.persistence.FetchType | ||||||
|  | import javax.persistence.JoinColumn | ||||||
|  | import javax.persistence.ManyToOne | ||||||
|  |  | ||||||
|  | @Entity | ||||||
|  | class CharacterChatMessage( | ||||||
|  |     val message: String, | ||||||
|  |  | ||||||
|  |     @ManyToOne(fetch = FetchType.LAZY) | ||||||
|  |     @JoinColumn(name = "chat_room_id", nullable = false) | ||||||
|  |     val chatRoom: CharacterChatRoom, | ||||||
|  |  | ||||||
|  |     @ManyToOne(fetch = FetchType.LAZY) | ||||||
|  |     @JoinColumn(name = "participant_id", nullable = false) | ||||||
|  |     val participant: CharacterChatParticipant, | ||||||
|  |  | ||||||
|  |     val isActive: Boolean = true | ||||||
|  | ) : BaseEntity() | ||||||
| @@ -0,0 +1,40 @@ | |||||||
|  | package kr.co.vividnext.sodalive.chat.room | ||||||
|  |  | ||||||
|  | import kr.co.vividnext.sodalive.chat.character.ChatCharacter | ||||||
|  | import kr.co.vividnext.sodalive.common.BaseEntity | ||||||
|  | import kr.co.vividnext.sodalive.member.Member | ||||||
|  | import javax.persistence.CascadeType | ||||||
|  | import javax.persistence.Entity | ||||||
|  | import javax.persistence.EnumType | ||||||
|  | import javax.persistence.Enumerated | ||||||
|  | import javax.persistence.FetchType | ||||||
|  | import javax.persistence.JoinColumn | ||||||
|  | import javax.persistence.ManyToOne | ||||||
|  | import javax.persistence.OneToMany | ||||||
|  |  | ||||||
|  | @Entity | ||||||
|  | class CharacterChatParticipant( | ||||||
|  |     @ManyToOne(fetch = FetchType.LAZY) | ||||||
|  |     @JoinColumn(name = "chat_room_id", nullable = false) | ||||||
|  |     val chatRoom: CharacterChatRoom, | ||||||
|  |  | ||||||
|  |     @Enumerated(EnumType.STRING) | ||||||
|  |     val participantType: ParticipantType, | ||||||
|  |  | ||||||
|  |     @ManyToOne(fetch = FetchType.LAZY) | ||||||
|  |     @JoinColumn(name = "member_id") | ||||||
|  |     val member: Member? = null, | ||||||
|  |  | ||||||
|  |     @ManyToOne(fetch = FetchType.LAZY) | ||||||
|  |     @JoinColumn(name = "character_id") | ||||||
|  |     val character: ChatCharacter? = null, | ||||||
|  |  | ||||||
|  |     val isActive: Boolean = true | ||||||
|  | ) : BaseEntity() { | ||||||
|  |     @OneToMany(mappedBy = "participant", cascade = [CascadeType.ALL], fetch = FetchType.LAZY) | ||||||
|  |     val messages: MutableList<CharacterChatMessage> = mutableListOf() | ||||||
|  | } | ||||||
|  |  | ||||||
|  | enum class ParticipantType { | ||||||
|  |     USER, CHARACTER | ||||||
|  | } | ||||||
| @@ -0,0 +1,20 @@ | |||||||
|  | package kr.co.vividnext.sodalive.chat.room | ||||||
|  |  | ||||||
|  | import kr.co.vividnext.sodalive.common.BaseEntity | ||||||
|  | import javax.persistence.CascadeType | ||||||
|  | import javax.persistence.Entity | ||||||
|  | import javax.persistence.FetchType | ||||||
|  | import javax.persistence.OneToMany | ||||||
|  |  | ||||||
|  | @Entity | ||||||
|  | class CharacterChatRoom( | ||||||
|  |     val sessionId: String, | ||||||
|  |     val title: String, | ||||||
|  |     val isActive: Boolean = true | ||||||
|  | ) : BaseEntity() { | ||||||
|  |     @OneToMany(mappedBy = "chatRoom", cascade = [CascadeType.ALL], fetch = FetchType.LAZY) | ||||||
|  |     val messages: MutableList<CharacterChatMessage> = mutableListOf() | ||||||
|  |  | ||||||
|  |     @OneToMany(mappedBy = "chatRoom", cascade = [CascadeType.ALL], fetch = FetchType.LAZY) | ||||||
|  |     val participants: MutableList<CharacterChatParticipant> = mutableListOf() | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user