positioning.py 798 B

1234567891011121314151617181920212223242526
  1. from fastapi import APIRouter
  2. from loguru import logger
  3. from app.controllers.location.ble.space import get_space_location
  4. from app.models.domain.location import PositionSpaceResponse
  5. from app.schemas.bluetooth import IBeaconBase
  6. router = APIRouter()
  7. @router.post(
  8. "/space/users/{user_id}/projects/{project_id}", response_model=PositionSpaceResponse
  9. )
  10. async def update_in_space(
  11. user_id: str, project_id: str, ibeacon_list: list[IBeaconBase]
  12. ):
  13. space_id = await get_space_location(project_id, ibeacon_list)
  14. logger.debug(f"{user_id} is in {space_id}")
  15. response = {"userId": user_id, "projectId": project_id}
  16. if space_id:
  17. response.update({"result": "success", "spaceId": space_id})
  18. else:
  19. response.update({"result": "failure"})
  20. return response