import { createCrudRoutes } from '../../../utils/generic-crud.routes';
import { Passenger } from '../../../modules/passengers/passenger.entity';
import {
  PassengerCreateSchema,
  PassengerUpdateSchema,
  PassengerResponseSchema
} from '../../../modules/passengers/passenger.schema';
import { authMiddleware } from '../../../middleware/auth.middleware';

// 创建乘客管理API路由
// 管理后台API路径：/api/v1/admin/passengers
export const passengersRoutes = createCrudRoutes({
  entity: Passenger,
  createSchema: PassengerCreateSchema,
  updateSchema: PassengerUpdateSchema,
  getSchema: PassengerResponseSchema,
  listSchema: PassengerResponseSchema,
  searchFields: ['name', 'phone', 'idNumber'],
  relations: ['user'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});