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

43 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-05-24 11:31:15 +02:00
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { getTypeByORM } from "../../../migrations/ormHelper";
2025-05-25 07:01:13 +02:00
import { vehicleType } from "./vehicleType";
import { damageReport } from "../damageReport";
2025-05-28 17:06:45 +02:00
import { inspection } from "../inspection/inspection";
2025-05-24 11:31:15 +02:00
@Entity()
2025-05-25 07:01:13 +02:00
export class vehicle {
2025-05-24 11:31:15 +02:00
@PrimaryGeneratedColumn("uuid")
id: string;
2025-05-26 14:53:25 +02:00
@Column({ type: "varchar", length: 255, nullable: true, default: null, unique: true })
2025-05-24 11:31:15 +02:00
code?: string;
@Column({ type: "varchar", length: 255 })
name: string;
@Column({ type: "varchar", length: 255 })
location: string;
@Column({ type: getTypeByORM("date").type as ColumnType })
2025-05-24 11:31:15 +02:00
commissioned: Date;
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true, default: null })
2025-05-24 11:31:15 +02:00
decommissioned?: Date;
@Column()
vehicleTypeId: string;
2025-05-25 07:01:13 +02:00
@ManyToOne(() => vehicleType, {
2025-05-24 11:31:15 +02:00
nullable: false,
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
})
2025-05-25 07:01:13 +02:00
vehicleType: vehicleType;
2025-05-24 11:31:15 +02:00
2025-05-25 07:01:13 +02:00
@OneToMany(() => damageReport, (d) => d.vehicle, { cascade: ["insert"] })
reports: damageReport[];
2025-05-28 17:06:45 +02:00
@OneToMany(() => inspection, (i) => i.vehicle)
inspections: inspection[];
2025-05-24 11:31:15 +02:00
}