feat(api): migracion completa de Flask API a FastAPI ASGI con arquitectura en 4 capas v3.6.0
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
FastAPI Students Router (/api/v1/students)
|
||||
Provides academic milestone and gradebook queries for students.
|
||||
"""
|
||||
from typing import Optional
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
|
||||
from app.services.gradebook_service import GradebookService
|
||||
from dependencies import get_current_user
|
||||
from app.models.user import User
|
||||
|
||||
students_router = APIRouter(prefix="/api/v1/students", tags=["Students"])
|
||||
|
||||
|
||||
@students_router.get("/my-grades")
|
||||
def get_my_grades(current_user: User = Depends(get_current_user)):
|
||||
"""Consulta individual de calificaciones y estado académico del alumno logueado."""
|
||||
try:
|
||||
grades = GradebookService.get_student_grades(current_user.id)
|
||||
return {
|
||||
'status': 'success',
|
||||
'student_id': current_user.id,
|
||||
'is_impersonating': False,
|
||||
'data': grades
|
||||
}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
|
||||
|
||||
|
||||
@students_router.get("/my-upcoming-milestones")
|
||||
def get_my_upcoming_milestones(
|
||||
limit: int = Query(5, ge=1, le=50),
|
||||
current_user: User = Depends(get_current_user)
|
||||
):
|
||||
"""Próximas evaluaciones e hitos académicos con cuenta regresiva para el dashboard."""
|
||||
try:
|
||||
milestones = GradebookService.get_student_upcoming_milestones(current_user.id, limit=limit)
|
||||
return {'status': 'success', 'data': milestones}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
|
||||
Reference in New Issue
Block a user