feat: Sistema de Ranking de Consultores CAPES - versão inicial
Backend (FastAPI + DDD):
- Arquitetura DDD com camadas Domain, Application, Infrastructure, Interface
- Integração com Elasticsearch (ATUACAPES) para dados de consultores
- Integração com Oracle (SUCUPIRA_PAINEL) para coordenações PPG
- Cálculo dos 4 componentes de pontuação (A, B, C, D)
- Cache em memória para otimização de performance
- API REST com endpoints /ranking, /ranking/detalhado, /consultor/{id}
Frontend (React + Vite):
- Interface responsiva com cards expansíveis
- Visualização detalhada de pontuação por componente
- Filtro por quantidade de consultores (Top 10, 50, 100, etc)
Docker:
- docker-compose com shared_network externa
- Backend com Oracle Instant Client
- Frontend com Vite dev server
This commit is contained in:
77
backend/src/interface/api/routes.py
Normal file
77
backend/src/interface/api/routes.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from typing import Optional
|
||||
|
||||
from ...application.use_cases.obter_ranking import ObterRankingUseCase
|
||||
from ...application.use_cases.obter_consultor import ObterConsultorUseCase
|
||||
from ...infrastructure.repositories.consultor_repository_impl import ConsultorRepositoryImpl
|
||||
from ..schemas.consultor_schema import (
|
||||
RankingResponseSchema,
|
||||
RankingDetalhadoResponseSchema,
|
||||
ConsultorDetalhadoSchema,
|
||||
ConsultorResumoSchema,
|
||||
)
|
||||
from .dependencies import get_repository
|
||||
|
||||
router = APIRouter(prefix="/api/v1", tags=["ranking"])
|
||||
|
||||
|
||||
@router.get("/ranking", response_model=RankingResponseSchema)
|
||||
async def obter_ranking(
|
||||
limite: int = Query(default=100, ge=1, le=1000, description="Limite de consultores"),
|
||||
offset: int = Query(default=0, ge=0, description="Offset para paginação"),
|
||||
componente: Optional[str] = Query(
|
||||
default=None, description="Filtrar por componente (a, b, c, d)"
|
||||
),
|
||||
repository: ConsultorRepositoryImpl = Depends(get_repository),
|
||||
):
|
||||
use_case = ObterRankingUseCase(repository=repository)
|
||||
consultores_dto = await use_case.executar(limite=limite, componente=componente)
|
||||
|
||||
total = await repository.contar_total()
|
||||
|
||||
consultores_schema = [
|
||||
ConsultorResumoSchema(**vars(dto)) for dto in consultores_dto
|
||||
]
|
||||
|
||||
return RankingResponseSchema(
|
||||
total=total, limite=limite, offset=offset, consultores=consultores_schema
|
||||
)
|
||||
|
||||
|
||||
@router.get("/ranking/detalhado", response_model=RankingDetalhadoResponseSchema)
|
||||
async def obter_ranking_detalhado(
|
||||
limite: int = Query(default=100, ge=1, le=1000, description="Limite de consultores"),
|
||||
componente: Optional[str] = Query(
|
||||
default=None, description="Filtrar por componente (a, b, c, d)"
|
||||
),
|
||||
repository: ConsultorRepositoryImpl = Depends(get_repository),
|
||||
):
|
||||
use_case = ObterRankingUseCase(repository=repository)
|
||||
consultores_dto = await use_case.executar_detalhado(limite=limite, componente=componente)
|
||||
|
||||
total = await repository.contar_total()
|
||||
|
||||
consultores_schema = [
|
||||
ConsultorDetalhadoSchema(**dto.to_dict()) for dto in consultores_dto
|
||||
]
|
||||
|
||||
return RankingDetalhadoResponseSchema(total=total, limite=limite, consultores=consultores_schema)
|
||||
|
||||
|
||||
@router.get("/consultor/{id_pessoa}", response_model=ConsultorDetalhadoSchema)
|
||||
async def obter_consultor(
|
||||
id_pessoa: int,
|
||||
repository: ConsultorRepositoryImpl = Depends(get_repository),
|
||||
):
|
||||
use_case = ObterConsultorUseCase(repository=repository)
|
||||
consultor = await use_case.executar(id_pessoa=id_pessoa)
|
||||
|
||||
if not consultor:
|
||||
raise HTTPException(status_code=404, detail=f"Consultor {id_pessoa} não encontrado")
|
||||
|
||||
return consultor
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
async def health_check():
|
||||
return {"status": "ok", "message": "API Ranking CAPES funcionando"}
|
||||
Reference in New Issue
Block a user