import { createCrudRoutes } from '@d8d/shared-crud';
import { Merchant } from '../entities/merchant.entity';
import { MerchantSchema, CreateMerchantDto, UpdateMerchantDto } from '../schemas/merchant.schema';
import { authMiddleware } from '@d8d/auth-module';

// 基础商户路由（完整权限）
export const merchantRoutes = createCrudRoutes({
  entity: Merchant,
  createSchema: CreateMerchantDto,
  updateSchema: UpdateMerchantDto,
  getSchema: MerchantSchema,
  listSchema: MerchantSchema,
  searchFields: ['name', 'username', 'realname', 'phone'],
  middleware: [authMiddleware],
  userTracking: {
    createdByField: 'createdBy',
    updatedByField: 'updatedBy'
  }
});

// 导出所有路由
export { userMerchantRoutes } from './user-routes';
export { adminMerchantRoutes } from './admin-routes';