Skip to content

分享链接

资源说明

分享链接定义

衡石系统为应用设置分享链接,用户不需要登录衡石系统就可以查看此应用下面的仪表盘和图表。

目录结构说明

字段类型描述
idBIGINT分享链接id
hashSTRING分享的hash
objectTypeSTRING分享的类型,目前可选类型为 app
objectIdNUMBER应用的id
titleSTRING应用的标题
isDeleteBOOL是否被删除
enableBOOL是否被启用

接口说明

启用/停用分享链接

请求URL

http
PUT /api/shares/switch HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数
字段类型是否必须说明
objectTypeSTRING分享的类型
objectIdNUMBER应用的id
enableBOOLEANtrue 表示启用分享, false 表示停用分享

返回对象的格式说明

启用请求返回对象的格式说明
字段类型是否必须说明
objectTypeSTRING分享的类型
objectIdNUMBER应用的id
enableBOOLEANtrue
hashSTRING分享的 hash
titleSTRING应用的标题
停用请求返回对象的格式说明

停用请求只返回请求状态,返回对象为空。

接口示例1: 启用分享链接

http
PUT /api/shares/switch HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{"objectType":"app","objectId":1478,"enable":true}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
    "version": "version@9a5e106#6730f0d",
    "code": 0,
    "msg": "success",
    "data": {
        "id": 59,
        "hash": "E8B10104A",
        "objectType": "app",
        "objectId": 1478,
        "createdBy": 1,
        "createdAt": "2019-12-16 09:42:10",
        "title": "新建应用 (5)",
        "enable": true
    }
}

接口示例2: 停用分享链接

http
PUT /api/shares/switch HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{"objectType":"app","objectId":1478,"enable":false}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
    "version": "version@9a5e106#6730f0d",
    "code": 0,
    "msg": "success",
    "data": {}
}

重新生成分享链接

请求URL

http
PUT /api/shares/refresh HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数
字段类型是否必须说明
objectTypeSTRING分享的类型
objectIdNUMBER应用的id

返回对象的格式说明

字段类型是否必须说明
objectTypeSTRING分享的类型
objectIdNUMBER应用的id
enableBOOLEANtrue
hashSTRING分享的 hash
titleSTRING应用的标题

接口示例1: 重新生成分享链接

http
PUT /api/shares/refresh HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{"objectType":"app","objectId":1478}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
    "version": "version@9a5e106#6730f0d",
    "code": 0,
    "msg": "success",
    "data": {
        "id": 60,
        "hash": "E1C0FDEAC",
        "objectType": "app",
        "objectId": 1478,
        "createdBy": 1,
        "createdAt": "2019-12-16 09:47:01",
        "title": "新建应用 (5)",
        "enable": true
    }
}

获取 app 的共享 hash 签名

请求URL

http
GET /api/apps/{appId}/share/signature HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型是否必须说明
appIdINTEGER应用的 id

返回对象的格式说明

返回的是可用的url参数字符串

接口示例1

http
GET /api/apps/11384/share/signature?where=%5B%7B%22kind%22%3A%22constant%22%2C%22op%22%3Atrue%7D%5D HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
    "version": "version@9a5e106#6730f0d",
    "code": 0,
    "msg": "success",
    "data": "where=%5B%7B%22kind%22%3A%22constant%22%2C%22op%22%3Atrue%7D%5D&utcSecond=1624508733&signature=a129c5e37f1e74703acf7d425181df74ffaa9c34"
}

通过共享信息获取签名

请求URL

http
POST /api/shares/signature HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body
字段类型是否必须说明
appHashSTRING应用的共享 hash
whereSTRING需要添加的 where 过滤条件
havingSTRING需要添加的 having 过滤条件
utcSecondINTEGER签名的时间戳,用于配置了有效期的共享

返回对象的格式说明

返回的是可用的url参数字符串

接口示例1

http
POST /api/shares/signature HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
    "appHash":"ninininini",
    "utcSecond":10101011,
    "where":"[{\"kind\":\"formula\",\"op\":\"isnotnull({A})\"}]"
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
    "version": "version@9a5e106#6730f0d",
    "code": 0,
    "msg": "success",
    "data": "where=%5B%7B%22kind%22%3A%22formula%22%2C%22op%22%3A%22isnotnull%28%7BA%7D%29%22%7D%5D&utcSecond=10101011&signature=703dc6e05ac3b25a58358f78d42723b7a08aa287"
}

HENGSHI SENSE API 使用手册