Skip to content

获取用户完整信息 ​

1. 接口定位 ​

  • 接口名称: 获取用户完整信息
  • 所属域: chat/user
  • 业务目标: 批量查询指定用户信息;普通用户仅可查询本人和好友,管理员可查询任意用户

2. 请求定义 ​

  • Method: POST
  • Path: /user/find/full
  • Content-Type: 推荐 application/json
  • operationID: 必填,请通过 Header operationID 传入
  • 鉴权: 必填,需要通过 Header token 传入有效的登录令牌
  • 幂等性: 幂等(只读操作)

3. 请求参数 ​

Header 参数 ​

字段必填类型说明
operationID是string链路追踪 ID
token是string登录令牌

Body 参数 ​

字段必填类型说明
userIDs是[]string目标用户 ID 列表

字段约束 ​

  • userIDs 不能为空,至少包含一个用户 ID。

4. 响应结构 ​

通用响应包裹 ​

字段类型说明
errCodeint错误码,0 表示成功
errMsgstring错误简述
errDltstring错误详情
dataany业务数据

data 字段结构 ​

字段类型说明
usersarray用户完整信息列表
userIDstring用户 ID
nicknamestring用户昵称
faceURLstring头像 URL
exstringopen-im-server 用户扩展字段(原样返回)
accountstring账户名
phoneNumberstring手机号(普通用户视角为脱敏值)
areaCodestring手机区号
emailstring邮箱
genderint32性别
birthstring出生日期
createTimeint64创建时间(UNIX 时间戳)
appMerchantIDstring应用商户 ID
registerTypeint32注册类型

5. 业务规则 ​

  • 普通用户仅允许查询本人和好友 userID;非本人/非好友目标会被过滤。
  • 普通用户响应中的 phoneNumber 默认脱敏。
  • 管理员可查询任意用户,且返回完整字段(包含明文手机号)。
  • 返回 ex 字段,来源于 open-im-server 用户扩展字段,原样透传,不做结构化解析。
  • 用户不存在时不返回该用户。
  • 返回列表顺序与请求 userIDs 顺序一致;不存在的 ID 自动过滤。
  • 本接口通常由管理员或用户自己使用。

6. 错误码与失败场景 ​

错误码场景典型报错
1001userIDs 为空或未提供userIDs is empty

7. 示例 ​

fetch 请求示例 ​

javascript
fetch("http://localhost:10008/user/find/full", {
  method: "POST",
  headers: {
    operationID: "550e8400-e29b-41d4-a716-446655440001",
    token: "eyJhbGciOiJIUzI1NiIs...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    userIDs: ["user001", "user002"],
  }),
})
  .then((res) => res.json())
  .then((data) => console.log(data));

请求示例(JSON) ​

json
{
  "userIDs": ["user001", "user002"]
}

成功响应示例 ​

json
{
  "errCode": 0,
  "errMsg": "",
  "errDlt": "",
  "data": {
    "users": [
      {
        "userID": "user001",
        "nickname": "老李",
        "ex": "{\"isOfficial\":true,\"badge\":\"vip\"}",
        "account": "lili",
        "phoneNumber": "138****8000",
        "areaCode": "+86",
        "email": "lili@example.com",
        "gender": 1,
        "faceURL": "https://example.com/avatar1.jpg",
        "birth": "1990-01-15",
        "createTime": 1704067200,
        "appMerchantID": "merchant001",
        "registerType": 1
      }
    ]
  }
}

失败响应示例 ​

json
{
  "errCode": 1001,
  "errMsg": "ArgsError",
  "errDlt": "userIDs is empty"
}

8. 时序流程 ​

  1. 验证令牌。
  2. 校验 userIDs 不为空。
  3. 普通用户按“本人+好友”做对象级过滤;管理员不受该限制。
  4. 查询用户属性表获取信息。
  5. 普通用户响应手机号脱敏后返回。

9. 变更记录 ​

  • 2026-03-31: 首版发布,包含批量查询完整信息的定义和示例。
  • 2026-09-27: 响应新增 ex 字段,原样返回 open-im-server 用户扩展信息。
  • 2026-10-12: 安全收敛:普通用户限制为仅可查询本人/好友,且手机号默认脱敏;管理员保持完整能力。