mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-06 04:13:37 +00:00
- Added DTOs for creating, querying, and updating train crew members. - Created entity for train crew members with relevant fields and enums for role, nationality, and status. - Developed service for handling CRUD operations and ensuring no duplicate crew members. - Implemented controller to manage API endpoints for train crew operations. - Integrated permissions for viewing, creating, updating, and deleting train crew members. - Added frontend components for displaying, adding, editing, and deleting train crew members. - Established API service for interacting with the train crew backend. - Updated routing and sidebar to include train crew management section.
64 lines
1.3 KiB
TypeScript
64 lines
1.3 KiB
TypeScript
import { Transform, Type } from 'class-transformer';
|
|
import { IsBoolean, IsEnum, IsIn, IsInt, IsOptional, IsString, Max, Min } from 'class-validator';
|
|
import {
|
|
TrainCrewNationality,
|
|
TrainCrewRole,
|
|
TrainCrewStatus,
|
|
} from '../entities/train-crew-member.entity';
|
|
|
|
/** Sortable columns. Whitelisted: the value is interpolated into ORDER BY. */
|
|
export const TRAIN_CREW_SORT_FIELDS = [
|
|
'firstName',
|
|
'lastName',
|
|
'role',
|
|
'nationality',
|
|
'status',
|
|
'createdAt',
|
|
'updatedAt',
|
|
] as const;
|
|
|
|
export class QueryTrainCrewMemberDto {
|
|
/** Matched against first and last name. */
|
|
@IsOptional()
|
|
@IsString()
|
|
search?: string;
|
|
|
|
@IsOptional()
|
|
@IsEnum(TrainCrewRole)
|
|
role?: TrainCrewRole;
|
|
|
|
@IsOptional()
|
|
@IsEnum(TrainCrewNationality)
|
|
nationality?: TrainCrewNationality;
|
|
|
|
@IsOptional()
|
|
@IsEnum(TrainCrewStatus)
|
|
status?: TrainCrewStatus;
|
|
|
|
@IsOptional()
|
|
@Transform(({ value }) => (value === 'true' ? true : value === 'false' ? false : value))
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
page?: number;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(200)
|
|
limit?: number;
|
|
|
|
@IsOptional()
|
|
@IsIn(TRAIN_CREW_SORT_FIELDS as unknown as string[])
|
|
sortBy?: (typeof TRAIN_CREW_SORT_FIELDS)[number];
|
|
|
|
@IsOptional()
|
|
@IsIn(['ASC', 'DESC'])
|
|
sortOrder?: 'ASC' | 'DESC';
|
|
}
|