feat(character chat room): 채팅방, 채팅메시지, 채팅방 참여자 엔티티 구성
This commit is contained in:
parent
60172ae84d
commit
694d9cd05a
|
@ -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()
|
||||||
|
}
|
Loading…
Reference in New Issue