全部產品
Search
文件中心

Drive and Photo Service:使用者

更新時間:Dec 22, 2025

說明

User 在一個Domain下有唯一的ID。Account 是 User 的登入帳號,同一個 User 可以有多種登入帳號,比如手機號,郵箱等。

說明

系統內建的角色有:user, admin, superadmin。

下文提到的Admin許可權,是指調用者token的角色為:admin | superadmin。

說明

請求參數中的 options: IPDSRequestConfig 基於 axios 的 request config 封裝,詳情請看:AxiosRequestConfig

createUser 方法

重要

需要Admin許可權。

建立使用者。

此方法只建立使用者,如果要使用PDS提供的幾種登入方式,還需要調對應的 LinkAccount - 綁定帳號 介面。

如果是JWT接入的使用者,則無需調用 linkAccount。

const result = await client.createUser(params, options)

舉例

const userInfo = await client.createUser({
  user_id: 'id_123',
  phone: '135****8888',
  email:'username@aliyundoc.com',
  nick_name: '暱稱',
  user_name: '使用者名稱',
  role: 'user'
})

參數說明

欄位

類型

必選

說明

params

ICreateUserReq

建立使用者的參數

options

IPDSRequestConfig

其它配置項

ICreateUserReq

欄位

類型

必選

說明

user_id

string

User ID

role

string

角色, 支援: "user","admin","superadmin",預設:"user"。 如果是當前domain支援subdomain。還可以支援 "subdomain_super_admin", "subdomain_admin"。

user_name

string

使用者名稱

nick_name

string

暱稱

description

string

備忘

email

string

郵箱

phone

string

手機

status

string

狀態,取值範圍: disabled, enabled

avatar

string

頭像資訊, 以 http:// 開頭, 或者 base64 data URI

返回

欄位

類型

必選

說明

result

IUserItem

結果

IUserItem

名稱

類型

說明

domain_id

string

domain ID

user_id

string

user id

email

string

郵箱

role

string

使用者角色

description

string

描述

phone

string

手機

nick_name

string

暱稱

user_name

string

使用者名稱

status

string

狀態: enabled, disabled

avatar

string

頭像

created_at

number

建立時間,從1970年1月1日0點到當前的毫秒時間戳記

updated_at

number

最後修改時間,從1970年1月1日0點到當前的毫秒時間戳記

default_drive_id

string

預設drive id

listUsers 方法

重要

需要Admin許可權。

列舉使用者。

const result = await client.listUsers(params, options)

舉例:

const {items=[],next_marker} = await client.listUsers({
  limit: 100,
  marker: ''
})

參數

欄位

類型

必選

說明

params

IListReq

預設為 {}

options

IPDSRequestConfig

其它配置項

IListReq

欄位

類型

必選

說明

marker

string

查詢起始標識

limit

string

返回資料最大條數,範圍:[1-100],預設:100

返回

欄位

類型

必選

說明

result

IListRes

結果

IListRes

欄位

類型

必選

說明

items

IUserItem[]

使用者列表

getUser 方法

重要

Admin 許可權可以查詢任意使用者的資訊。User 許可權只可以查自己的資訊。

查詢使用者資訊。

const result = await client.getUser(params, options)

舉例

const userInfo = await client.getUser({
   user_id: 'id_123'
})

參數

欄位

類型

必選

說明

params

Object

預設為 {}

options

IPDSRequestConfig

其它配置項

params

欄位

類型

必選

說明

user_id

string

User ID

返回

欄位

類型

必選

說明

result

IUserItem

結果

IUserItem

名稱

類型

說明

domain_id

string

domain ID

user_id

string

user id

email

string

郵箱

role

string

使用者角色

description

string

描述

phone

string

手機

nick_name

string

暱稱

user_name

string

使用者名稱

status

string

狀態: enabled, disabled

avatar

string

頭像

created_at

number

建立時間,從1970年1月1日0點到當前的毫秒時間戳記

updated_at

number

最後修改時間,從1970年1月1日0點到當前的毫秒時間戳記

default_drive_id

string

預設drive id

generalGetUser 方法

查詢單個使用者介面。

const result = await client.generalGetUser(params, options)

舉例

const userInfo = await client.generalGetUser({
  user_id: 'id_123',
  extra_return_info: ['drive', 'group']
})

參數

欄位

類型

必選

說明

params

Object

預設為 {}

options

IPDSRequestConfig

其它配置項

params

欄位

類型

必選

說明

user_id

string

User ID 不穿查當前登入使用者

extra_return_info

string[]

管理員才可以傳此欄位

可選枚舉:drive、group, 表示返回使用者的drive或group資訊。

如果此欄位帶上group會大幅減慢查詢速度,調用limit不能超過30。

返回

欄位

類型

必選

說明

result

IUserItem

結果

IUserItem

名稱

類型

說明

domain_id

string

domain ID

user_id

string

user id

email

string

郵箱

role

string

使用者角色

description

string

描述

phone

string

手機

nick_name

string

暱稱

user_name

string

使用者名稱

status

string

狀態: enabled, disabled

avatar

string

頭像

created_at

number

建立時間,從1970年1月1日0點到當前的毫秒時間戳記

updated_at

number

最後修改時間,從1970年1月1日0點到當前的毫秒時間戳記

default_drive_id

string

預設drive id

updateUser 方法

重要

要求Admin許可權

修改使用者暱稱,頭像等資訊。

await client.updateUser(params, options)

舉例

// 將使用者禁用
await client.updateUser({  
  user_id: 'id_123',
  status : 'disabled'
})

參數

欄位

類型

必選

說明

params

IUpdateUserReq

預設為 {}

options

IPDSRequestConfig

其它配置項

IUpdateUserReq

欄位

類型

必選

說明

user_id

string

User ID

role

string

角色, 支援: "user","admin","superadmin",預設:"user"

nick_name

string

暱稱

description

string

備忘

email

string

郵箱

phone

string

手機

status

string

狀態,取值範圍: disabled, enabled

avatar

string

頭像資訊, 以 http:// 開頭, 或者 base64 data URI

返回

欄位

類型

必選

說明

result

IUserItem

結果

deleteUser 方法

重要

需要admin許可權

刪除使用者並刪除關聯的AccountLink。

await client.deleteUser(params, options)

舉例

await client.deleteUser({
  user_id: 'id_123'
})

參數

欄位

類型

必選

說明

params

Object

預設為 {}

options

IPDSRequestConfig

其它配置項

params

欄位

類型

必選

說明

user_id

string

User ID

返回

searchUsers 方法

重要

需要Admin許可權

搜尋使用者。

const result = await client.searchUsers(params, options)

舉例

const {items=[]} = await client.searchUsers({  
  nick_name_for_fuzzy: 'test'
})

參數

欄位

類型

必選

說明

params

ISearchUsersReq

預設為 {}

options

IPDSRequestConfig

其它配置項

ISearchUsersReq

欄位

類型

必選

說明

nick_name

string

暱稱,首碼匹配,中文不支援全拼和首字母

nick_name_for_fuzzy

string

使用者暱稱模糊搜尋

user_name

string

使用者名稱,首碼匹配,中文不支援全拼和首字母

email

string

電子郵件, 首碼匹配

phone

string

電話號碼, 首碼匹配

role

string

角色, 精確匹配

status

string

狀態, 精確匹配

limit

number

返回資料最大條數,範圍:[1-100],預設:100

marker

string

查詢起始標識

返回

欄位

類型

必選

說明

result

IListRes

結果

IListRes

名稱

類型

說明

items

IUserItem[]

user 數組

next_marker

string

下一頁起始位置標識

generalSearchUsers 方法

搜尋使用者。

const result = await client.generalSearchUsers(params, options)

舉例

const {items=[], next_marker} = await client.generalSearchUsers({  
  nick_name_for_fuzzy: 'test',
  direct_parent_group_id: '123456',
  extra_return_info: ['drive', 'group'],
  limit: 30,
  marker: ''
})

參數

欄位

類型

必選

說明

params

IUserGeneralSearchReq

預設為 {}

options

IPDSRequestConfig

其它配置項

IUserGeneralSearchReq

欄位

類型

必選

說明

nick_name

string

暱稱,首碼匹配,中文不支援全拼和首字母

nick_name_for_fuzzy

string

使用者暱稱模糊搜尋

parent_group_id_list

string[]

返回該團隊下的資料,包含子團隊下符合的成員

direct_parent_group_id

string

只返回該團隊下的資料,不包含子團隊

extra_return_info

string[]

管理員才可以傳此欄位

可選枚舉:drive、group, 表示返回使用者的drive或group資訊。

如果此欄位帶上group會大幅減慢查詢速度,調用limit不能超過30。

limit

number

返回資料最大條數,範圍:[1-100],預設:100

marker

string

查詢起始標識

返回

欄位

類型

必選

說明

result

IListRes

結果

IListRes

名稱

類型

說明

items

IUserItem[]

user 數組

next_marker

string

下一頁起始位置標識

listGroupUsers 方法

列舉Group的直接子成員。

此方法普通使用者也能調用。

const result = await client.listGroupUsers(params, options)

舉例

const params = {
  group_id: "abc"
}
const {items=[], next_marker} = await client.listGroupUsers(params)

參數

欄位

類型

必選

說明

params

IListGroupUserReq

預設為 {}

options

IPDSRequestConfig

其它配置項

IListGroupUserReq

欄位

類型

必選

說明

group_id

string

查詢某個group下的user和group

member_type

string

成員類型,選擇性參數:user、group 不傳預設都返回

extra_return_info

string[]

可選:group, drive。

管理員才可以傳此欄位。表示返回使用者的 drive或 group 資訊。 如果此欄位帶上group會大幅減慢查詢速度,調用一次不能超過30條記錄。

limit

number

返回資料最大條數,範圍:[1-100],預設:100

marker

string

查詢起始標識

返回

欄位

類型

必選

說明

result

IListRes

結果

IListRes

名稱

類型

說明

items

IGroupItem[] 或

IUserItem[]

數組

next_marker

string

下一頁起始位置標識

importUser 方法

重要

需要Admin許可權

匯入手機/信箱使用者。

此方法相當於 createUser 成功後又調用 createAccountLink

const result = await client.importUser(params, options)

舉例

匯入手機使用者

await client.importUser({
  authentication_type: 'mobile',
  auto_create_drive: true,
  identity:'135****8888',
  drive_total_size: 1024 * 1024 * 1024,
  nick_name: 'W123'
})

匯入Email使用者

await client.importUser({
  authentication_type: 'email',
  auto_create_drive: true,
  identity:'username@example.com',
  drive_total_size: 1024 * 1024 * 1024,
  nick_name: 'W123'
})

參數

欄位

類型

必選

說明

params

IImportUserReq

預設為 {}

options

IPDSRequestConfig

其它配置項

IImportUserReq

欄位

類型

必選

說明

auto_create_drive

boolean

自動建立雲端硬碟

drive_total_size

number

雲端硬碟空間大小

authentication_type

string

取值範圍:mobile, email,ldap, custom。

identity

string

唯一標識, 如果 authentication_type 為 mobile, 應該傳手機號,如果為 email, 應該傳郵箱地址, 如果為ldap,應該傳 ldap_dn, 如果是custom, 則傳自訂的唯一ID。

parent_group_id

string

nick_name

string

暱稱

返回

欄位

類型

必選

說明

result

IUserItem

結果