# -*- coding: utf-8 -*-

from typing import List

from fastapi import APIRouter, Depends, HTTPException, Query
from loguru import logger

from app.controllers.location.ble.space import get_space_location
from app.models.domain.bluetooth import BluetoothUserResponse
from app.schemas.bluetooth import IBeaconBase

router = APIRouter()


@router.post('/user/{user_id}', response_model=BluetoothUserResponse)
async def create_bluetooth_info(user_id: str, bluetooth_info: List[IBeaconBase]):
    info_list = [item.dict() for item in bluetooth_info]
    logger.info(f'{user_id}: {info_list}')
    sp_id = await get_space_location('Pj1101080259', bluetooth_info)
    response = {'Result': sp_id}

    return response