GenAuth DocsDocuments
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Old version
  • Single Page Web Application

  • Mobile and Client Applications

  • Standard Web Application

    • Java

    • Node.js

      • Installation and Usage
      • User Authentication Module
      • Management Module

        • User Management

          • Get User Information
          • Batch Get User Information
          • Get User List
          • Get User External Identity Sources
          • Get User Role List
          • Get User Real-name Authentication Information
          • Delete User Real-name Authentication Information
          • Get User Department List
          • Set User Departments
          • Get Group List
          • Delete Users
          • Get User MFA Binding Information
          • Get Archived User List
          • Force User Logout
          • Check if User Exists
          • Create User
          • Batch Create Users
          • Update User Profile
          • Get User Accessible Applications
          • Get User Authorized Applications
          • Check if User Has Role
          • Get User Login History
          • Get Applications User Has Logged Into
          • Get Identity Sources User Has Logged Into
          • Get All Resources Authorized to User
        • Group Management

        • Role Management

        • Organization Management

        • 访问控制管理

        • 外部身份源管理

        • 自定义字段管理

    • Python

  • Framework Integration

  • Others

  1. Development Integration
  2. /
  3. Standard Web Application
  4. /
  5. Node.js
  6. /
  7. Management Module

  8. /
  9. User Management

  10. /
  11. Get User Department List

¶ 获取用户部门列表

Update time: 2025-07-23 07:34:21
Edit

通过用户 ID,获取用户部门列表,支持分页,可以选择获取自定义数据、选择指定用户 ID 类型、增序或降序等。

¶ 请求参数

名称类型必填默认值描述示例值
userIdstring是-用户 ID。6229ffaxxxxxxxxcade3e3d9
userIdTypestring否user_id用户 ID 类型,可以指定为用户 ID、手机号、邮箱、用户名和 externalId。。 枚举值:user_id,external_id,phone,email,usernameuser_id
pagenumber否1当前页数,从 1 开始。1
limitnumber否10每页数目,最大不能超过 50,默认为 10。10
withCustomDataboolean否-是否获取自定义数据。true
sortBystring否JoinDepartmentAt排序依据,如 部门创建时间、加入部门时间、部门名称、部门标志符。 枚举值:DepartmentCreatedAt,JoinDepartmentAt,DepartmentName,DepartmemtCodeJoinDepartmentAt
orderBystring否Desc增序或降序。 枚举值:Asc,DescDesc

¶ 示例代码

import { ManagementClient } from "@genauth/nodejs";
// 在 Node.js 中引用:
// const { ManagementClient } = require('@genauth/nodejs');

const managementClient = new ManagementClient({
  accessKeyId: "GEN_AUTH_USERPOOL_ID",
  accessKeySecret: "GEN_AUTH_USERPOOL_SECRET",
});

(async () => {
  const result = await managementClient.getUserDepartments({
    userId: "6229ffaxxxxxxxxcade3e3d9",

    userIdType: "user_id",

    page: 1,

    limit: 10,

    withCustomData: true,

    sortBy: "JoinDepartmentAt",

    orderBy: "Desc",
  });
})();

¶ 请求响应

类型: UserDepartmentPaginatedRespDto

名称类型描述
statusCodenumber业务状态码,可以通过此状态码判断操作是否成功,200 表示成功。
messagestring描述信息
apiCodenumber细分错误码,可通过此错误码得到具体的错误类型。
dataUserDepartmentPagingDto响应数据

示例结果:

{
  "statusCode": 200,
  "message": "操作成功",
  "apiCode": 20001,
  "data": {
    "list": {
      "organizationCode": "steamory",
      "departmentId": "60b49eb83fd80adb96f26e68",
      "createdAt": "2022-07-03T02:20:30.000Z",
      "name": "dd8d7stf44",
      "description": "dd8d7stf44",
      "openDepartmentId": "ou_7dab8a3d3cdccxxxxxx777c7ad535d62",
      "isLeader": true,
      "code": "6229c4deb3e4d8a20b6021ff",
      "isMainDepartment": true,
      "joinedAt": "2022-07-03T02:20:30.000Z",
      "i18n": {
        "name": {
          "zh-CN": {
            "enabled": false,
            "value": "中文"
          },
          "en-US": {
            "enabled": false,
            "value": "English"
          }
        }
      },
      "customData": {
        "icon": "https://example.com/logo"
      }
    }
  }
}

¶ 数据结构

¶ UserDepartmentPagingDto

名称类型必填描述
totalCountnumber是记录总数。
listarray是响应数据。嵌套类型:UserDepartmentRespDto。

¶ UserDepartmentRespDto

名称类型必填描述
organizationCodestring是组织 Code(organizationCode)。 示例值: steamory
departmentIdstring是部门 ID。 示例值: 60b49eb83fd80adb96f26e68
createdAtstring是部门创建时间。 示例值: 2022-07-03T02:20:30.000Z
namestring是部门名称。 示例值: dd8d7stf44
descriptionstring是部门描述。 示例值: dd8d7stf44
openDepartmentIdstring否自定义部门 ID,用于存储自定义的 ID。 示例值: ou_7dab8a3d3cdccxxxxxx777c7ad535d62
isLeaderboolean是是否是部门 Leader。 示例值: true
codestring是部门识别码。 示例值: 6229c4deb3e4d8a20b6021ff
isMainDepartmentboolean是是否是主部门。 示例值: true
joinedAtstring是加入部门时间。 示例值: 2022-07-03T02:20:30.000Z
isVirtualNodeboolean是是否是虚拟部门。
i18n否多语言设置。嵌套类型:I18nDto。 示例值: [object Object]
customDataobject否部门的扩展字段数据。 示例值: [object Object]

¶ I18nDto

名称类型必填描述
name是支持多语言的字段。嵌套类型:LangObject。 示例值: [object Object]

¶ LangObject

名称类型必填描述
zh-CN是多语言的中文内容。嵌套类型:LangUnit。 示例值: [object Object]
en-US是多语言的英文内容。嵌套类型:LangUnit。 示例值: [object Object]

¶ LangUnit

名称类型必填描述
enabledboolean是是否已开启。若开启,且控制台选择该语言,则展示该内容。(默认关闭)。
valueboolean是多语言内容。
Previous article: Delete User Real-name Authentication Information Next article: Set User Departments
  • 请求参数
  • 示例代码
  • 请求响应
  • 数据结构

User identity management

Integrated third-party login
Customized authentication process

Enterprise internal management

Single sign-on
Multi-factor authentication
Permission management

Developer

Development Documentation
GitHub (opens new window)

Company

official@genauth.ai
16th Floor, Building B, Beichen Century Center, Chaoyang District, Beijing (Total)
Room 406, 4th Floor, Block B, No. 200, Tianfu Fifth Street, High-tech Zone, Chengdu (Branch)

© Beijing Steamory Technology Co., Ltd.