itecdn 5.x用户文档
itecdn 5.x / 用户 API

查询操作日志

GET/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 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
pagequeryinteger (int32)可选

页码,默认 1。服务端仅校验为数字,分页偏移为 (page - 1) × limit。

完整参数定义
{
  "name": "page",
  "in": "query",
  "required": false,
  "description": "页码,默认 1。服务端仅校验为数字,分页偏移为 (page - 1) × limit。",
  "schema": {
    "type": "integer",
    "format": "int32",
    "minimum": 1,
    "default": 1
  }
}
limitqueryinteger (int32)可选

每页记录数,默认 10;传 0 时不附加 SQL limit,返回全部匹配记录。

完整参数定义
{
  "name": "limit",
  "in": "query",
  "required": false,
  "description": "每页记录数,默认 10;传 0 时不附加 SQL limit,返回全部匹配记录。",
  "schema": {
    "type": "integer",
    "format": "int32",
    "minimum": 0,
    "default": 10
  }
}
uidqueryinteger (int64)可选

仅管理员有效:精确筛选操作用户 ID。普通用户提供此参数仍只查询自己的日志。

完整参数定义
{
  "name": "uid",
  "in": "query",
  "required": false,
  "description": "仅管理员有效:精确筛选操作用户 ID。普通用户提供此参数仍只查询自己的日志。",
  "schema": {
    "type": "integer",
    "format": "int64",
    "minimum": 1
  }
}
ipquerystring可选

按客户端 IP 进行包含匹配,不要求完整 IP。

完整参数定义
{
  "name": "ip",
  "in": "query",
  "required": false,
  "description": "按客户端 IP 进行包含匹配,不要求完整 IP。",
  "schema": {
    "type": "string",
    "example": "198.51.100"
  }
}
startquerystring可选

创建时间下限,筛选 create_at 大于或等于该值。服务端直接交给数据库比较。

完整参数定义
{
  "name": "start",
  "in": "query",
  "required": false,
  "description": "创建时间下限,筛选 create_at 大于或等于该值。服务端直接交给数据库比较。",
  "schema": {
    "type": "string",
    "example": "2026-01-01 00:00:00"
  }
}
endquerystring可选

创建时间上限(不含),筛选 create_at 小于该值。服务端直接交给数据库比较。

完整参数定义
{
  "name": "end",
  "in": "query",
  "required": false,
  "description": "创建时间上限(不含),筛选 create_at 小于该值。服务端直接交给数据库比较。",
  "schema": {
    "type": "string",
    "example": "2026-01-02 00:00:00"
  }
}
typequerystring可选

精确筛选资源类别,即日志中的 type,例如 网站、任务、证书或 ACL。

完整参数定义
{
  "name": "type",
  "in": "query",
  "required": false,
  "description": "精确筛选资源类别,即日志中的 type,例如 网站、任务、证书或 ACL。",
  "schema": {
    "type": "string"
  }
}
actionquerystring可选

精确筛选操作动作。通用写入逻辑使用 新增、更新、删除。

完整参数定义
{
  "name": "action",
  "in": "query",
  "required": false,
  "description": "精确筛选操作动作。通用写入逻辑使用 新增、更新、删除。",
  "schema": {
    "type": "string",
    "enum": [
      "新增",
      "更新",
      "删除"
    ]
  }
}
contentquerystring可选

按操作对象内容进行包含匹配,例如资源 ID 或以逗号分隔的资源 ID。

完整参数定义
{
  "name": "content",
  "in": "query",
  "required": false,
  "description": "按操作对象内容进行包含匹配,例如资源 ID 或以逗号分隔的资源 ID。",
  "schema": {
    "type": "string"
  }
}
diffquerystring可选

按字段变更内容进行包含匹配。该字段通常保存更新前后差异的文本或 JSON 文本。

完整参数定义
{
  "name": "diff",
  "in": "query",
  "required": false,
  "description": "按字段变更内容进行包含匹配。该字段通常保存更新前后差异的文本或 JSON 文本。",
  "schema": {
    "type": "string"
  }
}

响应

HTTP 200

业务结果使用 HTTP 200 返回。成功响应含 code、count、data,不含 msg;页码、每页数量或认证失败时返回统一业务错误封装。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

成功状态码,固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
countinteger (int64)必填

当前权限和筛选条件下、未应用分页前的日志总数。

约束 / 默认值 / 示例
{
  "format": "int64",
  "minimum": 0
}
dataarray <object>必填

当前页操作日志,按 id 倒序排列。

展开字段结构

当前页操作日志,按 id 倒序排列。

数组元素 · object

单条操作日志。

字段类型必填说明与约束
idinteger (int64)必填

操作日志 ID。

约束 / 默认值 / 示例
{
  "format": "int64"
}
uidinteger (int64)必填

执行操作的用户 ID。

约束 / 默认值 / 示例
{
  "format": "int64",
  "nullable": true
}
typestring必填

资源类别,例如 网站、任务、证书、ACL。

约束 / 默认值 / 示例
{
  "nullable": true
}
actionstring必填

操作动作,通用写入逻辑为 新增、更新 或 删除。

约束 / 默认值 / 示例
{
  "nullable": true
}
contentstring必填

被操作对象的标识文本,通常为资源 ID 或逗号分隔的资源 ID。

约束 / 默认值 / 示例
{
  "nullable": true
}
diffstring必填

字段变更详情文本或 JSON 文本;新增、删除操作通常为空。

约束 / 默认值 / 示例
{
  "nullable": true
}
ipstring必填

执行操作的客户端 IP。

约束 / 默认值 / 示例
{
  "nullable": true
}
ip_locationstring必填

服务端根据 IP 记录的地理位置,格式通常为 国家-省份-城市。

约束 / 默认值 / 示例
{
  "nullable": true
}
create_atstring (date-time)必填

数据库返回的操作创建时间。

约束 / 默认值 / 示例
{
  "format": "date-time",
  "nullable": true
}
processstring必填

操作处理标记;通用新增、更新、删除写入时为空字符串。

约束 / 默认值 / 示例
{
  "nullable": true
}
create_at2string必填

格式化后的操作时间,格式为 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "nullable": true
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

page 格式错误、limit 格式错误或认证失败的业务错误码。

约束 / 默认值 / 示例
{
  "enum": [
    "log_op-1",
    "log_op-2",
    "login_required"
  ]
}
msgstring必填

具体错误原因。

datastring必填

业务错误时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 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"

查看完整接口 JSON