diff --git a/xumu.py b/xumu.py index 7340199..91e0268 100644 --- a/xumu.py +++ b/xumu.py @@ -19,11 +19,31 @@ class BaseResponse(BaseModel): data: Any = None +# 监控视频接口 @app.get("/api/xumu/video") async def data_query(username): return BaseResponse(data=get_video_url(username)) +@app.get("/api/xumu/device/online") +async def device_online_query(iccid, deviceId): + try: + sql = "select is_online from root.farm.clientId where time >= 0" + # 检查iccid是否有值,如果有,添加到SQL语句中 + if iccid: + sql += f" and iccid = '{iccid}'" + # 检查deviceId是否有值,如果有,添加到SQL语句中 + if deviceId: + sql += f" and deviceId = '{deviceId}'" + send_json = { + "sql": sql + } + r = requests.post(baseHost + queryUri, headers=headers, json=send_json) + return BaseResponse(data=r.json()) + except Exception as e: + return BaseResponse(code=500, msg=str(e)) + + # 数据查询接口 @app.get("/api/xumu/data/query") async def data_query(deviceId):