<?php

namespace Modules\Performance;

use Gestoreasy\Core\Module\ModuleInterface;
use Gestoreasy\Core\Routing\Router;
use Gestoreasy\Core\Http\AuthMiddleware;
use Gestoreasy\Core\Auth\Rbac;
use Modules\Performance\Controllers\PerformanceController;

class Module implements ModuleInterface {
    public function register(Router $router): void {
        $perfCtrl = new PerformanceController();

        // API - Estatísticas de Performance
        $router->get('/api/performance/queries', [$perfCtrl, 'getQueries'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['performance.read'])]);
        $router->get('/api/performance/queries/slow', [$perfCtrl, 'getSlowQueries'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['performance.read'])]);
        $router->get('/api/performance/queries/stats', [$perfCtrl, 'getQueryStats'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['performance.read'])]);
        $router->get('/api/performance/queries/by-sql', [$perfCtrl, 'getQueriesBySql'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['performance.read'])]);
        $router->post('/api/performance/queries/clear', [$perfCtrl, 'clearQueries'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['performance.admin'])]);
        
        // API - Cache Stats
        $router->get('/api/performance/cache/stats', [$perfCtrl, 'getCacheStats'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['performance.read'])]);
        
        // API - Queue Stats
        $router->get('/api/performance/queue/stats', [$perfCtrl, 'getQueueStats'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['performance.read'])]);
    }
}

