import { createCrudRoutes } from '@d8d/shared-crud';
import { Merchant } from '../entities/merchant.entity';
import { AdminMerchantSchema, AdminCreateMerchantDto, AdminUpdateMerchantDto } from '../schemas/admin-merchant.schema';
import { authMiddleware } from '@d8d/auth-module';

// 管理员专用商户路由（完整权限）
export const adminMerchantRoutes = createCrudRoutes({
  entity: Merchant,
  createSchema: AdminCreateMerchantDto,
  updateSchema: AdminUpdateMerchantDto,
  getSchema: AdminMerchantSchema,
  listSchema: AdminMerchantSchema,
  searchFields: ['name', 'username', 'realname', 'phone'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  },
  dataPermission: {
    enabled: false, // 管理员路由不使用数据权限控制
    userIdField: 'createdBy' // 即使不启用，也需要提供userIdField
  }
});