base unit data
This commit is contained in:
parent
15a511f942
commit
95d1113ff9
7 changed files with 232 additions and 0 deletions
49
src/entity/unit/wearable/wearable.ts
Normal file
49
src/entity/unit/wearable/wearable.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { getTypeByORM } from "../../../migrations/ormHelper";
|
||||
import { WearableType } from "./wearableType";
|
||||
import { DamageReport } from "../damageReport";
|
||||
import { member } from "../../club/member/member";
|
||||
|
||||
@Entity()
|
||||
export class Wearable {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, unique: true })
|
||||
code?: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
name: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
location: string;
|
||||
|
||||
@Column({ type: getTypeByORM("datetime").type as ColumnType })
|
||||
commissioned: Date;
|
||||
|
||||
@Column({ type: getTypeByORM("datetime").type as ColumnType, nullable: true })
|
||||
decommissioned?: Date;
|
||||
|
||||
@Column()
|
||||
equipmentTypeId: string;
|
||||
|
||||
@Column()
|
||||
wearerId: string;
|
||||
|
||||
@ManyToOne(() => WearableType, {
|
||||
nullable: false,
|
||||
onDelete: "RESTRICT",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
wearableType: WearableType;
|
||||
|
||||
@ManyToOne(() => member, {
|
||||
nullable: false,
|
||||
onDelete: "SET NULL",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
wearer: member;
|
||||
|
||||
@OneToMany(() => DamageReport, (d) => d.wearable, { cascade: ["insert"] })
|
||||
reports: DamageReport[];
|
||||
}
|
17
src/entity/unit/wearable/wearableType.ts
Normal file
17
src/entity/unit/wearable/wearableType.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { Wearable } from "./wearable";
|
||||
|
||||
@Entity()
|
||||
export class WearableType {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
type: string;
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
description: string;
|
||||
|
||||
@OneToMany(() => Wearable, (e) => e.wearableType, { cascade: ["insert"] })
|
||||
equipment: Wearable[];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue