import { Router } from 'express';
import { requirePermission } from '../../core/guards/rbac.guard';
import { requireTraceContext } from '../../core/guards/trace-context.guard';
import { TelemetryController } from '../controllers/TelemetryController';

const router = Router();

/**
 * [CORE_LOG_03] 语义日志搜索与聚类
 */
router.get('/semantic/search', requireTraceContext, requirePermission('audit:read'), TelemetryController.searchSemanticLogs);
router.get('/semantic/clusters', requireTraceContext, requirePermission('audit:read'), TelemetryController.clusterAnomalyPatterns);

/**
 * [CORE_TELE_10] & [CORE_TELE_PREDICTIVE_HEALTH] 系统诊断与健康预测
 */
router.get('/diagnostics/run', requireTraceContext, requirePermission('admin:all'), TelemetryController.runDiagnostics);
router.get('/health/prediction', requireTraceContext, requirePermission('admin:all'), TelemetryController.getHealthPrediction);
router.get('/topology', requireTraceContext, requirePermission('admin:all'), TelemetryController.getNetworkTopology);

/**
 * [V31.3] 影子测试
 */
router.get('/audit/shadow', requireTraceContext, requirePermission('admin:all'), TelemetryController.runShadowAudit);

/**
 * [CORE_TELE_08] 成本审计
 */
router.get('/cost/bill/:tenantId', requireTraceContext, requirePermission('finance:read'), TelemetryController.getApiBill);

/**
 * [UX_REVIEW_01] 批量建议批复
 */
router.post('/suggestions/batch-approve', requireTraceContext, requirePermission('trade:write'), TelemetryController.batchApproveSuggestions);

/**
 * [BIZ_GOV_05] ROI 看板
 */
router.get('/roi/dashboard', requireTraceContext, requirePermission('finance:read'), TelemetryController.getRoiDashboard);

/**
 * [UX_EXT_19] 插件端异常上报
 */
router.post('/anomaly', requireTraceContext, TelemetryController.reportAnomaly);

export default router;
