1
0
forked from noxious/server
2025-02-12 00:50:51 +01:00

69 lines
1.2 KiB
TypeScript

import { randomUUID } from 'node:crypto'
import { BaseEntity } from '@/application/base/baseEntity'
import type { UUID } from '@/application/types'
import type { Character } from '@/entities/character'
import type { Map } from '@/entities/map'
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
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
}
}