factory and restructure view models
This commit is contained in:
parent
fcbfe560c3
commit
117ced38ab
33 changed files with 479 additions and 46 deletions
|
@ -23,33 +23,36 @@ export class damageReport {
|
|||
@Column({ type: "varchar", length: 255 })
|
||||
reportedBy: string;
|
||||
|
||||
@Column({ nullable: true, default: null })
|
||||
equipmentId: string;
|
||||
@Column({ type: "int", default: 0 })
|
||||
imageCount: number;
|
||||
|
||||
@Column({ nullable: true, default: null })
|
||||
vehicleId: string;
|
||||
equipmentId?: string;
|
||||
|
||||
@Column({ nullable: true, default: null })
|
||||
wearableId: string;
|
||||
vehicleId?: string;
|
||||
|
||||
@Column({ nullable: true, default: null })
|
||||
wearableId?: string;
|
||||
|
||||
@ManyToOne(() => equipment, {
|
||||
nullable: true,
|
||||
onDelete: "CASCADE",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
equipment: equipment;
|
||||
equipment?: equipment;
|
||||
|
||||
@ManyToOne(() => vehicle, {
|
||||
nullable: true,
|
||||
onDelete: "CASCADE",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
vehicle: vehicle;
|
||||
vehicle?: vehicle;
|
||||
|
||||
@ManyToOne(() => wearable, {
|
||||
nullable: true,
|
||||
onDelete: "CASCADE",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
wearable: wearable;
|
||||
wearable?: wearable;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ export class inspection {
|
|||
inspectionVersionedPlanId: string;
|
||||
|
||||
@Column()
|
||||
equipmentId: string;
|
||||
equipmentId?: string;
|
||||
|
||||
@Column()
|
||||
vehicleId: string;
|
||||
vehicleId?: string;
|
||||
|
||||
@ManyToOne(() => inspectionPlan, {
|
||||
nullable: false,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { equipment } from "../equipment/equipment";
|
||||
import { vehicle } from "../vehicle/vehicle";
|
||||
import { PlanTimeDefinition } from "../../../viewmodel/admin/unit/inspectionPlan/inspectionPlan.models";
|
||||
import { PlanTimeDefinition } from "../../../viewmodel/admin/unit/inspection/inspectionPlan.models";
|
||||
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
|
||||
|
||||
@Entity()
|
||||
|
@ -22,16 +22,24 @@ export class inspectionPlan {
|
|||
createdAt: Date;
|
||||
|
||||
@Column()
|
||||
equipmentId: string;
|
||||
equipmentId?: string;
|
||||
|
||||
@Column()
|
||||
vehicleId: string;
|
||||
vehicleId?: string;
|
||||
|
||||
@ManyToOne(() => equipment)
|
||||
equipment: equipment;
|
||||
@ManyToOne(() => equipment, {
|
||||
nullable: true,
|
||||
onDelete: "CASCADE",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
equipment?: equipment;
|
||||
|
||||
@ManyToOne(() => vehicle)
|
||||
vehicle: vehicle;
|
||||
@ManyToOne(() => vehicle, {
|
||||
nullable: true,
|
||||
onDelete: "CASCADE",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
vehicle?: vehicle;
|
||||
|
||||
@OneToMany(() => inspectionVersionedPlan, (ivp) => ivp.inspectionPlan, {
|
||||
cascade: ["insert"],
|
||||
|
|
|
@ -28,10 +28,10 @@ export class inspectionPoint {
|
|||
type: InspectionPointEnum;
|
||||
|
||||
@Column({ type: "int", nullable: true, default: null })
|
||||
min: number;
|
||||
min?: number;
|
||||
|
||||
@Column({ type: "int", nullable: true, default: null })
|
||||
max: number;
|
||||
max?: number;
|
||||
|
||||
@Column({ type: "int", default: 0 })
|
||||
sort: number;
|
||||
|
|
|
@ -29,7 +29,7 @@ export class wearable {
|
|||
wearableTypeId: string;
|
||||
|
||||
@Column()
|
||||
wearerId: string;
|
||||
wearerId?: string;
|
||||
|
||||
@ManyToOne(() => wearableType, {
|
||||
nullable: false,
|
||||
|
@ -39,11 +39,11 @@ export class wearable {
|
|||
wearableType: wearableType;
|
||||
|
||||
@ManyToOne(() => member, {
|
||||
nullable: false,
|
||||
nullable: true,
|
||||
onDelete: "SET NULL",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
wearer: member;
|
||||
wearer?: member;
|
||||
|
||||
@OneToMany(() => damageReport, (d) => d.wearable, { cascade: ["insert"] })
|
||||
reports: damageReport[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue