This commit is contained in:
xyj 2024-01-24 17:29:46 +08:00
parent 20dc484ab9
commit 66b64d4410
1 changed files with 5 additions and 5 deletions

10
main.py
View File

@ -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)],