Files
OnEverControl/backend/app/api/v1/control_posts.py
T

49 lines
1.7 KiB
Python

# ==============================================================================
# Endpoints de Puestos de Control y Workstations (/api/v1/control-posts)
# ==============================================================================
from typing import List
from fastapi import APIRouter
from app.schemas.workstation_schema import (
WorkstationStatusResponse,
WorkstationConfigResponse,
WorkstationItemDTO,
)
from app.services.workstation_service import WorkstationService
router = APIRouter()
@router.get(
"/workstations",
response_model=List[WorkstationItemDTO],
summary="Listar todas las Workstations reales registradas en SQL Server",
)
async def list_workstations():
"""Listado real de estaciones desde la tabla wks para selector de login."""
return WorkstationService.listar_estaciones_disponibles()
@router.get(
"/{name}/config",
response_model=WorkstationConfigResponse,
summary="Consultar configuración de módulos de carril asignados a la workstation",
)
@router.get(
"/workstation/{name}/config",
response_model=WorkstationConfigResponse,
summary="Consultar configuración de módulos de carril asignados a la workstation (alias)",
)
async def get_workstation_config(name: str):
"""Retorna los módulos de entrada y salida asignados a la estación en wksmdl y mdl."""
return WorkstationService.obtener_config_workstation(name)
@router.get(
"/workstation/{name}/status",
response_model=WorkstationStatusResponse,
summary="Consultar estado y módulos de la Workstation",
)
async def get_workstation_status(name: str):
"""Verifica si la tablet/estación está autorizada como Puesto de Control y retorna sus carriles."""
return WorkstationService.obtener_estado_workstation(name)