import { createCrudRoutes } from '../../../utils/generic-crud.routes';
import { authMiddleware } from '../../../middleware/auth.middleware';
import { RouteEntity } from '../../../modules/routes/route.entity';
import { createRouteSchema, updateRouteSchema, getRouteSchema, routeListResponseSchema } from '../../../modules/routes/route.schema';

// 创建路线管理API路由
export const routesRoutes = createCrudRoutes({
  entity: RouteEntity,
  createSchema: createRouteSchema,
  updateSchema: updateRouteSchema,
  getSchema: getRouteSchema,
  listSchema: routeListResponseSchema,
  searchFields: ['name', 'startLocation.name', 'endLocation.name'],
  relations: ['activity', 'startLocation', 'endLocation'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});