mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 21:50:57 +00:00
67 lines
3.5 KiB
TypeScript
67 lines
3.5 KiB
TypeScript
import { IsString, IsInt, IsOptional, IsArray, IsBoolean } from 'class-validator';
|
|
import { ApiProperty, ApiPropertyOptional, PartialType, OmitType } from '@nestjs/swagger';
|
|
|
|
export class CreateTrainDto {
|
|
@ApiProperty({ example: '301', description: 'Unique train service number' }) @IsString() number: string;
|
|
@ApiProperty({ example: 'Express 301' }) @IsString() name: string;
|
|
@ApiPropertyOptional({ example: 'EDR', description: 'Operator ID (defaults to op_edr)' }) @IsOptional() @IsString() operatorId?: string;
|
|
@ApiPropertyOptional({ example: 'Ethiopian-Djibouti Railway' }) @IsOptional() @IsString() operatorName?: string;
|
|
@ApiPropertyOptional({ example: 'Addis-Djibouti Express' }) @IsOptional() @IsString() description?: string;
|
|
}
|
|
|
|
export class CreateCoachDto {
|
|
@ApiProperty({ example: 'A-001', description: 'Unique coach number' }) @IsString() number: string;
|
|
@ApiProperty({ example: 'coach-type-uuid', description: 'Coach Type UUID' }) @IsString() coachTypeId: string;
|
|
@ApiProperty({ example: '2+2', description: 'Seat arrangement (e.g., "2+2", "3+2")' }) @IsString() arrangement: string;
|
|
@ApiProperty({ example: 60, description: 'Total seat capacity' }) @IsInt() capacity: number;
|
|
@ApiPropertyOptional({ example: 'ACTIVE', description: 'Status: ACTIVE, INACTIVE' }) @IsOptional() @IsString() status?: string;
|
|
}
|
|
|
|
export class UpdateCoachDto extends PartialType(OmitType(CreateCoachDto, ['number'] as const)) {}
|
|
|
|
export class AssignCoachDto {
|
|
@ApiProperty({ example: 'schedule-uuid', description: 'TrainSchedule UUID' }) @IsString() scheduleId: string;
|
|
@ApiProperty({ example: 'coach-uuid', description: 'Coach UUID' }) @IsString() coachId: string;
|
|
@ApiProperty({ example: 1, description: 'Position in the train consist' }) @IsInt() positionNumber: number;
|
|
@ApiPropertyOptional({ example: true, description: 'Whether this coach is operational' }) @IsOptional() @IsBoolean() isOperational?: boolean;
|
|
}
|
|
|
|
export class ListCoachesDto {
|
|
@ApiPropertyOptional({ example: 'ACTIVE', description: 'Filter by status: ACTIVE, INACTIVE' })
|
|
@IsOptional() @IsString() status?: string;
|
|
|
|
@ApiPropertyOptional({ example: 'schedule-uuid', description: 'Filter coaches assigned to this schedule' })
|
|
@IsOptional() @IsString() scheduleId?: string;
|
|
}
|
|
|
|
// Legacy DTO types for backward compatibility
|
|
export class CreateCoachTypeDto {
|
|
@ApiProperty({ example: 'sleeper' }) @IsString() code: string;
|
|
@ApiProperty({ example: 'Sleeper Coach' }) @IsString() name: string;
|
|
@IsOptional() @IsString() type?: string;
|
|
}
|
|
|
|
export class UpdateCoachTypeDto {
|
|
@ApiPropertyOptional({ example: 'sleeper' }) @IsOptional() @IsString() code?: string;
|
|
@ApiPropertyOptional({ example: 'Sleeper Coach' }) @IsOptional() @IsString() name?: string;
|
|
@ApiPropertyOptional({ example: 'sleeper' }) @IsOptional() @IsString() type?: string;
|
|
}
|
|
|
|
export class CreateClassDto {
|
|
@ApiProperty({ example: 'coach-type-uuid' }) @IsString() coachTypeId: string;
|
|
@ApiProperty({ example: 'Economy' }) @IsString() name: string;
|
|
@IsOptional() @IsString() description?: string;
|
|
@ApiProperty({ example: 5000 }) @IsInt() baseFareMinor: number;
|
|
}
|
|
|
|
export class UpdateClassDto {
|
|
@ApiPropertyOptional({ example: 'coach-type-uuid' }) @IsOptional() @IsString() coachTypeId?: string;
|
|
@ApiPropertyOptional({ example: 'Economy' }) @IsOptional() @IsString() name?: string;
|
|
@ApiPropertyOptional() @IsOptional() @IsString() description?: string;
|
|
@ApiPropertyOptional({ example: 5000 }) @IsOptional() @IsInt() baseFareMinor?: number;
|
|
@ApiPropertyOptional({ example: true })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
}
|