查询操作日志
/v1/log/op分页查询资源新增、更新和删除等操作日志,按日志 ID 倒序返回。普通用户只能查看自己的操作;管理员可查询全部日志或用 uid 筛选指定用户。支持按 IP、时间、资源类别、操作动作、操作对象和变更内容筛选,limit=0 时返回全部匹配记录。
身份认证
access-token
api-key + api-secret
认证定义
{
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "access-token",
"description": "通过登录接口获得的短期访问令牌。"
},
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "api-key",
"description": "API Key;必须和 api-secret 同时发送。"
},
"ApiSecret": {
"type": "apiKey",
"in": "header",
"name": "api-secret",
"description": "API Secret;必须和 api-key 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
page | query | integer (int32) | 可选 | 页码,默认 1。服务端仅校验为数字,分页偏移为 (page - 1) × limit。 完整参数定义 |
limit | query | integer (int32) | 可选 | 每页记录数,默认 10;传 0 时不附加 SQL limit,返回全部匹配记录。 完整参数定义 |
uid | query | integer (int64) | 可选 | 仅管理员有效:精确筛选操作用户 ID。普通用户提供此参数仍只查询自己的日志。 完整参数定义 |
ip | query | string | 可选 | 按客户端 IP 进行包含匹配,不要求完整 IP。 完整参数定义 |
start | query | string | 可选 | 创建时间下限,筛选 create_at 大于或等于该值。服务端直接交给数据库比较。 完整参数定义 |
end | query | string | 可选 | 创建时间上限(不含),筛选 create_at 小于该值。服务端直接交给数据库比较。 完整参数定义 |
type | query | string | 可选 | 精确筛选资源类别,即日志中的 type,例如 网站、任务、证书或 ACL。 完整参数定义 |
action | query | string | 可选 | 精确筛选操作动作。通用写入逻辑使用 新增、更新、删除。 完整参数定义 |
content | query | string | 可选 | 按操作对象内容进行包含匹配,例如资源 ID 或以逗号分隔的资源 ID。 完整参数定义 |
diff | query | string | 可选 | 按字段变更内容进行包含匹配。该字段通常保存更新前后差异的文本或 JSON 文本。 完整参数定义 |
响应
HTTP 200
业务结果使用 HTTP 200 返回。成功响应含 code、count、data,不含 msg;页码、每页数量或认证失败时返回统一业务错误封装。
application/json
oneOf
oneOf · 1 · object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 成功状态码,固定为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||
count | integer (int64) | 必填 | 当前权限和筛选条件下、未应用分页前的日志总数。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||
data | array <object> | 必填 | 当前页操作日志,按 id 倒序排列。 展开字段结构当前页操作日志,按 id 倒序排列。 数组元素 · object 单条操作日志。
|
oneOf · 2 · object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | string | 必填 | page 格式错误、limit 格式错误或认证失败的业务错误码。 约束 / 默认值 / 示例 |
msg | string | 必填 | 具体错误原因。 |
data | string | 必填 | 业务错误时固定为空字符串。 约束 / 默认值 / 示例 |
完整 Schema
{
"oneOf": [
{
"type": "object",
"required": [
"code",
"count",
"data"
],
"properties": {
"code": {
"type": "integer",
"enum": [
0
],
"description": "成功状态码,固定为 0。"
},
"count": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "当前权限和筛选条件下、未应用分页前的日志总数。"
},
"data": {
"type": "array",
"description": "当前页操作日志,按 id 倒序排列。",
"items": {
"type": "object",
"required": [
"id",
"uid",
"type",
"action",
"content",
"diff",
"ip",
"ip_location",
"create_at",
"process",
"create_at2"
],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "操作日志 ID。"
},
"uid": {
"type": "integer",
"format": "int64",
"nullable": true,
"description": "执行操作的用户 ID。"
},
"type": {
"type": "string",
"nullable": true,
"description": "资源类别,例如 网站、任务、证书、ACL。"
},
"action": {
"type": "string",
"nullable": true,
"description": "操作动作,通用写入逻辑为 新增、更新 或 删除。"
},
"content": {
"type": "string",
"nullable": true,
"description": "被操作对象的标识文本,通常为资源 ID 或逗号分隔的资源 ID。"
},
"diff": {
"type": "string",
"nullable": true,
"description": "字段变更详情文本或 JSON 文本;新增、删除操作通常为空。"
},
"ip": {
"type": "string",
"nullable": true,
"description": "执行操作的客户端 IP。"
},
"ip_location": {
"type": "string",
"nullable": true,
"description": "服务端根据 IP 记录的地理位置,格式通常为 国家-省份-城市。"
},
"create_at": {
"type": "string",
"format": "date-time",
"nullable": true,
"description": "数据库返回的操作创建时间。"
},
"process": {
"type": "string",
"nullable": true,
"description": "操作处理标记;通用新增、更新、删除写入时为空字符串。"
},
"create_at2": {
"type": "string",
"nullable": true,
"description": "格式化后的操作时间,格式为 YYYY-MM-DD HH:mm:ss。"
}
},
"additionalProperties": false,
"description": "单条操作日志。"
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "string",
"enum": [
"log_op-1",
"log_op-2",
"login_required"
],
"description": "page 格式错误、limit 格式错误或认证失败的业务错误码。"
},
"msg": {
"type": "string",
"description": "具体错误原因。"
},
"data": {
"type": "string",
"enum": [
""
],
"description": "业务错误时固定为空字符串。"
}
},
"additionalProperties": false
}
]
}示例
{
"code": 0,
"count": 1,
"data": [
{
"id": 301,
"uid": 12,
"type": "网站",
"action": "更新",
"content": "101",
"diff": "[{\"field\":\"domain\",\"old\":\"old.example.com\",\"new\":\"www.example.com\"}]",
"ip": "198.51.100.23",
"ip_location": "中国-北京市-北京市",
"create_at": "2026-01-01T12:00:00",
"process": "",
"create_at2": "2026-01-01 12:00:00"
}
]
}查询成功
{
"code": 0,
"count": 1,
"data": [
{
"id": 301,
"uid": 12,
"type": "网站",
"action": "更新",
"content": "101",
"diff": "[{\"field\":\"domain\",\"old\":\"old.example.com\",\"new\":\"www.example.com\"}]",
"ip": "198.51.100.23",
"ip_location": "中国-北京市-北京市",
"create_at": "2026-01-01T12:00:00",
"process": "",
"create_at2": "2026-01-01 12:00:00"
}
]
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/log/op" \
--header "access-token: YOUR_ACCESS_TOKEN"