Skip to content

查询违禁词策略

1. 接口定位

  • 接口名称: 查询违禁词策略
  • 所属域: admin/sensitive-word
  • 业务目标: 按场景读取当前生效策略

2. 请求定义

  • Method: POST
  • Path: /adminx/sensitive_word/policy/get
  • Content-Type: 推荐 application/json
  • operationID: 必填,请通过 Header operationID 传入
  • 鉴权: 需要 Header token,且必须是管理员 token
  • 幂等性: 幂等;同请求参数返回同一策略快照

3. 请求参数

Header 参数

字段必填类型说明
operationIDstring链路追踪 ID
tokenstring管理员 token

Body 参数

字段必填类型说明
scenestring场景:singlegroup

字段约束

  • scene 仅允许 single/group

4. 响应 data

通用响应包裹

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

data 字段

字段类型说明
policyobject策略

policy 字段:scene/enabled/action/operator/updateTime。

5. 业务规则

  • scene 维度一条策略记录。
  • updateTime 为毫秒时间戳。

6. 错误码与失败场景

错误码场景典型报错
1001scene 非法scene must be single or group
-指定场景无策略由数据层返回记录不存在错误
-数据库查询失败由数据库层返回原始错误

7. 示例

fetch 请求示例

javascript
fetch("http://localhost:10011/adminx/sensitive_word/policy/get", {
  method: "POST",
  headers: {
    operationID: "sensitive-policy-get-001",
    token: "eyJhbGciOi...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    scene: "single",
  }),
})
  .then((res) => res.json())
  .then((data) => console.log(data));

请求示例(JSON)

json
{
  "scene": "single"
}

成功响应示例

json
{
  "errCode": 0,
  "errMsg": "",
  "errDlt": "",
  "data": {
    "policy": {
      "scene": "single",
      "enabled": true,
      "action": "reject",
      "operator": "admin_001",
      "updateTime": 1760000000000
    }
  }
}

失败响应示例

json
{
  "errCode": 1001,
  "errMsg": "ArgsError",
  "errDlt": "scene must be single or group"
}

8. 时序流程

  1. 中间件校验管理员 token。
  2. 校验 scene 参数。
  3. 按场景查询策略并组装 policy 返回。
  4. 返回统一响应。

9. 变更记录

  • 2026-07-14: 文档重构为标准 admin API 模板,补齐 Header、响应包裹、失败示例与时序流程。