diff --git a/main.py b/main.py index 821ce07..ddb84a7 100644 --- a/main.py +++ b/main.py @@ -22,23 +22,20 @@ class BaseResponse(BaseModel): # 设备注册实体 class Device(BaseModel): iccid: str = "" - deviceId: str = "" + deviceId: str type: int = None # 数据查询参数实体 class DataQuery(BaseModel): deviceId: str - limit: int = 1 - # 数据查询接口 @app.post("/api/xumu/data/query") async def data_query(params: DataQuery): try: deviceId = params.deviceId - limit = params.limit - sql = f"select * from root.farm.{deviceId} order by time desc limit {limit}" + sql = f"select last * from root.farm.{deviceId}" send_json = { "sql": sql } @@ -95,6 +92,9 @@ async def register(request: Request): deviceId = payload["d"] iccid = payload["cid"] type = payload["t"] + # TODO 检测该设备是否已经创建 + + # 创建该设备 send_json = { "devices": ["root.device"], "timestamps": [int(time.time() * 1000)],