Notas y bibliotecas funcionando
This commit is contained in:
@@ -3,6 +3,7 @@ from fastapi import Path
|
||||
|
||||
from backend.schemas.text_manager_schema import BibliotecaInput, NotaInput
|
||||
|
||||
from fastapi.concurrency import run_in_threadpool
|
||||
from backend.db.conexion import get_conexion
|
||||
from backend.services.text_manager_srvc import *
|
||||
from src.ConexionSql.Postgres_conexion import PostgresConexion
|
||||
@@ -10,21 +11,24 @@ from src.ConexionSql.Postgres_conexion import PostgresConexion
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/", summary="Crear una nueva biblioteca")
|
||||
def crear_biblioteca_endpoint(
|
||||
@router.post("/biblioteca", summary="Crear una nueva biblioteca")
|
||||
async def crear_biblioteca_endpoint(
|
||||
data: BibliotecaInput,
|
||||
conexion: PostgresConexion = Depends(get_conexion)
|
||||
):
|
||||
try:
|
||||
return crear_biblioteca(
|
||||
nombre_biblioteca=data.nombre_biblioteca,
|
||||
descripcion=data.descripcion,
|
||||
conexion=conexion
|
||||
return await run_in_threadpool(
|
||||
crear_biblioteca,
|
||||
data.nombre_biblioteca,
|
||||
conexion,
|
||||
data.descripcion,
|
||||
)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail="Error interno al crear la biblioteca")
|
||||
raise HTTPException(status_code=500, detail=f"Error interno al crear la biblioteca: {str(e)}")
|
||||
|
||||
|
||||
|
||||
@router.get("/list", summary="Listar todas las bibliotecas")
|
||||
def listar_todas_bibliotecas(
|
||||
|
||||
Reference in New Issue
Block a user