- Added schemas, services, and routers for PROSEC, RCG2, Regulaciones, REIT, RequisitoPrevio, TLCS, and Vehiculos modules. - Each module includes search and get by ID functionalities. - Integrated FastAPI routers for each module into the main SITAR router. - Ensured proper response models using Pydantic for data validation.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Fundamentos TLC Router"""
|
|
|
|
from typing import Optional, List
|
|
from fastapi import APIRouter, HTTPException, Query, Depends
|
|
from core.security import get_current_user
|
|
from .service import FundamentosTLCService
|
|
from .schemas import FundamentosTLCResponse
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/", response_model=List[FundamentosTLCResponse])
|
|
async def search_fundamentos(
|
|
fraccion: Optional[str] = Query(None),
|
|
nico: Optional[str] = Query(None),
|
|
tipat_only: bool = Query(False),
|
|
skip: int = Query(0, ge=0),
|
|
limit: int = Query(100, ge=1, le=1000),
|
|
current_user: dict = Depends(get_current_user),
|
|
):
|
|
try:
|
|
service = FundamentosTLCService.get_instance()
|
|
return await service.search(
|
|
fraccion=fraccion, nico=nico, tipat_only=tipat_only, skip=skip, limit=limit
|
|
)
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
@router.get("/{sysid}", response_model=FundamentosTLCResponse)
|
|
async def get_fundamento_by_id(
|
|
sysid: int, current_user: dict = Depends(get_current_user)
|
|
):
|
|
try:
|
|
return await FundamentosTLCService.get_instance().get_by_id(sysid)
|
|
except Exception as e:
|
|
raise HTTPException(status_code=404, detail=str(e))
|