mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 08:32:54 +00:00
100 lines
2.4 KiB
TypeScript
100 lines
2.4 KiB
TypeScript
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
import {
|
|
IsIn,
|
|
IsInt,
|
|
IsISO8601,
|
|
IsOptional,
|
|
IsString,
|
|
Max,
|
|
MaxLength,
|
|
Min,
|
|
} from 'class-validator';
|
|
|
|
export const BATCH_BOARD_STATUSES = [
|
|
'DRAFT',
|
|
'SCHEDULED',
|
|
'DISPATCHED',
|
|
'ARRIVED',
|
|
'CANCELLED',
|
|
] as const;
|
|
|
|
export const BATCH_BOARD_SORT_FIELDS = [
|
|
'createdAt',
|
|
'scheduledDepartureDate',
|
|
'trainNumber',
|
|
'status',
|
|
] as const;
|
|
export type BatchBoardSortField = (typeof BATCH_BOARD_SORT_FIELDS)[number];
|
|
|
|
/** Filters for the batch monitoring board list (import schedules, all statuses). */
|
|
export class BatchBoardQueryDto {
|
|
@ApiPropertyOptional({ default: 1, minimum: 1 })
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
page?: number;
|
|
|
|
@ApiPropertyOptional({ default: 12, minimum: 1, maximum: 100 })
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(100)
|
|
pageSize?: number;
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
'Comma-separated schedule statuses (DRAFT,SCHEDULED,DISPATCHED,ARRIVED,CANCELLED). Omit for all.',
|
|
example: 'DISPATCHED,ARRIVED',
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
statuses?: string;
|
|
|
|
@ApiPropertyOptional({ enum: ['OPEN', 'FULL', 'CLOSED'] })
|
|
@IsOptional()
|
|
@IsIn(['OPEN', 'FULL', 'CLOSED'])
|
|
bookingWindowStatus?: 'OPEN' | 'FULL' | 'CLOSED';
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
'Case-insensitive match on train number, route yards, stations, or locomotive code.',
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(120)
|
|
search?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Departure date lower bound (ISO 8601).' })
|
|
@IsOptional()
|
|
@IsISO8601()
|
|
departureFrom?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Departure date upper bound (ISO 8601).' })
|
|
@IsOptional()
|
|
@IsISO8601()
|
|
departureTo?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Created-at lower bound (ISO 8601).' })
|
|
@IsOptional()
|
|
@IsISO8601()
|
|
createdFrom?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Created-at upper bound (ISO 8601).' })
|
|
@IsOptional()
|
|
@IsISO8601()
|
|
createdTo?: string;
|
|
|
|
@ApiPropertyOptional({ enum: BATCH_BOARD_SORT_FIELDS, default: 'createdAt' })
|
|
@IsOptional()
|
|
@IsIn(BATCH_BOARD_SORT_FIELDS as unknown as string[])
|
|
sortBy?: BatchBoardSortField;
|
|
|
|
@ApiPropertyOptional({ enum: ['ASC', 'DESC'], default: 'DESC' })
|
|
@IsOptional()
|
|
@IsIn(['ASC', 'DESC'])
|
|
sortOrder?: 'ASC' | 'DESC';
|
|
}
|