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

const router = Router();

router.post('/init-tables', requireTraceContext, requirePermission('admin'), OrderCentralController.initTables);

router.post('/platforms', requireTraceContext, requirePermission('order:config'), OrderCentralController.registerPlatform);

router.post('/collect', requireTraceContext, requirePermission('order:write'), OrderCentralController.collectOrders);

router.get('/orders', requireTraceContext, requirePermission('order:read'), OrderCentralController.getOrders);

router.get('/funnel-analysis', requireTraceContext, requirePermission('order:read'), OrderCentralController.getFunnelAnalysis);

router.get('/platform-stats', requireTraceContext, requirePermission('order:read'), OrderCentralController.getPlatformStats);

router.get('/collections', requireTraceContext, requirePermission('order:read'), OrderCentralController.getCollectionHistory);

export default router;
