feat(14-01): add sector CRUD backend with migration, model, service, and router
- Create sectors table migration (034) with RLS and devices.sector_id FK - Add Sector ORM model with site_id and tenant_id foreign keys - Add SectorCreate/Update/Response/ListResponse Pydantic schemas - Implement sector_service with CRUD and device assignment functions - Add sectors router with GET/POST/PUT/DELETE and device sector assignment - Register sectors router in main.py - Add sector_id and sector_name to Device model and DeviceResponse Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -111,6 +111,8 @@ def _build_device_response(device: Device) -> DeviceResponse:
|
||||
groups=groups,
|
||||
site_id=device.site_id,
|
||||
site_name=device.site.name if device.site else None,
|
||||
sector_id=device.sector_id,
|
||||
sector_name=device.sector.name if device.sector else None,
|
||||
created_at=device.created_at,
|
||||
)
|
||||
|
||||
@@ -123,6 +125,7 @@ def _device_with_relations():
|
||||
selectinload(Device.tag_assignments).selectinload(DeviceTagAssignment.tag),
|
||||
selectinload(Device.group_memberships).selectinload(DeviceGroupMembership.group),
|
||||
selectinload(Device.site),
|
||||
selectinload(Device.sector),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user