update
This commit is contained in:
parent
20dc484ab9
commit
66b64d4410
10
main.py
10
main.py
|
@ -22,23 +22,20 @@ class BaseResponse(BaseModel):
|
||||||
# 设备注册实体
|
# 设备注册实体
|
||||||
class Device(BaseModel):
|
class Device(BaseModel):
|
||||||
iccid: str = ""
|
iccid: str = ""
|
||||||
deviceId: str = ""
|
deviceId: str
|
||||||
type: int = None
|
type: int = None
|
||||||
|
|
||||||
|
|
||||||
# 数据查询参数实体
|
# 数据查询参数实体
|
||||||
class DataQuery(BaseModel):
|
class DataQuery(BaseModel):
|
||||||
deviceId: str
|
deviceId: str
|
||||||
limit: int = 1
|
|
||||||
|
|
||||||
|
|
||||||
# 数据查询接口
|
# 数据查询接口
|
||||||
@app.post("/api/xumu/data/query")
|
@app.post("/api/xumu/data/query")
|
||||||
async def data_query(params: DataQuery):
|
async def data_query(params: DataQuery):
|
||||||
try:
|
try:
|
||||||
deviceId = params.deviceId
|
deviceId = params.deviceId
|
||||||
limit = params.limit
|
sql = f"select last * from root.farm.{deviceId}"
|
||||||
sql = f"select * from root.farm.{deviceId} order by time desc limit {limit}"
|
|
||||||
send_json = {
|
send_json = {
|
||||||
"sql": sql
|
"sql": sql
|
||||||
}
|
}
|
||||||
|
@ -95,6 +92,9 @@ async def register(request: Request):
|
||||||
deviceId = payload["d"]
|
deviceId = payload["d"]
|
||||||
iccid = payload["cid"]
|
iccid = payload["cid"]
|
||||||
type = payload["t"]
|
type = payload["t"]
|
||||||
|
# TODO 检测该设备是否已经创建
|
||||||
|
|
||||||
|
# 创建该设备
|
||||||
send_json = {
|
send_json = {
|
||||||
"devices": ["root.device"],
|
"devices": ["root.device"],
|
||||||
"timestamps": [int(time.time() * 1000)],
|
"timestamps": [int(time.time() * 1000)],
|
||||||
|
|
Loading…
Reference in New Issue