import { createCrudRoutes } from '@d8d/shared-crud';
import { authMiddleware } from '@d8d/auth-module';
import { Supplier } from '../entities/supplier.entity';
import { AdminSupplierSchema, CreateAdminSupplierDto, UpdateAdminSupplierDto } from '../schemas/admin-supplier.schema';

export const adminSupplierRoutes = createCrudRoutes({
  entity: Supplier,
  createSchema: CreateAdminSupplierDto,
  updateSchema: UpdateAdminSupplierDto,
  getSchema: AdminSupplierSchema,
  listSchema: AdminSupplierSchema,
  searchFields: ['name', 'username', 'realname'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
  // 管理员路由不使用数据权限控制，保持完整CRUD功能
});