monitoring-api/packages/v1/administrativo/services/log/log_index_service.py
2025-10-06 09:30:41 -03:00

25 lines
No EOL
937 B
Python

from fastapi import HTTPException, status
from packages.v1.administrativo.actions.log.log_index_action import LogIndexAction
from typing import Tuple, List, Dict, Any
class IndexService:
# O método execute agora recebe 'first' e 'skip'
def execute(self, first: int, skip: int) -> Tuple[List[Dict[str, Any]], int]:
# Instanciamento de ações com prefixo 'log'
log_index_action = LogIndexAction()
# Executa a busca de todos os logs com paginação
data, total_records = log_index_action.execute(first, skip)
# Verifica se foram localizados registros
if not data:
# Retorna uma exceção
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail='Não foi possível localizar os logs'
)
# Retorna as informações localizadas e o total de registros
return data, total_records