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

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