Skip to content

应用参数

资源说明

应用参数定义

参数是作用在整个应用内的一个可配置变量,可以使用在应用内任何可以设置常量的地方如:高级表达式、数据集过滤条件、customSQL、图表过滤器、行权限等。

应用参数结构说明

字段类型描述
idLONG应用参数id
appIdLONG应用id
nameSTRING应用参数名称
optionsOBJECT应用参数配置信息
options.typeSTRING应用参数数据类型,支持:number,string,date,time
options.subTypeSTRING应用参数允许值,支持:ALL,LIST,DYNAMIC,RANGE
options.maxValueOBJECT应用参数最大值
options.minValueOBJECT应用参数最小值
options.valueSetARRAY应用参数指定值列表,JSONObject格式,有效key为"value","display",例:"valueSet":[{value: 0, display : "男性"}, {value:1}, {value:2, display:"未知"}]
options.intervalNumLONG应用参数值间隔数
options.periodSTRING应用参数时间间隔单位,可选值:YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND
options.granularitySTRING应用参数时间粒度,可选值:YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND
options.defaultValueOBJECT应用参数默认值
options.allowAllValueBOOL应用参数是否允许任意值
options.datasetIdLONG应用参数值数据集id
options.valueFieldSTRING应用参数值字段名称
options.displayFieldSTRING应用参数显示值字段名称
options.displayValueSTRING应用参数显示值
options.multiValueConfigOBJECT应用参数多值配置
options.multiValueConfig.enableBOOL应用参数开启多值
options.multiValueConfig.splitSTRING应用参数多值配置分隔符
options.multiValueConfig.quoteSTRING应用参数多值配置起止符
options.multiValueConfig.prefixSTRING应用参数多值配置前缀
options.multiValueConfig.suffixSTRING应用参数多值配置后缀
updatedAtDATETIME应用参数最后更新时间
updatedByLONG应用参数最后修改者的userId
createdAtDATETIME应用参数创建时间
updatedByLONG应用参数最后修改者的userId
extendAppIdLONG继承的应用id
extendAppTitleSTRING继承的应用名称
tagsOBJECT应用参数分组信息

接口说明

1、创建应用参数

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的编辑者权限

请求URL

http
POST /api/apps/{appId}/params HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数
字段类型是否必须说明
nameSTRING应用参数名称
options.typeSTRING应用参数数据类型,支持:number,string,date,time
options.subTypeSTRING应用参数允许值,支持:ALL,LIST,DYNAMIC,RANGE
options.maxValueOBJECT应用参数最大值
options.minValueOBJECT应用参数最小值
options.valueSetARRAY应用参数指定值列表,JSONObject格式,有效key为"value","display",例:"valueSet":[{value: 0, display : "男性"}, {value:1}, {value:2, display:"未知"}]
options.intervalNumLONG应用参数值间隔数
options.periodSTRING应用参数时间间隔单位,可选值:YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND
options.granularitySTRING应用参数时间粒度,可选值:YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND
options.defaultValueOBJECT应用参数默认值
options.allowAllValueBOOL应用参数是否允许任意值
options.datasetIdLONG应用参数值数据集id
options.valueFieldSTRING应用参数值字段名称
options.displayFieldSTRING应用参数显示值字段名称
options.displayValueSTRING应用参数显示值
options.multiValueConfigOBJECT应用参数多值配置
options.multiValueConfig.enableBOOL应用参开启多值
options.multiValueConfig.splitSTRING应用参数多值配置分隔符
options.multiValueConfig.quoteSTRING应用参数多值配置起止符
options.multiValueConfig.prefixSTRING应用参数多值配置前缀
options.multiValueConfig.suffixSTRING应用参数多值配置后缀

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT每种应用参数的共同结构见应用参数结构说明

接口示例1: 创建应用参数

http
POST /api/apps/{appId}/params HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "name": "test",
  "options": {
    "type": "time",
    "subType": "RANGE",
    "allowAllValue": false,
    "granularity": "second",
    "period": "SECOND",
    "maxValue": "2023-08-01 23:59:59",
    "minValue": "2023-01-01 00:00:00",
    "defaultValue": "2023-02-01 10:00:00"
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 6,
    "name": "test",
    "appId": 19,
    "options": {
      "type": "time",
      "subType": "RANGE",
      "maxValue": "2023-08-01 23:59:59",
      "minValue": "2023-01-01 00:00:00",
      "period": "SECOND",
      "granularity": "second",
      "defaultValue": "2023-02-01 10:00:00",
      "allowAllValue": false
    },
    "createdBy": 2,
    "createdAt": "2023-08-10 11:11:41",
    "updatedBy": 2,
    "updatedAt": "2023-08-10 11:11:41",
    "tags": {}
  }
}

接口示例2: 创建应用参数(列表)

http
POST /api/apps/{appId}/params HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "name": "listTest",
  "options": {
    "type": "string",
    "subType": "LIST",
    "allowAllValue": false,
    "defaultValue": "test1",
    "displayValue": "t1",
    "valueSet": [
      {
        "value": "test1",
        "display": "t1"
      },
      {
        "value": "test2",
        "display": "t2"
      },
      {
        "value": "test3",
        "display": "t3"
      }
    ]
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 7,
    "name": "listTest",
    "appId": 19,
    "options": {
      "type": "string",
      "subType": "LIST",
      "valueSet": [
        {
          "value": "test1",
          "display": "t1"
        },
        {
          "value": "test2",
          "display": "t2"
        },
        {
          "value": "test3",
          "display": "t3"
        }
      ],
      "defaultValue": "test1",
      "displayValue": "t1",
      "allowAllValue": false
    },
    "createdBy": 2,
    "createdAt": "2023-08-10 11:15:10",
    "updatedBy": 2,
    "updatedAt": "2023-08-10 11:15:10",
    "tags": {}
  }
}

2、修改应用参数

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的编辑者权限

请求URL

http
PUT /api/apps/{appId}/params/{paramId} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数
字段类型是否必须说明
nameSTRING应用参数名称
options.typeSTRING应用参数数据类型,支持:number,string,date,time
options.subTypeSTRING应用参数允许值,支持:ALL,LIST,DYNAMIC,RANGE
options.maxValueOBJECT应用参数最大值
options.minValueOBJECT应用参数最小值
options.valueSetARRAY应用参数指定值列表,JSONObject格式,有效key为"value","display",例:"valueSet":[{value: 0, display : "男性"}, {value:1}, {value:2, display:"未知"}]
options.intervalNumLONG应用参数值间隔数
options.periodSTRING应用参数时间间隔单位,可选值:YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND
options.granularitySTRING应用参数时间粒度,可选值:YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND
options.defaultValueOBJECT应用参数默认值
options.allowAllValueBOOL应用参数是否允许任意值
options.datasetIdLONG应用参数值数据集id
options.valueFieldSTRING应用参数值字段名称
options.displayFieldSTRING应用参数显示值字段名称
options.displayValueSTRING应用参数显示值
options.multiValueConfigOBJECT应用参数多值配置
options.multiValueConfig.enableBOOL应用参开启多值
options.multiValueConfig.splitSTRING应用参数多值配置分隔符
options.multiValueConfig.quoteSTRING应用参数多值配置起止符
options.multiValueConfig.prefixSTRING应用参数多值配置前缀
options.multiValueConfig.suffixSTRING应用参数多值配置后缀

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT每种应用参数的共同结构见应用参数结构说明

接口示例1: 修改应用参数

http
PUT /api/apps/{appId}/params/{paramId} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "id": 5,
  "name": "test1",
  "appId": 19,
  "type": "number",
  "options": {
    "type": "number",
    "subType": "RANGE",
    "maxValue": 100,
    "minValue": 0,
    "defaultValue": 10,
    "allowAllValue": false,
    "intervalNum": 10
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 5,
    "name": "test1",
    "appId": 19,
    "options": {
      "type": "number",
      "subType": "RANGE",
      "maxValue": 100,
      "minValue": 0,
      "intervalNum": 10,
      "defaultValue": 10,
      "allowAllValue": false
    },
    "createdBy": 2,
    "createdAt": "2023-08-10 11:00:01",
    "updatedBy": 2,
    "updatedAt": "2023-08-10 11:22:50",
    "isDelete": false,
    "tags": {
    }
  }
}

3、删除应用参数

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的编辑者权限

请求URL

http
DELETE /api/apps/{appId}/params/{paramId} HTTP/1.1

请求参数

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值

接口示例1: 删除应用参数

http
DELETE /api/apps/{appId}/params/{paramId} HTTP/1.1
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

4、根据id获取应用参数

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的查看者权限

请求URL

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

请求参数

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT每种应用参数的共同结构见应用参数结构说明

接口示例1: 根据id获取应用参数

http
GET /api/apps/{appId}/params/{paramId} HTTP/1.1
Accept: 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": {
    "id": 5,
    "name": "test1",
    "appId": 19,
    "options": {
      "type": "number",
      "subType": "RANGE",
      "maxValue": 100,
      "minValue": 0,
      "intervalNum": 10,
      "defaultValue": 10,
      "allowAllValue": false
    },
    "createdBy": 2,
    "createdAt": "2023-08-10 11:00:01",
    "updatedBy": 2,
    "updatedAt": "2023-08-10 11:22:50",
    "isDelete": false,
    "tags": {}
  }
}

5、获取应用参数列表

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的查看者权限

请求URL

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

请求参数

URL 参数
字段类型是否必须说明
orderByString排序字段
queryAllParamsBOOLEAN查询图表使用到的全部应用参数,包含当前应用和数据包的参数,默认为false
excludeMultiBOOLEAN排除多值参数,默认为false

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT 数组每种应用参数的共同结构见应用参数结构说明

接口示例1: 获取应用参数列表

http
GET /api/apps/{appId}/params HTTP/1.1
Accept: 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": [
    {
      "id": 7,
      "name": "listTest",
      "appId": 19,
      "options": {
        "type": "string",
        "subType": "LIST",
        "valueSet": [
          {
            "value": "test1",
            "display": "t1"
          }
        ],
        "defaultValue": "test1",
        "displayValue": "t1",
        "allowAllValue": false
      },
      "createdBy": 2,
      "createdAt": "2023-08-10 11:15:10",
      "updatedBy": 2,
      "updatedAt": "2023-08-10 11:15:10",
      "isDelete": false,
      "extendAppTitle": "分析应用",
      "tags": {
      }
    },
    {
      "id": 6,
      "name": "test",
      "appId": 19,
      "options": {
        "type": "time",
        "subType": "RANGE",
        "maxValue": "2023-08-01 23:59:59",
        "minValue": "2023-01-01 00:00:00",
        "period": "SECOND",
        "granularity": "second",
        "defaultValue": "2023-02-01 10:00:00",
        "allowAllValue": false
      },
      "createdBy": 2,
      "createdAt": "2023-08-10 11:11:41",
      "updatedBy": 2,
      "updatedAt": "2023-08-10 11:11:41",
      "isDelete": false,
      "extendAppTitle": "分析应用",
      "tags": {
      }
    }
  ]
}

6、根据查询条件获取应用参数列表

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的查看者权限

请求URL

http
POST /api/apps/{appId}/params/query HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数
字段类型是否必须说明
idLONG应用参数id
appIdLONG应用id
nameSTRING应用参数名称
options.typeSTRING应用参数类型
options.subTypeSTRING应用参数允许值,支持:ALL,LIST,DYNAMIC,RANGE
options.datasetIdLONG应用参数应用参数值数据集id
updatedAtDATETIME应用参数最后更新时间
updatedByLONG应用参数最后修改者的userId
createdAtDATETIME应用参数创建时间
updatedByLONG应用参数最后修改者的userId
excludeMultiBOOLEAN排除多值参数
isDeleteBOOLEAN是否删除
appIdsLONG 数组应用参数id列表,查询多个应用下的参数

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT 数组每种应用参数的共同结构见应用参数结构说明

接口示例1: 根据查询条件获取应用参数列表

http
POST /api/apps/{appId}/params/query HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "name": "test1"
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": [
    {
      "id": 5,
      "name": "test1",
      "appId": 19,
      "options": {
        "type": "number",
        "subType": "RANGE",
        "maxValue": 100,
        "minValue": 0,
        "intervalNum": 10,
        "defaultValue": 10,
        "allowAllValue": false
      },
      "createdBy": 2,
      "createdAt": "2023-08-10 11:00:01",
      "updatedBy": 2,
      "updatedAt": "2023-08-10 14:11:20",
      "isDelete": false,
      "tags": {
      }
    }
  ]
}

7、查询引用了指定参数的资源

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的查看者权限

请求URL

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

请求参数

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT 数组引用参数的资源数组,目前包含全局参数控件、数据集、继承数据集、仪表盘、应用权限规则

接口示例1: 获取应用参数列表

http
GET /api/apps/19/params/5/referenced HTTP/1.1
Accept: 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": [
    {
      "name": "paramReference",
      "value": [
        {
          "name": "dashboard",
          "value": [
            {
              "uniqueFlag": "新建仪表盘 (1)",
              "appId": 19,
              "name": "新建仪表盘 (1)",
              "id": 2,
              "objectType": "dashboard"
            }
          ]
        }
      ]
    }
  ]
}

8、查询使用了指定参数的数据集

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的查看者权限

请求URL

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

请求参数

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT 数组每种数据集的共同结构见数据集结构说明

接口示例1: 获取应用参数列表

http
GET /api/apps/19/params/5/datasets HTTP/1.1
Accept: 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": [
    {
      "id": 1,
      "title": "movie",
      "createdBy": 2,
      "createdAt": "2023-08-07 11:48:10",
      "updatedBy": 2,
      "updatedAt": "2023-08-10 17:32:16",
      "visible": true,
      "isDelete": false,
      "appId": 19,
      "accessCount": 5,
      "lastAccessedAt": "2023-08-10 17:32:16",
      "options": {
        "cache": false,
        "type": "connection",
        "totalSize": 254,
        "rowCount": 1,
        "rowCountValid": true,
        "connectionTitle": "3381",
        "refreshHours": [
        ],
        "refreshMinute": 0,
        "connectionId": 4,
        "connectionCategory": "Database",
        "origin": "mysql",
        "table": "movie",
        "where": [
          {
            "op": "and",
            "args": [
              {
                "op": "=",
                "args": [
                  {
                    "op": "id",
                    "kind": "field",
                    "type": "number"
                  },
                  {
                    "op": "test1",
                    "kind": "param",
                    "type": "number"
                  }
                ],
                "kind": "function"
              }
            ],
            "kind": "function"
          }
        ],
        "path": [
          "qa"
        ],
        "transpose": false,
        "padHeader": false,
        "storageType": "mysql",
        "storageConnectionId": 4,
        "storageConnectionTitle": "3381",
        "schema": [
        ],
        "metrics": [
        ],
        "isFile": false
      },
      "importType": 0,
      "importStatus": 0,
      "status": 3,
      "isPublic": true,
      "includeInAppScope": false,
      "jobStatus": "SUCCESSFUL",
      "dataControl": true,
      "canPushToMemory": false,
      "schemaStale": false,
      "dataStale": false,
      "importSwitchable": false,
      "entityKey": "19-1",
      "entityGroup": "DATASET",
      "origin": "mysql",
      "type": "connection",
      "emptyDataset": false
    }
  ]
}

9、修改参数分组

  • 创建者需要拥有数据管理员数据分析员角色 且 需要为应用的创建者 或 拥有应用或应用所在目录的编辑者权限

请求URL

http
PUT /api/apps/{appId}/params/groups HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数

OBJECT数组,单个OBJECT结构如下:

字段类型是否必须说明
nameSTRING分组名称
childrenSTRING 数组分组中包含的参数id列表

返回对象的格式说明

字段类型说明
codeLONG返回码
msgSTRING返回码对应的信息
versionSTRING当前系统版本哈希值
dataOBJECT 数组分组数据,同Request Body

接口示例1: 修改应用参数

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

// Request Body:
[
  {
    "name": "分组1",
    "children": [
      5,
      6
    ]
  },
  {
    "name": "分组2",
    "children": [
      1,
      6
    ]
  }
]
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": [
    {
      "name": "分组1",
      "displayIndex": 0,
      "children": [
        "5",
        "6"
      ]
    },
    {
      "name": "分组2",
      "displayIndex": 0,
      "children": [
        "1",
        "6"
      ]
    }
  ]
}

HENGSHI SENSE API 使用手册