Skip to content

用户属性

用户属性说明

用户属性的定义

由系统定义或用户自定义的用户扩展变量,可作为可变参数用于数据连接、链接权限、行权限、高级表达式等功能

用户属性结构说明

字段类型描述
idLONGid
nameSTRING属性名称
scopeSTRING用户属性作用范围:SYSTEM,INTERNAL,GLOBAL,SYSTEM为系统定义,用户不可添加或修改
openLevelSTRING用户属性开放级别:READ_ONLY,HIDDEN
updatedAtDATETIME用户属性最后更新时间
updatedByLONG用户属性最后修改者的userId
createdAtDATETIME用户属性创建时间
updatedByLONG用户属性最后修改者的userId
optionsOBJECT用户属性的配置信息
options.typeSTRING用户属性类型,支持:string,number,date,time,any
options.defaultValueOBJECT用户属性默认值,需与用户属性类型匹配,属性类型为any时可任意设置
options.allowAllValueBOOL用户属性是否允许任意值
options.multiValueConfigOBJECT用户属性多值配置
options.multiValueConfig.enableBOOL用户属性开启多值
options.multiValueConfig.splitSTRING用户属性多值配置分隔符
options.multiValueConfig.quoteSTRING用户属性多值配置起止符
options.multiValueConfig.prefixSTRING用户属性多值配置前缀
options.multiValueConfig.suffixSTRING用户属性多值配置后缀

用户属性使用说明

  1. 用户属性可用于连接权限或行权限的过滤
  2. 用户属性可用于表达式,使用格式为
  3. 若用户属性设置了默认值,且当前被含有用户属性的过滤限制了的登陆用户,没有专门为自身设置这个属性的具体值,则在过滤时会使用默认值
  4. 系统定义的用户属性的默认名称前缀为sys.,用户自定义属性不可以此前缀开头
  5. 用户属性创建后,名称不可再变更
  6. 系统定义的用户属性不可修改,其值为用户对应的信息,如登录名,邮箱等
  7. 用户属性作用范围说明:SYSTEM为系统定义,用户不可添加或修改;INTERNAL为内部属性,定义后只能在平台方或租户内部可用;GLOBAL为全局属性,平台方与租户方都可以使用,由平台方定义并为租户方赋值,属性值被所有对应的租户内所有用户继承,租户不可修改或删除。
  8. 开放级别为HIDDEN的用户属性只能用于数据连接,不可在应用中使用。
  9. 开放级别为HIDDEN的平台方全局用户属性,对租户方不可见。
  10. 作用范围为GLOBAL的全局属性,在租户方有三个可取值的点:属性默认值(attr.defaultValue)、平台方为租户设置的值(tenant.platformConfig)、租户内用户通过sso登陆同步的值(user.platformConfig),取值优先级为:user.platformConfig>tenant.platformConfig>attr.defaultValue

接口说明

创建用户属性

创建用户属性。

请求URL

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

请求参数

request body 参数

用户属性结构说明

返回对象的格式说明

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

接口示例1: 创建用户属性

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

// Request Body:
{
  "name": "数字属性",
  "scope": "INTERNAL",
  "openLevel": "READ_ONLY",
  "options": {
    "type": "number",
    "multiValueConfig": {
      "enable": false,
      "split": ",",
      "quote": "",
      "prefix": "",
      "suffix": ""
    },
    "defaultValue": 8
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "name": "数字属性",
    "scope": "INTERNAL",
    "options": {
      "type": "number",
      "defaultValue": 8,
      "allowAllValue": true,
      "multiValueConfig": {
        "enable": false,
        "split": ",",
        "quote": "",
        "prefix": "",
        "suffix": ""
      }
    },
    "createdBy": 2,
    "createdAt": "2023-08-10 18:46:36",
    "updatedBy": 2,
    "updatedAt": "2023-08-10 18:46:36",
    "openLevel": "READ_ONLY"
  }
}

接口示例2: 创建用户属性

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

// Request Body:
{
  "name": "任意属性",
  "scope": "INTERNAL",
  "openLevel": "READ_ONLY",
  "options": {
    "type": "any",
    "multiValueConfig": {
      "enable": false,
      "split": ",",
      "quote": "",
      "prefix": "",
      "suffix": ""
    },
    "defaultValue": "[\"值1\",\"值2\"]"
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 3,
    "name": "任意属性",
    "scope": "INTERNAL",
    "options": {
      "type": "any",
      "defaultValue": "[\"值1\",\"值2\"]",
      "allowAllValue": true,
      "multiValueConfig": {
        "enable": false,
        "split": ",",
        "quote": "",
        "prefix": "",
        "suffix": ""
      }
    },
    "createdBy": 2,
    "createdAt": "2023-08-10 18:48:57",
    "updatedBy": 2,
    "updatedAt": "2023-08-10 18:48:57",
    "openLevel": "READ_ONLY"
  }
}

修改用户属性

修改用户属性。

说明

  • 若用户属性已在使用,则修改属性类型可能导致使用了该用户属性的资源出现数据异常

请求URL

http
PUT /api/users/attrs/{attrId} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型是否必须说明
attrIdLONG被修改用户属性的 id
request body 参数

用户属性结构说明

返回对象的格式说明

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

接口示例1: 修改用户属性

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

// Request Body:
{
  "id": 2,
  "name": "数字属性",
  "scope": "GLOBAL",
  "editable": true,
  "options": {
    "type": "number",
    "defaultValue": 9,
    "allowAllValue": true,
    "multiValueConfig": {
      "enable": false,
      "split": ",",
      "quote": "",
      "prefix": "",
      "suffix": ""
    }
  },
  "openLevel": "READ_ONLY",
  "valueSet": [
  ],
  "isMultiValue": false,
  "isAttr": true
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "name": "数字属性",
    "scope": "GLOBAL",
    "editable": true,
    "options": {
      "type": "number",
      "defaultValue": 9,
      "allowAllValue": true,
      "multiValueConfig": {
        "enable": false,
        "split": ",",
        "quote": "",
        "prefix": "",
        "suffix": ""
      }
    },
    "createdBy": 2,
    "createdAt": "2023-08-10 18:46:36",
    "updatedBy": 2,
    "updatedAt": "2023-08-10 18:54:23",
    "isDelete": false,
    "openLevel": "READ_ONLY"
  }
}

删除用户属性

删除用户属性

说明

  • 若用户属性已在使用,则删除可能导致使用了该用户属性的资源出现数据异常

请求URL

http
DELETE /api/users/attrs/{attrId} HTTP/1.1
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型是否必须说明
attrIdLONG被删除用户属性的id

返回对象的格式说明

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

接口示例1: 删除用户

http
DELETE /api/users/attrs/2 HTTP/1.1
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

获取用户属性列表

请求URL

http
GET /api/users/attrs?offset=0&limit=1000&queryValueSet=true HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数

| 字段 | 类型 |是否必须| 说明 | |---------------|------- --|-------|------------------------------------| | offset | INTEGER | 可选 | 分页偏移量,默认是0 | | limit | INTEGER | 可选 | 分页获取个数,默认是10 | | queryValueSet | BOOLEAN | 可选 | 是否要获取每条属性在设置了该属性的所有用户中的distinct值列表 |

返回对象的格式说明

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

接口示例1: 获取用户属性列表

http
GET /api/users/attrs?offset=0&limit=1000&queryValueSet=true 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": "sys.email",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "string",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        "anonymous@hengshi.com"
      ]
    },
    {
      "name": "sys.id",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "number",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        2
      ]
    },
    {
      "name": "sys.language",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "string",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        "zh_CN"
      ]
    },
    {
      "name": "sys.loginName",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "string",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        "admin"
      ]
    },
    {
      "name": "sys.mobile",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "string",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": []
    },
    {
      "name": "sys.name",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "string",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        "admin"
      ]
    },
    {
      "name": "sys.org_ids",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "any",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        []
      ]
    },
    {
      "name": "sys.org_names",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "any",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        []
      ]
    },
    {
      "name": "sys.organization_ids",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "any",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        []
      ]
    },
    {
      "name": "sys.organization_names",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "any",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": [
        []
      ]
    },
    {
      "name": "sys.tenant_code",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "string",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": []
    },
    {
      "name": "sys.tenant_id",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "number",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": []
    },
    {
      "name": "sys.tenant_name",
      "scope": "SYSTEM",
      "editable": false,
      "options": {
        "type": "string",
        "allowAllValue": true
      },
      "openLevel": "READ_ONLY",
      "valueSet": []
    },
    {
      "id": 3,
      "name": "任意属性",
      "scope": "INTERNAL",
      "editable": true,
      "options": {
        "type": "any",
        "defaultValue": "[\"值1\",\"值2\"]",
        "allowAllValue": true,
        "multiValueConfig": {
          "enable": false,
          "split": ",",
          "quote": "",
          "prefix": "",
          "suffix": ""
        }
      },
      "createdBy": 2,
      "createdAt": "2023-08-10 18:48:57",
      "updatedBy": 2,
      "updatedAt": "2023-08-10 18:48:57",
      "isDelete": false,
      "openLevel": "READ_ONLY",
      "valueSet": []
    },
    {
      "id": 1,
      "name": "属性1",
      "scope": "INTERNAL",
      "editable": true,
      "options": {
        "type": "string",
        "defaultValue": [
          "啊"
        ],
        "allowAllValue": true,
        "multiValueConfig": {
          "enable": true,
          "split": ",",
          "quote": "`",
          "prefix": "(",
          "suffix": ")"
        }
      },
      "createdBy": 2,
      "createdAt": "2023-08-10 18:30:57",
      "updatedBy": 2,
      "updatedAt": "2023-08-10 18:35:28",
      "isDelete": false,
      "openLevel": "READ_ONLY",
      "valueSet": []
    }
  ],
  "totalHits": 15,
  "offset": 0,
  "chartDataStartTimeMillis": 0
}

根据ID获取用户属性

请求URL

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

请求参数

URL 参数
字段类型是否必须说明
attrIdLONG用户属性的 id

返回对象的格式说明

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

接口示例1: 根据ID获取用户属性

http
GET /api/users/attrs/4 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": 4,
    "name": "test",
    "scope": "INTERNAL",
    "editable": true,
    "options": {
      "type": "string",
      "defaultValue": "aaa",
      "allowAllValue": true,
      "multiValueConfig": {
        "enable": false,
        "split": ",",
        "quote": "",
        "prefix": "",
        "suffix": ""
      }
    },
    "createdBy": 2,
    "createdAt": "2023-08-11 10:13:27",
    "updatedBy": 2,
    "updatedAt": "2023-08-11 10:13:27",
    "isDelete": false,
    "openLevel": "READ_ONLY"
  }
}

HENGSHI SENSE API 使用手册