Skip to content

用户

用户说明

用户的定义

HENGSHI 系统内的用户及 SSO 认证后自动创建用户,主要信息由登录名、邮箱、姓名、手机号码、用户属性等组成。 如果在系统中通过api创建了用户,再使用 SSO 认证是可以自动关联用户的。如: 通过api创建了用户loginName=demoTest,当通过 SSO 认证时的loginName也是demoTest,那么不会再自动创建用户, 而是将以demoTest的身份进行登录。关联的优先级是loginName,email,mobile。

用户结构说明

字段类型是否必须描述
idLONGid
loginNameSTRINGloginName,email不能同时为空登录名,企业内不能重复。
emailSTRINGloginName,email不能同时为空邮箱,企业内不能重复。
passwordSTRING重置密码时使用,填写当前登录用户的密码公钥加密密码,用base64格式进行编码。重置密码时验证当前用户身份的验证字段。
newPasswordSTRING不使用密码登录时可以不设置公钥加密密码,用base64格式进行编码。填写需保存的用户密码。
uuidSTRING公钥对应的uuid解密使用。
mobileSTRING手机,企业内不能重复。
nameSTRING显示名称(昵称)
userTypeSTRING默认为internal,可选值:internal,ldap,cas,oauth2,saml2,dingtalk,wechat-work,ctr,yunzhijia,jwt-param,lark
descriptionSTRING用户备注
avatarSTRING用户头像
rolesJSON 数组角色
roles[].idLONG角色id
organizationsJSON 数组用户组
organizations[].idLONG用户组id
orgsJSON 数组用户组织架构
orgs[].idLONG用户组织架构id
platformConfigJSON用户通过sso方式登陆同步的全局属性
configJSON用户属性,其内容为自定义的用户属性,如:{"school":"a","grade":3}
resetPasswordBOOLEAN用户登录以后是否需要重置密码。管理员重置用户密码时,不支持 API 更新该字段

config字段说明:

  1. 用户可以在页面创建用户属性并赋值。

  2. 用户可以通过api调用传递用户属性,需要以用户结构说明中的config,如:

    {
       "loginName":"demoUser001",
       "config":{
           "text":"a",
           "number":1,
           "array":[
               "test1"
           ]
       }
    }
  3. oauth,jwt认证方式登录时会将除登录名,用户名,邮箱,手机,角色以外的json字段自动封装成用户属性,如下json,会将school、grade封装成用户属性,保存到用户的config字段。

    json
    {
        "loginName":"loginName",//登录名映射
        "email":"email",//邮箱映射
        "mobile":"mobile",//手机映射
        "name":"name",//用户名映射
        "school":"a",//用户属性
        "grade":3 //用户属性
    }
  4. 钉钉,企业微信,云之家,飞书认证方式登录时会将除登录名,用户名,邮箱,手机,角色以外的json自动封装成用户属性。具体的用户信息由 钉钉企业微信云之家飞书 接口返回,请参考官方文档。

角色结构说明

字段类型是否必须描述
idLONGid
nameSTRING角色名称
descriptionSTRING角色描述

角色是系统内置数据,不可更新, 系统内角色有:

name角色
system admin系统管理
data admin数据管理
data analyst数据分析
data viewer数据查看
api adminAPI 管理员

用户组结构说明

字段类型是否必须描述
idLONGid
nameSTRING名称
emailSTRING邮箱
descriptionSTRING用户组备注
usersJSON 数组用户
users[].idLONG角色id

接口说明

获取角色列表

获取角色列表。

请求URL

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

请求参数

URL 参数

request body 参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT角色结构说明

接口示例1: 获取角色列表

http
GET /api/users/roles 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,
         "name":"system admin",
         "description":"system admin"
      },
      {
         "id":2,
         "name":"data admin",
         "description":"data admin"
      },
      {
         "id":3,
         "name":"data analyst",
         "description":"data analyst"
      },
      {
         "id":4,
         "name":"data viewer",
         "description":"data viewer"
      },
      {
         "id":5,
         "name":"api admin",
         "description":"api admin"
      }
   ]
}

创建用户

创建用户。

请求URL

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

请求参数

URL 参数

request body 参数

用户结构说明密码加密

说明

用户属性需要放在config字段中传递

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
data.idLONG用户的 id

用户默认头像

avatar

接口示例1: 创建用户(完整信息)

包含基本完整的用户信息,创建成功以后,用户可以根据登录名和密码登录。使用场景多为预先创建,配置用户,使用用户名/密码方式登录使用系统。

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

// Request Body:
{
  "loginName":"demoUser001",
  "name":"demoUser001",
  "email":"anonymous@hengshi.com",
  "newPassword":"duk5ZIVdikKtU9txy0aMZlLPJ8hntpINLx2hBWiJw8sYfSxSQ/pkSBRv85s/ROQb45J4R8MsCrN7VQkhONMoGQ==",
  "description":"desc",
  "uuid":"488b4801-1f50-4694-b0e1-7bd8fea4869f",
  "roles":[
      {
          "id":3
      },
      {
          "id":4
      },
      {
          "id":2
      }
  ],
  "config":{
    "text":"a",
    "number":1,
    "array":["test1"]
  },
  "organizations":[
      {
          "id":25
      }
  ],
  "orgs":[
    {
        "id":25
    }
  ],
  "avatar":"..."
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

接口示例2: 创建用户(必要信息)

只包含必要的用户信息,使用场景多为预先创建,根据需要配置用户角色(roles),用户属性(config)等,之后使用其他的认证方式(如单点登录,jwt等)登录使用系统。

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

// Request Body:
{
   "loginName": "13333333333",
   "roles": [
      {
         "id": 1
      }
   ]
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

管理员修改用户

管理员修改用户。

请求URL

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

请求参数

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

用户结构说明密码加密

说明

用户属性需要放在config字段中传递

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值

修改用户属性说明

若在更新用户时通过config修改用户属性,则需要传被修改用户的全量属性,该修改为直接覆盖,没有传的属性都会被置空

重制密码说明

4.1版本以后该接口不再支持修改密码功能,可调用管理员重置用户密码 4.3版本以后该接口不再支持启用/禁用用户,可调用管理员启用/停用用户

接口示例1: 修改用户

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

// Request Body:
{
  "enable":true,
  "description":"desc",
  "roles":[
      {
          "id":2
      },
      {
          "id":3
      },
      {
          "id":4
      }
  ],
  "config":{
      "text":"a",
      "number":1,
      "array":["test1"]
  },
  "organizations":[
      {
          "id":25
      }
  ],
  "orgs":[
    {
        "id":25
    }
  ]
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

接口示例2: 修改用户(用户属性)

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

// Request Body:
{
  "description": "",
  "uuid": "ab999a4c-3c79-4de2-9e96-d26a814c3d70",
  "config": {
    "a1": "测试",
    "a2": [
      "测试1","测试2"
    ],
    "t": "2020-07-23 16:11:00",
    "n": 1
  },
  "roles": [
    {
      "id": 1
    },
    {
      "id": 2
    },
    {
      "id": 3
    },
    {
      "id": 4
    }
  ],
  "organizations": [
    {
      "id": 2
    }
  ]
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

管理员重置用户密码

管理员重置用户密码。

请求URL

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

请求参数

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

用户结构说明密码加密

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值

接口示例1: 管理员重置密码

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

// Request Body:
{
  "password": "UEDK5yrm3xswER2JgWvMELLR3aETo76qKBOg5PW/4pDsP9270a+mYE5kkWXFfHYUqiZtPsC4Apumis3BG3oUlw==",
  "newPassword": "asxasdfweswER2JgWvMELLR3aETo76qKBOg5PW/4pDsP9270a+mYE5kkWXFfHYUqiZtff234141aaaaa====",
  "uuid": "68a5d0c6-5a33-45d6-833a-9b70c961a77a"
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

管理员启用/停用用户

管理员启用/停用用户。

请求URL

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

请求参数

URL 参数
request body 参数
字段类型是否必须说明
enableBOOLEAN启用:true,停用:false
usersJSON数组用户数组
users[].idLONG用户id

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值

接口示例1: 管理员启用、停用用户

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

// Request Body:
{
   "users":[
      {
         "id":26
      }
   ],
   "enable":false
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

用户自行修改帐号信息

用户自行修改帐号信息

请求URL

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

请求参数

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

用户结构说明密码加密

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值

用户可修改的信息

通过该接口用户可修改用户的名称,头像,密码,使用语言

修改密码说明

若调用该接口修改用户密码,与管理员修改接口不同的时,该密码就直接作为用户登陆密码使用,无需再次被强制要求修改

不可同时更改多项信息

名称,头像,密码,使用语言一次调用只能修改其中一项,若四个参数都传,则按照密码>头像>名称>使用语言的顺序修改其中一项

接口示例1: 修改用户名称

http
PUT /api/users/account/{userId} 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"
}

接口示例2: 修改密码

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

// Request Body:
{
  "uuid": "7a292f10-9db4-4d7a-b8cb-f29fdfb86e58",
  "password": "QziD1WxdWSJjAdsx0YrRnOxItgPVoZNNAQVsz0X4/rzNehqtPxtcaWU7UQD2N4dIvDkfhxv/0EUjLL3BssoRtw==",
  "newPassword": "P5vmmFYGYRsasXx0/v3LauKN041OipE19xAPP+AKGDrNwkITzDlw5q0GFoy5jwH7tld8a3GJbvAZg9fqz1Pb+w=="
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

接口示例3: 修改头像

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

// Request Body:
{
  "avatar": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE"
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

接口示例4: 修改使用语言

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

// Request Body:
{
  "options": {
    "language": "en-US"
  }
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

用户是否持有可用资源

说明

用户是否持有可用资源

请求URL

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

请求参数

URL Path 参数
字段类型是否必须说明
userIdLONG修改用户的 id

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataBOOLEAN用户是否持有可用资源

接口示例1: 用户是否持有可用资源

http
GET /api/users/{userId}/available-resources 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,
   "data": true,
  "msg": "success"
}

删除用户

说明

  • 若用户拥有任意未删除或转移给其他用户的资源(应用、链接、数据集成、数据科学),则不可删除用户

请求URL

http
DELETE /api/users/{userId} HTTP/1.1

请求参数

URL 参数
字段类型是否必须说明
userIdLONG修改用户的 id

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例1: 删除用户

http
DELETE /api/users/{userId} HTTP/1.1
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

通过id查询用户

请求URL

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

请求参数

URL Path 参数
字段类型是否必须说明
idLong用户的 id
request body 参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例:

http
GET /api/users/details/{userId} 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": 2,
    "name": "helloa",
    "email": "helloa@163.com",
    "description": "",
    "avatar": "",
    "enable": true,
    "createdAt": "2019-11-15 15:18:36",
    "lastLoginAt": "2020-09-16 11:49:38",
    "userType": "internal",
    "isDelete": false,
    "loginName": "hello"
  }
}

通过loginName查询用户

请求URL

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

请求参数

URL 参数

request body 参数
字段类型是否必须说明
loginNameSTRING用户的 loginName

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例:

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

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

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "name": "helloa",
    "email": "helloa@163.com",
    "description": "",
    "avatar": "",
    "enable": true,
    "createdAt": "2019-11-15 15:18:36",
    "lastLoginAt": "2020-09-16 11:49:38",
    "userType": "internal",
    "isDelete": false,
    "loginName": "hello"
  }
}

通过email查询用户

请求URL

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

请求参数

URL 参数

request body 参数
字段类型是否必须说明
emailSTRING用户的 email

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例:

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

// Request Body:
{
  "email": "helloa@163.com"
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "name": "helloa",
    "email": "helloa@163.com",
    "description": "",
    "avatar": "",
    "enable": true,
    "createdAt": "2019-11-15 15:18:36",
    "lastLoginAt": "2020-09-16 11:49:38",
    "userType": "internal",
    "isDelete": false,
    "loginName": "hello"
  }
}

通过mobile查询用户

请求URL

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

请求参数

URL 参数

request body 参数
字段类型是否必须说明
mobileSTRING用户的 email

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例:

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

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

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "name": "helloa",
    "email": "helloa@163.com",
    "description": "",
    "avatar": "",
    "mobile": "13012344321",
    "enable": true,
    "createdAt": "2019-11-15 15:18:36",
    "lastLoginAt": "2020-09-16 11:49:38",
    "userType": "internal",
    "isDelete": false,
    "loginName": "hello"
  }
}

通过用户id获取用户组和组织机构

请求URL

http
GET /api/users/orgs-organizations?userId={userId} HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数

request Query 参数
字段类型是否必须说明
userIdLONG用户的 id

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT包含用户组和树形组织架构
data.organizationsJSONOBJECT ARRAY用户组结构说明
data.orgTreeJSONOBJECT组织结构说明
data.orgTree.childrenJSONOBJECT下级组织,见组织结构说明

接口示例:通过用户id获取用户组和组织机构

http
GET /api/users/orgs-organizations?userId={userId} 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":{
      "organizations":[
         {
            "id":6431,
            "name":"API用户组",
            "description":"API用户组",
            "category":"NORMAL"
         }
      ],
      "orgTree":[
         {
            "id":1,
            "name":"衡石QA测试",
            "description":"",
            "createdBy":11630,
            "createdAt":"2023-07-12 15:23:48",
            "updatedBy":11630,
            "updatedAt":"2023-07-12 15:23:48",
            "source":"dingtalk",
            "code":"1",
            "orderNo":1,
            "children":[
               {
                  "id":25,
                  "name":"测试部",
                  "description":"",
                  "createdBy":11630,
                  "createdAt":"2023-07-12 15:23:48",
                  "updatedBy":11630,
                  "updatedAt":"2023-07-12 15:23:48",
                  "parentId":1,
                  "source":"dingtalk",
                  "code":"490184122",
                  "parentCode":"1",
                  "orderNo":3,
                  "delete":false
               }
            ],
            "delete":false
         }
      ]
   }
}

通过 loginName 或者 email 查询用户(不推荐使用),4.5之后的版本将不再支持

请参考 通过loginName查询用户 通过email查询用户 通过mobile查询用户

请求URL

http
GET /api/users/by-unique-key/{loginName or email} HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型是否必须说明
loginName or emailSTRING用户的 loginName 或者 email

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例: 通过 loginName 或者 email 查询用户(不推荐使用)

http
GET /api/users/by-unique-key/{loginName or email} HTTP/1.1
Accept: application/json

// Response:
{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "name": "helloa",
    "email": "helloa@163.com",
    "description": "",
    "avatar": "",
    "enable": true,
    "createdAt": "2019-11-15 15:18:36",
    "lastLoginAt": "2020-09-16 11:49:38",
    "userType": "internal",
    "isDelete": false,
    "loginName": "hello"
  }
}

获取用户列表

请求URL

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

请求参数

Query 参数
字段类型是否必须说明
returnAvatarBOOLEAN是否返回用户头像,默认为true
returnAttrBOOLEAN是否返回用户头像,默认为false
qSTRING用户显示名或登录名(like查询)
organizationsLONG用户组id
rolesLONG用户角色id
offsetINT分页偏移量
limitINT分页大小

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

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

http
GET /api/users?offset=0&limit=100&q=test&roles=1&roles=2 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": 2,
      "name": "test2",
      "email": "anonymous@hengshi.com",
      "description": "",
      "avatar": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAADAFBMVEXw8PAmstgA51gGMdj3GfUAAAAASUVORK5CYII=",
      "enable": true,
      "userType": "internal",
      "loginName": "test2",
      "config": {
        "sys.email": {
          "source": "SYSTEM_DEFINED",
          "value": "anonymous@hengshi.com",
          "type": "string"
        },
        "sys.login_name": {
          "source": "SYSTEM_DEFINED",
          "value": "test2",
          "type": "string"
        },
        "sys.mobile": {
          "source": "SYSTEM_DEFINED",
          "type": "string"
        },
        "sys.id": {
          "source": "SYSTEM_DEFINED",
          "value": 2,
          "type": "number"
        },
        "sys.loginName": {
          "source": "SYSTEM_DEFINED",
          "value": "test2",
          "type": "string"
        },
        "m_names": {
          "source": "USER_DEFINED",
          "value": [
            "盗梦空间",
            "搏击俱乐部"
          ],
          "type": "any"
        },
        "sys.name": {
          "source": "SYSTEM_DEFINED",
          "value": "test2",
          "type": "string"
        },
        "n_name": {
          "source": "USER_DEFINED",
          "value": "饮食男女",
          "type": "any",
          "defaultValue": "搏击俱乐部"
        }
      },
      "options": {},
      "roles": [
        {
          "id": 1,
          "name": "system admin",
          "description": "system admin"
        },
        {
          "id": 2,
          "name": "data admin",
          "description": "data admin"
        },
        {
          "id": 3,
          "name": "data analyst",
          "description": "data analyst"
        },
        {
          "id": 4,
          "name": "data viewer",
          "description": "data viewer"
        }
      ],
      "organizations": []
    },
    {
      "id": 9,
      "name": "test4",
      "email": "anonymous@hengshi.com",
      "description": "",
      "avatar": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAADAFBMVEXw8PAm2JAAm7YIceE7dPMAAAAASUVORK5CYII=",
      "enable": true,
      "userType": "internal",
      "loginName": "test4",
      "config": {
        "sys.email": {
          "source": "SYSTEM_DEFINED",
          "value": "anonymous@hengshi.com",
          "type": "string"
        },
        "sys.login_name": {
          "source": "SYSTEM_DEFINED",
          "value": "test4",
          "type": "string"
        },
        "sys.mobile": {
          "source": "SYSTEM_DEFINED",
          "type": "string"
        },
        "sys.id": {
          "source": "SYSTEM_DEFINED",
          "value": 9,
          "type": "number"
        },
        "sys.loginName": {
          "source": "SYSTEM_DEFINED",
          "value": "test4",
          "type": "string"
        },
        "sys.name": {
          "source": "SYSTEM_DEFINED",
          "value": "test4",
          "type": "string"
        }
      },
      "options": {},
      "roles": [
        {
          "id": 1,
          "name": "system admin",
          "description": "system admin"
        },
        {
          "id": 2,
          "name": "data admin",
          "description": "data admin"
        },
        {
          "id": 3,
          "name": "data analyst",
          "description": "data analyst"
        },
        {
          "id": 4,
          "name": "data viewer",
          "description": "data viewer"
        }
      ],
      "organizations": []
    }
  ]
}

获取用户简单信息列表

请求URL

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

请求参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例1: 获取用户简单信息列表

http
GET /api/users/simplify 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": 2,
      "name": "test2",
      "loginName": "test2",
       "email":"anonymous@hengshi.com"
    }
  ]
}

获得可被授权的用户列表

请求URL

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

请求参数

URL Query 参数
字段类型是否必须说明
actSTRING授权类型,可选值:collaborate(协作),publish(发布)
resourceSTRING资源类型,可选值:app(应用),connection(链接)

说明

  1. 资源类型为connection时,授权类型不可为publish
  2. 当条件为app&collaborate时,返回的时系统中拥有数据分析角色的用户
  3. 当条件为app&publish时,返回的时系统中拥有数据查看角色的用户
  4. 当条件为connection&collaborate时,返回的时系统中拥有数据分析数据管理角色的用户

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT用户结构说明

接口示例1: 获得可被授权的用户列表

http
GET /api/users/grantors?act=collaborate&resource=app 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": 41,
      "name": "test",
      "email": "anonymous@hengshi.com",
      "description": "",
      "enable": true,
      "loginName": "test",
      "config": {},
            "options": {}
        },
        {
            "id": 2,
            "name": "test2",
            "email": "anonymous@hengshi.com",
            "description": "",
            "enable": true,
            "loginName": "test2",
            "config": {
                "m_names": "[\"盗梦空间\",\"搏击俱乐部\"]",
                "n_name": "饮食男女"
            },
            "options": {}
        },
        {
            "id": 9,
            "name": "test4",
            "email": "anonymous@hengshi.com",
            "description": "",
            "enable": true,
            "loginName": "test4",
            "config": {},
            "options": {}
        }
    ]
}

新增用户组

新增用户组。

请求URL

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

请求参数

URL 参数

request body 参数

用户组结构说明

返回对象的格式说明

用户组结构说明

接口示例1: 新增用户组

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

// Request Body:
{
    "name":"zjj_group",
    "email":"anonymous@hengshi.com",
    "description":"desc",
    "users":[
        {
            "id":800
        }
    ]
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
    "version": "version@9a5e106#6730f0d",
    "code":0,
    "msg":"success",
    "data":{
        "id":36,
        "name":"zjj_group",
        "email":"anonymous@hengshi.com",
        "description":"desc",
        "createdBy":1,
        "createdAt":"2019-12-18 20:44:47",
        "updatedBy":1,
        "updatedAt":"2019-12-18 20:44:47",
        "users":[
            {
                "id":800,
                "userAttributes":{
                    "sys.id":800
                }
            }
        ]
    }
}

获取用户组列表

请求URL

http
GET /api/organizations HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT参数的共同结构见用户组结构说明

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

http
GET /api/organizations 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,
      "name": "ALL_USERS",
      "description": "System organization for all users",
      "category": "ALL_USERS",
      "userCount": 0,
      "users": []
    },
    {
      "id": 3,
      "name": "o4",
      "description": "",
      "category": "NORMAL",
      "userCount": 0,
      "users": []
    },
    {
      "id": 4,
      "name": "o42",
      "description": "",
      "category": "NORMAL",
      "userCount": 0,
      "users": []
    },
    {
      "id": 2,
      "name": "o1",
      "description": "",
      "category": "NORMAL",
      "userCount": 0,
      "users": []
    }
  ]
}

根据ID获取用户组

请求URL

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

请求参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT参数的共同结构见用户组结构说明

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

http
GET /api/organizations/2 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": 2,
    "name": "o1",
    "description": "",
    "category": "NORMAL",
    "userCount": 2,
    "users": [
      {
        "id": 2,
                "name": "test2",
                "email": "anonymous@hengshi.com",
                "description": ""
            },
            {
                "id": 9,
                "name": "test4",
                "email": "anonymous@hengshi.com",
                "description": ""
            }
        ]
    }
}

修改用户组

修改用户组。

请求URL

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

请求参数

URL 参数
字段类型是否必须说明
organizationIdLONG修改用户组的 id
request body 参数

用户组结构说明

返回对象的格式说明

用户组结构说明

接口示例1: 修改用户组

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

// Request Body:
{
    "name":"zjj_group",
    "email":"anonymous@hengshi.com",
    "description":"desc",
    "users":[
        {
            "id":800
        }
    ]
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
    "version": "version@9a5e106#6730f0d",
    "code":0,
    "msg":"success",
    "data":{
        "id":36,
        "name":"zjj_group",
        "email":"anonymous@hengshi.com",
        "description":"desc",
        "updatedBy":1,
        "updatedAt":"2019-12-18 20:46:51",
        "users":[
            {
                "id":800,
                "userAttributes":{
                    "$user.config.id":800,
                    "$user.id":800
                }
            }
        ]
    }
}

删除用户组

删除用户组。

请求URL

http
DELETE /api/organizations/{organizationId} HTTP/1.1

请求参数

URL 参数
字段类型是否必须说明
organizationIdLONG修改用户组的 id
request body 参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值

接口示例1: 删除用户组

http
DELETE /api/organizations/${organizationId} HTTP/1.1
http
HTTP/1.1 200 Ok
Content-Type: application/json

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

HENGSHI SENSE API 使用手册