ууу
This commit is contained in:
parent
01056a87b5
commit
b618bdf0da
1 changed files with 7 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue