Skip to content

informat.user 用户操作

概述

使用informat.user对象进行用户信息操作


getUser

查询用户信息getUser

javascript
informat.user.getUser(id)
参数类型描述
idString用户ID

返回值 类型为 User 返回用户信息,如果用户不存在返回null

示例:

js
informat.user.getUser('zhangsan');
json
{
  "avatar": "pic10.png",
  "companyRoleList": [
    "admin",
    "tester"
  ],
  "departmentList": [
    "yanfabu",
    "yunyingbu"
  ],
  "id": "zhangsan",
  "leaderList": [
    "lisi"
  ],
  "name": "张三",
  "roleList": [
    "tester",
    "admin"
  ],
  "userInfo": {
    "age": 20
  }
}

getUserInfo

查询用户详细信息

javascript
informat.user.getUserInfo(id)
参数类型描述
idString用户ID

返回值 类型为 UserInfo 返回用户信息,如果用户不存在返回null

示例:

js
informat.user.getUserInfo('zhangsan');
json
{
  "avatar": "pic10.png",
  "companyRoleList": [
    "admin",
    "tester"
  ],
  "departmentList": [
    "yanfabu",
    "yunyingbu"
  ],
  "email": "zhangsan@informat.cn",
  "id": "zhangsan",
  "leaderList": [
    "lisi"
  ],
  "mobileNo": "19900000000",
  "name": "张三",
  "roleList": [
    "tester",
    "admin"
  ],
  "userInfo": {
    "age": 20
  },
  "userName": "zhangsan"
}

getUserList

根据用户ID列表查询用户列表

TIP

列表查询不返回用户扩展信息

javascript
informat.user.getUserList(idList)
参数类型描述
idListArray<String>用户ID列表

返回值 类型为Array<User> 返回用户列表

示例:

js
informat.user.getUserList(['zhangsan','lisi']);
json
[
  {
    "avatar": "pic10.png",
    "companyRoleList": [
      "admin",
      "tester"
    ],
    "departmentList": [
      "yanfabu",
      "yunyingbu"
    ],
    "id": "zhangsan",
    "leaderList": [
      "lisi"
    ],
    "name": "张三",
    "roleList": [
      "tester",
      "admin"
    ]
  }
]

getAppUserList

查询应用成员列表

TIP

需要注意的是这里不返回用户扩展信息

javascript
informat.user.getAppUserList()

返回值 类型为Array<User> 返回应用成员列表

示例:

js
informat.user.getAppUserList();
json
[
  {
    "avatar": "pic10.png",
    "companyRoleList": [
      "admin",
      "tester"
    ],
    "departmentList": [
      "yanfabu",
      "yunyingbu"
    ],
    "id": "zhangsan",
    "leaderList": [
      "lisi"
    ],
    "name": "张三",
    "roleList": [
      "admin"
    ]
  }
]

getUserByRoleList

根据应用角色查询用户列表

TIP

需要注意的是这里不返回用户扩展信息

javascript
informat.user.getUserByRoleList(['admin'])
参数类型描述
roleListArray<String>应用角色标识符列表

返回值 类型为Array<User> 返回用户列表

示例:

js
informat.user.getUserByRoleList('admin');
json
[
  {
    "avatar": "pic10.png",
    "companyRoleList": [
      "admin",
      "tester"
    ],
    "departmentList": [
      "yanfabu",
      "yunyingbu"
    ],
    "id": "zhangsan",
    "leaderList": [
      "lisi"
    ],
    "name": "张三",
    "roleList": [
      "admin"
    ]
  },
  {
    "avatar": "pic22.png",
    "companyRoleList": [
      "admin",
      "tester"
    ],
    "departmentList": [
      "yanfabu",
      "yunyingbu"
    ],
    "id": "lisi",
    "leaderList": [],
    "name": "李四",
    "roleList": [
      "admin"
    ]
  }
]

getUserByDeptList

根据部门查询用户列表

javascript
informat.user.getUserByDeptList(deptList)
参数类型描述
deptListArray<String>部门标识符列表

返回值 类型为Array<User> 返回用户列表

示例:

javascript
informat.user.getUserByDeptList(['yanfabu','yunyingbu']);
json
[
  {
    "avatar": "pic10.png",
    "companyRoleList": [
      "admin",
      "tester"
    ],
    "departmentList": [
      "yanfabu",
      "yunyingbu"
    ],
    "id": "zhangsan",
    "leaderList": [
      "lisi"
    ],
    "name": "张三",
    "roleList": [
      "admin"
    ]
  }
]

getSuperiorUsers

查询用户的直接上级

javascript
informat.user.getSuperiorUsers(userId)
参数类型描述
userIdString用户ID

返回值 类型为Array<User> 返回用户上级列表

示例:

js
informat.user.getSuperiorUsers('zhangsan');
json
[
  {
    "avatar": "pic22.png",
    "companyRoleList": [
      "admin",
      "tester"
    ],
    "departmentList": [
      "yanfabu",
      "yunyingbu"
    ],
    "id": "lisi",
    "leaderList": [],
    "name": "李四",
    "roleList": [
      "admin"
    ]
  }
]

getSubordinateUsers

查询用户的直接下属

javascript
informat.user.getSubordinateUsers(userId)
参数类型描述
userIdString用户ID

返回值 类型为Array<User> 返回用户下属列表

示例:

js
informat.user.getSubordinateUsers('lisi');
json
[
  {
    "avatar": "pic10.png",
    "companyRoleList": [
      "admin",
      "tester"
    ],
    "departmentList": [
      "yanfabu",
      "yunyingbu"
    ],
    "id": "zhangsan",
    "leaderList": [
      "lisi"
    ],
    "name": "张三",
    "roleList": [
      "tester",
      "admin"
    ]
  }
]

getLeaderOfDeptList

查询部门的负责人

javascript
informat.user.getLeaderOfDeptList(deptList)
参数类型描述
deptListArray<String>部门ID列表

返回值 类型为Array<User> 返回部门负责人列表

示例:

js
informat.user.getLeaderOfDeptList(['yunyingbu']);
json
[
  {
    "avatar": "pic14.png",
    "companyRoleList": [
      "admin"
    ],
    "departmentList": [
      "yunyingbu"
    ],
    "id": "l4cntsd6j16qv",
    "leaderList": [],
    "name": "大熊",
    "roleList": []
  }
]

getUserRoleList

查询应用角色列表

javascript
informat.user.getUserRoleList()

返回值 类型为Array<UserRole> 返回所有应用角色列表

示例:

js
informat.user.getUserRoleList();
json
[
  {
    "admin": true,
    "id": "admin",
    "isAdmin": true,
    "name": "管理员",
    "permissionList": []
  },
  {
    "admin": false,
    "id": "hrManager",
    "isAdmin": false,
    "name": "HR",
    "permissionList": [
      "AppAccess",
      "AppMember",
      "gkxv4nq60zdwm",
      "task_taskCustomPermission"
    ]
  }
]

addUser

添加用户到应用中

javascript
informat.user.addUser(userId,roleList)
参数类型描述
userIdString用户ID
roleListArray<String>应用角色列表

示例:将用户张三添加到应用中,并赋予管理员和测试两个角色

javascript
informat.user.addUser('zhangsan', ['admin','tester']);

updateUserRole

更新应用成员的角色

javascript
informat.user.updateUserRole(userId,roleList)
参数类型描述
userIdString用户ID
roleListArray<String>应用角色列表

示例:将用户张三的应用角色改为测试人员

javascript
informat.user.updateUserRole('zhangsan', ['tester']);

deleteUser

将用户从应用中移除

javascript
informat.user.deleteUser(userId)
参数类型描述
userIdString用户ID

示例:将用户张三从应用中移除

javascript
informat.user.deleteUser('zhangsan');