Prechádzať zdrojové kódy

add a api for receiving a user's bluetooth infomation

chenhaiyang 4 rokov pred
rodič
commit
1b56b17da0

+ 19 - 0
app/api/routers/bluetooth.py

@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+
+from typing import List
+
+from fastapi import APIRouter, Depends, HTTPException, Query
+from loguru import logger
+
+from app.models.domain.bluetooth import BluetoothUserResponse
+from app.schemas.bluetooth import BluetoothCreate
+
+router = APIRouter()
+
+
+@router.post('/user/{user_id}', response_model=BluetoothUserResponse)
+async def create_bluetooth_info(bluetooth_info: List[BluetoothCreate]):
+    logger.info(bluetooth_info)
+    response = {'Result': 'success'}
+
+    return response

+ 2 - 1
app/main.py

@@ -7,7 +7,7 @@ import uvicorn
 from fastapi import FastAPI
 from loguru import logger
 
-from app.api.routers import targets, equipment, space, item, user
+from app.api.routers import targets, equipment, space, item, user, bluetooth
 from app.core.config import settings
 from app.core.events import create_start_app_handler
 from app.core.logger import InterceptHandler
@@ -29,6 +29,7 @@ def get_application() -> FastAPI:
     application.include_router(targets.router, prefix='/target', tags=['targets'])
     application.include_router(item.router, prefix='/items', tags=['items'])
     application.include_router(user.router, prefix='/users', tags=['users'])
+    application.include_router(bluetooth.router, prefix='/bluetooth', tags=['bluetooth'])
 
     return application
 

+ 7 - 0
app/models/domain/bluetooth.py

@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+
+from pydantic import BaseModel
+
+
+class BluetoothUserResponse(BaseModel):
+    Result: str

+ 18 - 0
app/schemas/bluetooth.py

@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+from typing import Optional
+
+from pydantic import BaseModel
+
+
+class BluetoothBase(BaseModel):
+    name: Optional[str] = None
+    deviceName: Optional[str] = None
+    localName: Optional[str] = None
+    RSSI: Optional[float] = None
+    advertisData: Optional[str] = None
+    manufacturerData: Optional[str] = None
+
+
+class BluetoothCreate(BluetoothBase):
+    pass