<?php

namespace Modules\IA;

use Gestoreasy\Core\Module\ModuleInterface;
use Gestoreasy\Core\Routing\Router;
use Gestoreasy\Core\Http\AuthMiddleware;
use Gestoreasy\Core\Auth\Rbac;
use Modules\IA\Controllers\PrevisaoDemandaController;
use Modules\IA\Controllers\RecomendacoesController;
use Modules\IA\Controllers\IAViewsController;

class Module implements ModuleInterface {
    public function register(Router $router): void {
        $previsaoCtrl = new PrevisaoDemandaController();
        $recomendacoesCtrl = new RecomendacoesController();
        $viewsCtrl = new IAViewsController();

        // Views
        $router->get('/ia', [$viewsCtrl, 'dashboard'], [AuthMiddleware::requireAuthHtml(), Rbac::requirePermissions(['ia.read'])]);
        $router->get('/ia/previsao-demanda', [$viewsCtrl, 'previsaoDemanda'], [AuthMiddleware::requireAuthHtml(), Rbac::requirePermissions(['ia.read'])]);

        // API - Previsão de Demanda
        $router->get('/api/ia/previsao-demanda', [$previsaoCtrl, 'getPrevisao'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['ia.read'])]);
        $router->post('/api/ia/previsao-demanda/treinar', [$previsaoCtrl, 'treinarModelo'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['ia.admin'])]);

        // API - Recomendações
        $router->get('/api/ia/recomendacoes/produto/{product_id}', [$recomendacoesCtrl, 'getRecomendacoesProduto'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['ia.read'])]);
        $router->get('/api/ia/recomendacoes/cliente/{cliente_id}', [$recomendacoesCtrl, 'getRecomendacoesCliente'], [AuthMiddleware::requireAuth(), Rbac::requirePermissions(['ia.read'])]);
    }
}

