User
Overview
User-related operation functions under the current system
usersWithRole
Returns the list of users who have any role in the roleIdList
User.usersWithRole(roleIdList);| Parameter | Type | Description |
|---|---|---|
| roleIdList | Array<String> | Array of role identifiers |
Return Value
Type Array<String> Array of user IDs that have any role in roleIdList
Example
User.usersWithRole(["admin"]); //[user1, user2, user3]usersWithDepartment
Returns the list of users belonging to the departments in departmentIdList
User.usersWithDepartment(departmentIdList);| Parameter | Type | Description |
|---|---|---|
| departmentIdList | Array<String> | Array of department identifiers |
Return Value
Type Array<String> Returns the list of users belonging to the departments in departmentIdList
Example
User.usersWithDepartment(["yanfabu"]);superiorUsers
Returns the list of superiors for userId
User.superiorUsers(userId);| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID to query for superiors |
Return Value
Type Array<String> Array of superior user IDs
Example
User.superiorUsers("user1"); //[user2,user3]superiorUsersWithLevel
Returns the list of consecutive superiors for userId
User.superiorUsersWithLevel(userId, level);| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID to query for superiors |
| level | Integer | Number of superior levels to query |
Return Value
Type Array<String> Array of superior user IDs
Example
User.superiorUsersWithLevel(Context.userId(), 1);subordinateUsers
Returns the list of subordinates for userId
User.subordinateUsers(userId);| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID to query for subordinates |
Return Value
Type Array<String> Array of subordinate user IDs
Example
User.subordinateUsers("user1"); //[user2,user3]subordinateUsersWithLevel
Returns the list of consecutive subordinates for userId
User.subordinateUsersWithLevel(userId);| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID to query for subordinates |
Return Value
Type Array<String> Array of subordinate user IDs
Example
User.subordinateUsersWithLevel("user1", 2); //[user2,user3]leaderOfDept
Returns the list of department heads for a single department
User.leaderOfDept(departmentId);| Parameter | Type | Description |
|---|---|---|
| departmentId | String | Department ID |
Return Value
Type Array<String> Array of user IDs who are department heads
Example
User.leaderOfDept("dept1"); //[user2,user3]leaderOfDeptWithLevel
Returns the list of consecutive superior department heads
User.leaderOfDeptWithLevel(departmentId, level);| Parameter | Type | Description |
|---|---|---|
| departmentId | String | Department ID |
| level | Integer | Number of superior levels to query |
Return Value
Type Array<String> Returns the list of consecutive superior department heads
Example
User.leaderOfDeptWithLevel("yanfabu", 1);leaderOfDeptList
Returns the list of department heads for multiple departments
User.leaderOfDeptList(departmentIdList);| Parameter | Type | Description |
|---|---|---|
| departmentIdList | Array<String> | List of department IDs |
Return Value
Type Array<String> Array of user IDs who are department heads
Example
User.leaderOfDeptList(["dept1", "dept2"]); //[user2,user3,user4]parentOfDept
Returns the parent department ID of a department
User.parentOfDept(departmentId);| Parameter | Type | Description |
|---|---|---|
| departmentId | String | Department ID |
Return Value
Type String Parent department ID
Example
User.parentOfDept("dept1"); //dept2parentOfDeptList
Returns the list of parent department IDs for a department
User.parentOfDeptList(departmentId);| Parameter | Type | Description |
|---|---|---|
| departmentId | String | Department ID |
Return Value
Type Array<String> List of parent department IDs
Example
User.parentOfDept("dept1"); //['dept2','dept3']childrenOfDept
Returns the list of all subordinate departments for a single department
The department structure is a tree structure, and this interface will recursively return all child nodes in the tree structure under the specified department.
User.childrenOfDept(departmentId);| Parameter | Type | Description |
|---|---|---|
| departmentId | String | Department ID |
Return Value
Type Array<String> List of child department IDs
Example
User.childrenOfDept("dept1"); //[dept2,dept3]childrenOfDeptList
Returns the list of all subordinate departments for multiple departments
User.childrenOfDeptList(departmentList);| Parameter | Type | Description |
|---|---|---|
| departmentList | Array<String> | List of department IDs |
Return Value
Type Array<String> List of child department IDs
Example
User.childrenOfDeptList(["dept1", "dept2"]); //[dept2,dept3]directChildrenOfDept
Returns the list of direct subordinate departments
User.directChildrenOfDept(departmentId);| Parameter | Type | Description |
|---|---|---|
| departmentId | String | Department ID |
Return Value
Type Array<String> List of child department IDs
Example
User.directChildrenOfDept("dept1"); //[dept2]user
Returns user information
User.user(userId);| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID |
Return Value
Type User
Example
userInfo
Returns user information
User.userInfo(userId);| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID |
Return Value
Type UserInfo
Example
deptList
Returns the list of department information for departmentIdList
User.deptList(departmentIdList);| Parameter | Type | Description |
|---|---|---|
| departmentIdList | Array<String> | List of department IDs |
Return Value
Type Array<Dept>
Example
User.deptList(["dept1", "dept2"]);dept
Returns department information
User.dept(deptId);| Parameter | Type | Description |
|---|---|---|
| deptId | String | Department ID |
Return Value
Type Dept
Example
User.dept("dept1");
