Skip to content

删除用户登录 IP 限制 ​

1. 接口定位 ​

  • 接口名称: 删除用户登录 IP 限制
  • 所属域: admin/forbidden/user
  • 业务目标: 删除指定用户与 IP 的登录限制映射关系

2. 请求定义 ​

  • Method: POST
  • Path: /forbidden/user/del
  • Content-Type: 推荐 application/json
  • operationID: 必填,请通过 Header operationID 传入
  • 鉴权: 需要 Header token,且必须是管理员 token
  • 幂等性: 弱幂等;不存在的组合不会单独返回未找到错误

3. 请求参数 ​

Header 参数 ​

字段必填类型说明
operationID是string链路追踪 ID
token是string管理员 token

Body 参数 ​

字段必填类型说明
limits是array<object>要删除的用户-IP 组合

limits 元素字段 ​

字段必填类型说明
userID是string用户 ID
ip是stringIP 地址

字段约束 ​

  • 协议校验要求 limits 不能为 null。
  • RPC 层要求 limits 长度必须大于 0。
  • RPC 层会逐条校验 userID 和 ip 都不能为空字符串,否则直接失败。

4. 响应结构 ​

通用响应包裹 ​

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

data 字段 ​

  • 本接口成功时返回空对象(无业务字段)。

5. 业务规则 ​

  • 仅管理员可以调用。
  • 删除条件按 (user_id, ip) 组合匹配,不支持只按 userID 或只按 ip 批量删除。
  • 不会先查询记录是否存在,也不会返回删除条数。

6. 错误码与失败场景 ​

错误码场景典型报错
1001limits 为 nulllimits is empty
1001limits 为空数组limits is empty
1001某条记录缺少 userID 或 ipuser_id or ip is empty
-数据库删除失败由数据库层返回原始错误

7. 示例 ​

fetch 请求示例 ​

javascript
fetch("http://localhost:10009/forbidden/user/del", {
  method: "POST",
  headers: {
    operationID: "550e8400-e29b-41d4-a716-446655440409",
    token: "eyJhbGciOi...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    limits: [
      {
        userID: "1000001234",
        ip: "203.0.113.8",
      },
    ],
  }),
})
  .then((res) => res.json())
  .then((data) => console.log(data));

请求示例(JSON) ​

json
{
  "limits": [
    {
      "userID": "1000001234",
      "ip": "203.0.113.8"
    }
  ]
}

成功响应示例 ​

json
{
  "errCode": 0,
  "errMsg": "",
  "errDlt": "",
  "data": {}
}

失败响应示例 ​

json
{
  "errCode": 1001,
  "errMsg": "ArgsError",
  "errDlt": "user_id or ip is empty"
}

8. 时序流程 ​

  1. 中间件校验管理员 token。
  2. 校验 limits 是否为空,并逐项检查 userID 与 ip。
  3. 将请求列表转换为删除过滤条件。
  4. 按 (user_id, ip) 组合批量删除。
  5. 返回统一成功响应。

9. 变更记录 ​

  • 2026-03-31: 首版发布,基于用户登录 IP 限制删除逻辑补全文档。