base unit data
This commit is contained in:
parent
15a511f942
commit
95d1113ff9
7 changed files with 232 additions and 0 deletions
52
src/entity/unit/damageReport.ts
Normal file
52
src/entity/unit/damageReport.ts
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import { Check, Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { Equipment } from "./equipment/equipment";
|
||||||
|
import { Wearable } from "./wearable/wearable";
|
||||||
|
import { Vehicle } from "./vehicle/vehicle";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class DamageReport {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
reported: Date;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
status: string;
|
||||||
|
|
||||||
|
@Column({ type: "boolean", default: false })
|
||||||
|
done: boolean;
|
||||||
|
|
||||||
|
@Column({ type: "text" })
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
equipmentId: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
vehicleId: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
wearableId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Equipment, {
|
||||||
|
nullable: true,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
equipment: Equipment;
|
||||||
|
|
||||||
|
@ManyToOne(() => Vehicle, {
|
||||||
|
nullable: true,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
vehicle: Vehicle;
|
||||||
|
|
||||||
|
@ManyToOne(() => Wearable, {
|
||||||
|
nullable: true,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
wearable: Wearable;
|
||||||
|
}
|
38
src/entity/unit/equipment/equipment.ts
Normal file
38
src/entity/unit/equipment/equipment.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { getTypeByORM } from "../../../migrations/ormHelper";
|
||||||
|
import { EquipmentType } from "./equipmentType";
|
||||||
|
import { DamageReport } from "../damageReport";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class Equipment {
|
||||||
|
@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;
|
||||||
|
|
||||||
|
@ManyToOne(() => EquipmentType, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
equipmentType: EquipmentType;
|
||||||
|
|
||||||
|
@OneToMany(() => DamageReport, (d) => d.equipment, { cascade: ["insert"] })
|
||||||
|
reports: DamageReport[];
|
||||||
|
}
|
19
src/entity/unit/equipment/equipmentType.ts
Normal file
19
src/entity/unit/equipment/equipmentType.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { Equipment } from "./equipment";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class EquipmentType {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
type: string;
|
||||||
|
|
||||||
|
@Column({ type: "text", nullable: true })
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
@OneToMany(() => Equipment, (e) => e.equipmentType, { cascade: ["insert"] })
|
||||||
|
equipment: Equipment[];
|
||||||
|
|
||||||
|
inspectionPlans: Array<any>;
|
||||||
|
}
|
38
src/entity/unit/vehicle/vehicle.ts
Normal file
38
src/entity/unit/vehicle/vehicle.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { getTypeByORM } from "../../../migrations/ormHelper";
|
||||||
|
import { VehicleType } from "./vehicleType";
|
||||||
|
import { DamageReport } from "../damageReport";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class Vehicle {
|
||||||
|
@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()
|
||||||
|
vehicleTypeId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => VehicleType, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
vehicleType: VehicleType;
|
||||||
|
|
||||||
|
@OneToMany(() => DamageReport, (d) => d.vehicle, { cascade: ["insert"] })
|
||||||
|
reports: DamageReport[];
|
||||||
|
}
|
19
src/entity/unit/vehicle/vehicleType.ts
Normal file
19
src/entity/unit/vehicle/vehicleType.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { Vehicle } from "./vehicle";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class VehicleType {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255 })
|
||||||
|
type: string;
|
||||||
|
|
||||||
|
@Column({ type: "text", nullable: true })
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
@OneToMany(() => Vehicle, (e) => e.vehicleType, { cascade: ["insert"] })
|
||||||
|
equipment: Vehicle[];
|
||||||
|
|
||||||
|
inspectionPlans: Array<any>;
|
||||||
|
}
|
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
Reference in a new issue