index.ts 754 B

123456789101112131415161718192021
  1. import { createCrudRoutes } from '@/server/utils/generic-crud.routes';
  2. import { authMiddleware } from '@/server/middleware/auth.middleware';
  3. import { LocationEntity } from '@/server/modules/locations/location.entity';
  4. import {
  5. createLocationSchema,
  6. updateLocationSchema,
  7. getLocationSchema,
  8. locationListResponseSchema
  9. } from '@/server/modules/locations/location.schema';
  10. // 使用通用CRUD路由创建地点管理API
  11. export default createCrudRoutes({
  12. entity: LocationEntity,
  13. createSchema: createLocationSchema,
  14. updateSchema: updateLocationSchema,
  15. getSchema: getLocationSchema,
  16. listSchema: locationListResponseSchema,
  17. searchFields: ['name', 'address'],
  18. relations: ['province', 'city', 'district'],
  19. middleware: [authMiddleware]
  20. });