This commit is contained in:
dv 2026-04-08 23:27:25 +03:00
parent 01056a87b5
commit b618bdf0da

View file

@ -1,9 +1,12 @@
"""Global devices endpoint — cross-object device listing with filters."""
import logging
from typing import Optional
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, Query
from sqlalchemy import select
logger = logging.getLogger(__name__)
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload
@ -18,7 +21,7 @@ router = APIRouter(prefix="/api/v1/devices", tags=["devices-global"])
@router.get("", response_model=list[DeviceRead])
async def list_all_devices(
category: Optional[list[str]] = None,
category: Optional[list[str]] = Query(default=None),
city: Optional[str] = None,
client: Optional[str] = None,
object_id: Optional[int] = None,
@ -34,6 +37,8 @@ async def list_all_devices(
- All bank terminals for a client: ?category=bank_terminal&client=Авангард
- All devices in a city: ?city=Санкт-Петербург
"""
logger.info("list_all_devices called: category=%r city=%r client=%r object_id=%r status=%r", category, city, client, object_id, status)
query = (
select(Device)
.join(Object, Device.object_id == Object.id)