69 lines
1.2 KiB
TypeScript
69 lines
1.2 KiB
TypeScript
import { randomUUID } from 'node:crypto'
|
|
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
|
import { BaseEntity } from '#application/bases/baseEntity'
|
|
import { SpriteAction } from './spriteAction'
|
|
import { UUID } from '#application/types'
|
|
|
|
@Entity()
|
|
export class Sprite extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@Property()
|
|
name!: string
|
|
|
|
@OneToMany(() => SpriteAction, (action) => action.sprite)
|
|
spriteActions = new Collection<SpriteAction>(this)
|
|
|
|
@Property()
|
|
createdAt = new Date()
|
|
|
|
@Property()
|
|
updatedAt = new Date()
|
|
|
|
setId(id: UUID) {
|
|
this.id = id
|
|
return this
|
|
}
|
|
|
|
getId() {
|
|
return this.id
|
|
}
|
|
|
|
setName(name: string) {
|
|
this.name = name
|
|
return this
|
|
}
|
|
|
|
getName() {
|
|
return this.name
|
|
}
|
|
|
|
setSpriteActions(spriteActions: Collection<SpriteAction>) {
|
|
this.spriteActions = spriteActions
|
|
return this
|
|
}
|
|
|
|
getSpriteActions() {
|
|
return this.spriteActions
|
|
}
|
|
|
|
setCreatedAt(createdAt: Date) {
|
|
this.createdAt = createdAt
|
|
return this
|
|
}
|
|
|
|
getCreatedAt() {
|
|
return this.createdAt
|
|
}
|
|
|
|
setUpdatedAt(updatedAt: Date) {
|
|
this.updatedAt = updatedAt
|
|
return this
|
|
}
|
|
|
|
getUpdatedAt() {
|
|
return this.updatedAt
|
|
}
|
|
}
|