ff-admin-server/src/entity/unit/inspection/inspectionPlan.ts

61 lines
1.6 KiB
TypeScript

import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { PlanTimeDefinition } from "../../../viewmodel/admin/unit/inspection/inspectionPlan.models";
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
import { equipmentType } from "../equipment/equipmentType";
import { vehicleType } from "../vehicle/vehicleType";
import { wearableType } from "../wearable/wearableType";
@Entity()
export class inspectionPlan {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({ type: "varchar", length: 255 })
title: string;
@Column({ type: "varchar", length: 255 })
inspectionInterval: PlanTimeDefinition;
@Column({ type: "varchar", length: 255 })
remindTime: PlanTimeDefinition;
@CreateDateColumn()
createdAt: Date;
@Column({ nullable: true, default: null })
equipmentTypeId?: string;
@Column({ nullable: true, default: null })
vehicleTypeId?: string;
@Column({ nullable: true, default: null })
wearableTypeId?: string;
@ManyToOne(() => equipmentType, {
nullable: true,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
equipmentType?: equipmentType;
@ManyToOne(() => vehicleType, {
nullable: true,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
vehicleType?: vehicleType;
@ManyToOne(() => wearableType, {
nullable: true,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
wearableType?: wearableType;
@OneToMany(() => inspectionVersionedPlan, (ivp) => ivp.inspectionPlan, {
cascade: ["insert"],
})
versionedPlans: inspectionVersionedPlan[];
latestVersionedPlan?: inspectionVersionedPlan;
}