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

const router = Router();

/**
 * [BIZ_GOV_06] 功能治理 API
 */
router.get('/flags', requireTraceContext, requirePermission('admin:all'), GovernanceController.getFeatureFlags);
router.post('/flags/register', requireTraceContext, requirePermission('admin:all'), GovernanceController.registerFeature);
router.post('/flags/toggle', requireTraceContext, requirePermission('admin:all'), GovernanceController.toggleFeature);
router.post('/flags/override', requireTraceContext, requirePermission('admin:all'), GovernanceController.setTenantOverride);
router.get('/flags/tenant/:tenantId', requireTraceContext, requirePermission('admin:all'), GovernanceController.getTenantOverrides);

/**
 * [FE_INBOX_01] 任务中心 API
 */
router.get('/tasks/pending', requireTraceContext, GovernanceController.getPendingTasks);
router.post('/tasks/claim', requireTraceContext, GovernanceController.claimTask);
router.post('/tasks/complete', requireTraceContext, GovernanceController.completeTask);

/**
 * [BIZ_AUDIT_RED_TEAMING] 红蓝对抗 API
 */
router.post('/redteam/run', requireTraceContext, requirePermission('admin:all'), GovernanceController.runRedTeamTests);
router.get('/redteam/report', requireTraceContext, requirePermission('admin:all'), GovernanceController.getSecurityReport);

export default router;
