forked from noxious/server
57 lines
1.0 KiB
TypeScript
57 lines
1.0 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 { Item } from '@/entities/item'
|
|
import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
|
|
|
|
export class BaseCharacterItem extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
character!: Character
|
|
|
|
@ManyToOne({ deleteRule: 'cascade' })
|
|
item!: Item
|
|
|
|
@Property()
|
|
quantity!: number
|
|
|
|
setId(id: UUID) {
|
|
this.id = id
|
|
return this
|
|
}
|
|
|
|
getId() {
|
|
return this.id
|
|
}
|
|
|
|
setCharacter(character: Character) {
|
|
this.character = character
|
|
return this
|
|
}
|
|
|
|
getCharacter() {
|
|
return this.character
|
|
}
|
|
|
|
setItem(item: Item) {
|
|
this.item = item
|
|
return this
|
|
}
|
|
|
|
getItem() {
|
|
return this.item
|
|
}
|
|
|
|
setQuantity(quantity: number) {
|
|
this.quantity = quantity
|
|
return this
|
|
}
|
|
|
|
getQuantity() {
|
|
return this.quantity
|
|
}
|
|
}
|