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"; @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; @ManyToOne(() => equipmentType, { nullable: true, onDelete: "CASCADE", onUpdate: "RESTRICT", }) equipmentType?: equipmentType; @ManyToOne(() => vehicleType, { nullable: true, onDelete: "CASCADE", onUpdate: "RESTRICT", }) vehicleType?: vehicleType; @OneToMany(() => inspectionVersionedPlan, (ivp) => ivp.inspectionPlan, { cascade: ["insert"], }) versionedPlans: inspectionVersionedPlan[]; latestVersionedPlan?: inspectionVersionedPlan; }