import { createCrudRoutes } from '@d8d/shared-crud';
import { DeliveryAddress } from '../entities';
import {
  AdminDeliveryAddressSchema,
  CreateAdminDeliveryAddressDto,
  UpdateAdminDeliveryAddressDto
} from '../schemas/admin-delivery-address.schema';
import { authMiddleware } from '@d8d/auth-module';

// 管理员专用路由 - 完整权限，不使用数据权限控制
const adminDeliveryAddressRoutes = createCrudRoutes({
  entity: DeliveryAddress,
  createSchema: CreateAdminDeliveryAddressDto,
  updateSchema: UpdateAdminDeliveryAddressDto,
  getSchema: AdminDeliveryAddressSchema,
  listSchema: AdminDeliveryAddressSchema,
  searchFields: ['name', 'phone', 'address'],
  relations: ['user', 'province', 'city', 'district', 'town'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
  // 注意：管理员路由不配置 dataPermission，保持完整CRUD功能
});

export default adminDeliveryAddressRoutes;