Skip to content

查询设备日志数据 (POST)

更新时间:

该接口用于查询设备的日志数据。

请求接口

POST /api/device/instance/{deviceId}/logs

TIP

访问权限:需要登录超级设备管理平台获取token,并校验token

请求参数

名称位置类型必选说明
X-Access-Tokenheaderstring平台 token
deviceIdpathstring设备ID
bodybodyobject-
» currentbodyinteger当前页面
» pageSizebodyinteger每页数量
» pageIndexbodyinteger页码,从 0 开始
» sortsbody[object]排序,可以根据多个字段排序
»» namebodystring排序字段名称
»» orderbodystring排序方式:asc(升序)、desc(降序)

响应参数

以200 Response为例,响应参数如下:

名称类型必选约束说明
» messagestringtruenone返回信息
» resultobjecttruenone返回结果
»» pageIndexintegertruenone页码,从 0 开始
»» pageSizeintegertruenone每页数量
»» totalintegertruenone总数
»» data[object]truenone数据
»»» idstringfalsenone日志ID
»»» deviceIdstringfalsenone设备ID
»»» typeobjectfalsenone事件类型
»»»» textstringtruenone事件类型名称
»»»» valuestringtruenone事件类型标识
»»» createTimestringfalsenone创建时间
»»» contentstringfalsenone日志内容
»»» timestampintegertruenone时间戳
» statusintegertruenone响应状态码
» timestampintegertruenone时间戳

响应状态码

状态码状态码含义说明
200OK成功
401Unauthorized登录状态已过期,token不能为空
500Internal 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
}