Skip to content

用户管理

属性

用户对象一般包含如下属性,新建、更新、查询时,需要根据情况设置或者获取这些信息。

参数 类型 说明
uid string 用户唯一标识符
status int 用户状态
username string 用户登录名,若创建用户时未声明,系统会自动生成
phone string 用户手机号码
email string 用户邮箱
nickname string 用户名称
desc string 用户介绍
role bool 用户角色
tier int 用户等级
type int 用户类型

接口

创建用户

POST /openapi/v1/accounts/

请求体:

{
  "uid": "xxx",
  "username": "xxx",
  "phone": "xxx",
  "email": "xxxxxx@xxxx",
  "nickname": "xxxx",
  "desc": "xxxx",
  "password": "xxxx",
  "role": 1,
  "tier": 1,
  "type": 1
}

参数说明

参数 类型 是否必填 说明
uid string 用户 uid,格式为 uuid4,不填写默认生成
username string 用户登录名
phone string 用户手机号码
email string 用户邮箱
nickname string 用户名
desc string 用户介绍
password string 用户登录密码
role int 用户角色
tier int 用户等级
type int 用户类型

返回结果

{
  "errcode": 200,
  "errmsg": "success",
  "data": {
    "uid": "xxxxxxxx",
    "status": 1,
    "username": "xxx",
    "phone": "xxx",
    "email": "xxxxxx@xxxx",
    "nickname": "xxxx",
    "desc": "xxxx",
    "role": 1,
    "tier": 1,
    "type": 1
  }
}

批量创建用户

POST /openapi/v1/accounts/create-accounts/

请求体:

{
  "accounts": [
    {
      "uid": "xxxxxxxx",
      "status": 1,
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "password": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    },
    {
      "uid": "xxxxxxxx",
      "status": 1,
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "password": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    }
  ]
}

参数说明

参数 类型 是否必填 说明
accounts array 用户信息数组,数据结构与单个创建用户相同

返回结果

{
  "errcode": 200,
  "errmsg": "success",
  "data": [
    {
      "uid": "xxxxxxxx",
      "status": 1,
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    },
    {
      "uid": "xxxxxxxx",
      "status": 1,
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "password": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    }
  ]
}

更新用户

PUT /openapi/v1/accounts/{account_uid}/

请求体:

{
  "username": "xxx",
  "phone": "xxx",
  "email": "xxxxxx@xxxx",
  "nickname": "xxxx",
  "desc": "xxxx",
  "password": "xxxx",
  "role": 1,
  "tier": 1,
  "type": 1
}

返回结果

{
  "errcode": 200,
  "errmsg": "success",
  "data": {
    "uid": "xxxxxxxx",
    "status": 1,
    "username": "xxx",
    "phone": "xxx",
    "email": "xxxxxx@xxxx",
    "nickname": "xxxx",
    "desc": "xxxx",
    "role": 1,
    "tier": 1,
    "type": 1
  }
}

批量更新用户

PUT /openapi/v1/accounts/update-accounts/

请求头:

{
  "Authorization": "连接密钥"
}

请求体:

{
  "accounts": [
    {
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "password": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    },
    {
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "password": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    }
  ]
}

返回结果

{
  "errcode": 200,
  "errmsg": "success",
  "data": [
    {
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    },
    {
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    }
  ]
}

获取用户列表

GET /openapi/v1/accounts/

可以使用 q 参数,搜索登录名,用户名称,用户介绍,手机号或者邮箱。例如 /openapi/v1/accounts/?q=18812345678

返回结果

{
  "errcode": 200,
  "errmsg": "success",
  "data": [
    {
      "uid": "xxxxxxxx",
      "status": 1,
      "username": "xxx",
      "phone": "xxx",
      "email": "xxxxxx@xxxx",
      "nickname": "xxxx",
      "desc": "xxxx",
      "role": 1,
      "tier": 1,
      "type": 1
    }
  ]
}

获取用户

GET /openapi/v1/accounts/{account_uid}/

返回结果

{
  "errcode": 200,
  "errmsg": "success",
  "data": {
    "uid": "xxx",
    "status": 1,
    "username": "xxx",
    "phone": "xxx",
    "email": "xxx",
    "nickname": "xxx",
    "desc": "xxx",
    "role": 1,
    "tier": 1,
    "type": 1
  }
}

根据标志符获取用户

POST /openapi/v1/accounts/fetch/

本接口在 v25.10 版本中引入

请求体:

{
  "username": "用户的唯一标识符,可以是登录名、手机号或者邮箱"
}

返回结果

如果根据唯一标识符找到用户,返回用户信息。否则返回空

删除用户

DELETE /openapi/v1/accounts/{account_uid}/

返回结果

{
  "errcode": 200,
  "errmsg": "success"
}

批量删除用户

DELETE /openapi/v1/accounts/delete-accounts/

请求体:

{
  "accountUids": [
    "xxxx",
    "xxxx"
  ]
}

返回结果

{
  "errcode": 200,
  "errmsg": "success"
}

获取单个用户的工作区列表

GET /openapi/v1/accounts/{account_uid}/projects/

请求体:

{
  "role": 1,
  "count": 1,
  "offset": 0,
  "limit": 10
}

参数说明

参数 类型 是否必填 说明
role int 用户角色
count int 查询总数
offset int 偏移量
limit int 查询条数

返回结果

{
  "errcode": 200,
  "errmsg": "success",
  "data": [
    {
      "id": 1,
      "name": "xxx",
      "desc": "xxx",
      "owner": {
        "uid": "xxx",
        "email": "xxx",
        "nickname": "xxx",
        "desc": "xxx",
        "status": 1
      },
      "locked": true
    }
  ]
}

参数说明

参数 类型 说明
id int 工作区编号
name string 工作区名称
desc string 工作区介绍
owner.uid string 工作区负责人 uid
owner.email string 工作区负责人邮箱
owner.nickname string 工作区负责人用户名
owner.desc string 工作区负责人介绍
owner.status int 工作区负责人状态
locked bool 工作区是否可编辑