base unit data
This commit is contained in:
parent
15a511f942
commit
95d1113ff9
7 changed files with 232 additions and 0 deletions
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>;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue