72 lines
1.2 KiB
TypeScript
72 lines
1.2 KiB
TypeScript
import { randomUUID } from 'node:crypto'
|
|
|
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
|
|
|
import type { UUID } from '#application/types'
|
|
import type { Character } from '#entities/character'
|
|
import type { Map } from '#entities/map'
|
|
|
|
import { BaseEntity } from '#application/base/baseEntity'
|
|
|
|
export class BaseChat extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
character!: Character
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
map!: Map
|
|
|
|
@Property()
|
|
message!: string
|
|
|
|
@Property()
|
|
createdAt = new Date()
|
|
|
|
setId(id: UUID) {
|
|
this.id = id
|
|
return this
|
|
}
|
|
|
|
getId() {
|
|
return this.id
|
|
}
|
|
|
|
setCharacter(character: Character) {
|
|
this.character = character
|
|
return this
|
|
}
|
|
|
|
getCharacter() {
|
|
return this.character
|
|
}
|
|
|
|
setMap(map: Map) {
|
|
this.map = map
|
|
return this
|
|
}
|
|
|
|
getMap() {
|
|
return this.map
|
|
}
|
|
|
|
setMessage(message: string) {
|
|
this.message = message
|
|
return this
|
|
}
|
|
|
|
getMessage() {
|
|
return this.message
|
|
}
|
|
|
|
setCreatedAt(createdAt: Date) {
|
|
this.createdAt = createdAt
|
|
return this
|
|
}
|
|
|
|
getCreatedAt() {
|
|
return this.createdAt
|
|
}
|
|
}
|