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

53 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-05-24 13:51:38 +02:00
import { Column, ColumnType, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { inspectionPlan } from "./inspectionPlan";
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
import { getTypeByORM } from "../../../migrations/ormHelper";
2025-05-25 07:01:13 +02:00
import { vehicle } from "../vehicle/vehicle";
import { equipment } from "../equipment/equipment";
2025-05-24 13:51:38 +02:00
@Entity()
export class inspection {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({ type: "text" })
context: string;
@CreateDateColumn()
createdAt: Date;
2025-05-26 14:53:25 +02:00
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true, default: null })
2025-05-25 07:01:13 +02:00
finishedAt?: Date;
2025-05-24 13:51:38 +02:00
2025-05-26 14:53:25 +02:00
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true, default: null })
2025-05-24 13:51:38 +02:00
nextInspection?: Date;
2025-05-26 14:53:25 +02:00
@ManyToOne(() => inspectionPlan, {
nullable: false,
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
})
2025-05-24 13:51:38 +02:00
inspectionPlan: inspectionPlan;
2025-05-26 14:53:25 +02:00
@ManyToOne(() => inspectionVersionedPlan, {
nullable: false,
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
})
2025-05-24 13:51:38 +02:00
inspectionVersionedPlan: inspectionVersionedPlan;
2025-05-26 14:53:25 +02:00
@ManyToOne(() => equipment, {
nullable: true,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
2025-05-25 07:01:13 +02:00
equipment: equipment;
2025-05-24 13:51:38 +02:00
2025-05-26 14:53:25 +02:00
@ManyToOne(() => vehicle, {
nullable: true,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
2025-05-25 07:01:13 +02:00
vehicle: vehicle;
2025-05-24 13:51:38 +02:00
}