该接口用于查询设备的日志数据。
请求接口
POST /api/device/instance/{deviceId}/logs
请求参数
名称 | 位置 | 类型 | 必选 | 说明 |
---|---|---|---|---|
X-Access-Token | header | string | 是 | 平台 token |
deviceId | path | string | 是 | 设备ID |
body | body | object | 否 | - |
» current | body | integer | 否 | 当前页面 |
» pageSize | body | integer | 否 | 每页数量 |
» pageIndex | body | integer | 否 | 页码,从 0 开始 |
» sorts | body | [object] | 否 | 排序,可以根据多个字段排序 |
»» name | body | string | 否 | 排序字段名称 |
»» order | body | string | 否 | 排序方式:asc(升序)、desc(降序) |
响应参数
以200 Response为例,响应参数如下:
名称 | 类型 | 必选 | 约束 | 说明 |
---|---|---|---|---|
» message | string | true | none | 返回信息 |
» result | object | true | none | 返回结果 |
»» pageIndex | integer | true | none | 页码,从 0 开始 |
»» pageSize | integer | true | none | 每页数量 |
»» total | integer | true | none | 总数 |
»» data | [object] | true | none | 数据 |
»»» id | string | false | none | 日志ID |
»»» deviceId | string | false | none | 设备ID |
»»» type | object | false | none | 事件类型 |
»»»» text | string | true | none | 事件类型名称 |
»»»» value | string | true | none | 事件类型标识 |
»»» createTime | string | false | none | 创建时间 |
»»» content | string | false | none | 日志内容 |
»»» timestamp | integer | true | none | 时间戳 |
» status | integer | true | none | 响应状态码 |
» timestamp | integer | true | none | 时间戳 |
响应状态码
状态码 | 状态码含义 | 说明 |
---|---|---|
200 | OK | 成功 |
401 | Unauthorized | 登录状态已过期,token不能为空 |
500 | Internal Server Error | 服务器内部异常 |
Body示例
json
{
"current": 1,
"pageSize": 10,
"pageIndex": 0,
"terms": [
{
"terms": [
{
"termType": "eq",
"column": "type",
"value": "reportProperty"
},
{
"termType": "gt",
"column": "timestamp",
"value": "2023-07-19 15:36:02",
"type": "and"
},
{
"termType": "lt",
"column": "timestamp",
"value": "2023-08-19 15:36:02",
"type": "and"
}
]
}
],
"sorts": [
{
"name": "timestamp",
"order": "desc"
}
]
}
{
"current": 1,
"pageSize": 10,
"pageIndex": 0,
"terms": [
{
"terms": [
{
"termType": "eq",
"column": "type",
"value": "reportProperty"
},
{
"termType": "gt",
"column": "timestamp",
"value": "2023-07-19 15:36:02",
"type": "and"
},
{
"termType": "lt",
"column": "timestamp",
"value": "2023-08-19 15:36:02",
"type": "and"
}
]
}
],
"sorts": [
{
"name": "timestamp",
"order": "desc"
}
]
}
返回示例
以200 Response为例:
json
{
"message": "success",
"result": {
"pageIndex": 0,
"pageSize": 10,
"total": 1,
"data": [
{
"id": "AYmvzHJYeJJRzuD8PBTCzcQHbezbAUxF",
"deviceId": "1686255442944180224",
"type": {
"text": "上线",
"value": "online"
},
"createTime": 1690871558744,
"content": "{\"headers\":{\"bindings\":[{\"id\":\"1684128610714238976\",\"type\":\"org\"}],\"serverId\":\"Himalaya-platform:9101\",\"deviceName\":\"人体感应雷达1\",\"productName\":\"建总-人体感应雷达\",\"connectTime\":1690871558743,\"from\":\"session\",\"productId\":\"1685920501800108032\",\"_uid\":\"AYmvzHJYeJJRzuD8PBTCzcQHbezbAUxF\",\"creatorId\":\"0458936de2edf602f70f101ef3398ce5\"},\"messageType\":\"ONLINE\",\"deviceId\":\"1686255442944180224\",\"timestamp\":1690871558744}",
"timestamp": 1690871558744
}
]
},
"status": 200,
"timestamp": 1690871980508
}
{
"message": "success",
"result": {
"pageIndex": 0,
"pageSize": 10,
"total": 1,
"data": [
{
"id": "AYmvzHJYeJJRzuD8PBTCzcQHbezbAUxF",
"deviceId": "1686255442944180224",
"type": {
"text": "上线",
"value": "online"
},
"createTime": 1690871558744,
"content": "{\"headers\":{\"bindings\":[{\"id\":\"1684128610714238976\",\"type\":\"org\"}],\"serverId\":\"Himalaya-platform:9101\",\"deviceName\":\"人体感应雷达1\",\"productName\":\"建总-人体感应雷达\",\"connectTime\":1690871558743,\"from\":\"session\",\"productId\":\"1685920501800108032\",\"_uid\":\"AYmvzHJYeJJRzuD8PBTCzcQHbezbAUxF\",\"creatorId\":\"0458936de2edf602f70f101ef3398ce5\"},\"messageType\":\"ONLINE\",\"deviceId\":\"1686255442944180224\",\"timestamp\":1690871558744}",
"timestamp": 1690871558744
}
]
},
"status": 200,
"timestamp": 1690871980508
}