mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 08:48:11 +00:00
trains, wagons,containers and cargoes schema and API
This commit is contained in:
@@ -1,23 +1,58 @@
|
||||
import { BaseEntity } from "@edr/api-common";
|
||||
import { Freight } from "@edr/types";
|
||||
import { Column, Entity } from "typeorm";
|
||||
// apps/edr-freight-api/src/modules/trains/entities/train.entity.ts
|
||||
import { BaseEntity } from '@edr/api-common';
|
||||
import { Freight } from '@edr/types';
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { Wagon } from '../../wagons/entities/wagon.entity';
|
||||
|
||||
@Entity({ schema:"freight",name: "trains" })
|
||||
@Entity({ schema: 'freight', name: 'trains' })
|
||||
export class Train extends BaseEntity {
|
||||
@Column({ name: "code", type: "varchar", length: 32, unique: true })
|
||||
// --- existing fields (keep for backward compatibility) ---
|
||||
@Column({ name: 'code', type: 'varchar', length: 32, unique: true })
|
||||
code!: string;
|
||||
|
||||
@Column({ name: "capacity_tons", type: "numeric", precision: 10, scale: 2 })
|
||||
@Column({ name: 'capacity_tons', type: 'numeric', precision: 10, scale: 2 })
|
||||
capacityTons!: number;
|
||||
|
||||
@Column({
|
||||
name: "status",
|
||||
type: "enum",
|
||||
name: 'status',
|
||||
type: 'enum',
|
||||
enum: Freight.TrainStatus,
|
||||
default: Freight.TrainStatus.Available,
|
||||
})
|
||||
status!: Freight.TrainStatus;
|
||||
|
||||
@Column({ name: "notes", type: "text", nullable: true })
|
||||
@Column({ name: 'notes', type: 'text', nullable: true })
|
||||
notes?: string | null;
|
||||
}
|
||||
|
||||
// --- new required fields ---
|
||||
@Column({ name: 'train_number', type: 'varchar', length: 20, unique: true, nullable: true })
|
||||
trainNumber?: string;
|
||||
|
||||
@Column({ name: 'train_name', type: 'varchar', length: 100, nullable: true })
|
||||
trainName?: string;
|
||||
|
||||
@Column({ name: 'route_id', type: 'uuid', nullable: true })
|
||||
routeId?: string;
|
||||
|
||||
@Column({ name: 'origin_station_id', type: 'uuid', nullable: true })
|
||||
originStationId?: string;
|
||||
|
||||
@Column({ name: 'destination_station_id', type: 'uuid', nullable: true })
|
||||
destinationStationId?: string;
|
||||
|
||||
@Column({ name: 'departure_time', type: 'timestamp', nullable: true })
|
||||
departureTime?: Date;
|
||||
|
||||
@Column({ name: 'arrival_time', type: 'timestamp', nullable: true })
|
||||
arrivalTime?: Date;
|
||||
|
||||
@Column({ name: 'locomotive_number', type: 'varchar', length: 50, nullable: true })
|
||||
locomotiveNumber?: string;
|
||||
|
||||
@Column({ name: 'remarks', type: 'text', nullable: true })
|
||||
remarks?: string;
|
||||
|
||||
// --- relationships ---
|
||||
@OneToMany(() => Wagon, (wagon) => wagon.train)
|
||||
wagons!: Wagon[]; // fixed typo: was 'wagens'
|
||||
}
|
||||
Reference in New Issue
Block a user