查询违禁词策略
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 参数
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| operationID | 是 | string | 链路追踪 ID |
| token | 是 | string | 管理员 token |
Body 参数
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| scene | 是 | string | 场景:single 或 group |
字段约束
scene仅允许single/group。
4. 响应 data
通用响应包裹
| 字段 | 类型 | 说明 |
|---|---|---|
| errCode | int | 错误码,0 表示成功 |
| errMsg | string | 错误简述 |
| errDlt | string | 错误详情 |
| data | object | 业务数据 |
data 字段
| 字段 | 类型 | 说明 |
|---|---|---|
| policy | object | 策略 |
policy 字段:scene/enabled/action/operator/updateTime。
5. 业务规则
scene维度一条策略记录。updateTime为毫秒时间戳。
6. 错误码与失败场景
| 错误码 | 场景 | 典型报错 |
|---|---|---|
| 1001 | scene 非法 | 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. 时序流程
- 中间件校验管理员 token。
- 校验
scene参数。 - 按场景查询策略并组装
policy返回。 - 返回统一响应。
9. 变更记录
- 2026-07-14: 文档重构为标准 admin API 模板,补齐 Header、响应包裹、失败示例与时序流程。