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

查询登录日志

GET/v1/log/login

分页查询登录记录,按日志 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"
  }
}
successquerystring可选

精确筛选登录结果。通常传 1 查询成功记录,传 0 查询失败记录;服务端直接将非空值交给数据库比较,不在接口层校验取值。

完整参数定义
{
  "name": "success",
  "in": "query",
  "required": false,
  "description": "精确筛选登录结果。通常传 1 查询成功记录,传 0 查询失败记录;服务端直接将非空值交给数据库比较,不在接口层校验取值。",
  "schema": {
    "type": "string",
    "enum": [
      "0",
      "1"
    ]
  }
}
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"
  }
}

响应

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;无法对应用户时为 null。

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

客户端登录 IP 地址。

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

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

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

登录结果的数据库布尔值:1 为成功,0 为失败;数据库字段为空时为 null。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "nullable": true
}
create_atstring必填

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

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

与 create_at 相同的格式化登录时间字段,兼容前端展示。

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

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

约束 / 默认值 / 示例
{
  "enum": [
    "log_login-1",
    "log_login-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",
              "ip",
              "ip_location",
              "success",
              "create_at",
              "create_at2"
            ],
            "properties": {
              "id": {
                "type": "integer",
                "format": "int64",
                "description": "登录日志 ID。"
              },
              "uid": {
                "type": "integer",
                "format": "int64",
                "nullable": true,
                "description": "尝试登录的用户 ID;无法对应用户时为 null。"
              },
              "ip": {
                "type": "string",
                "nullable": true,
                "description": "客户端登录 IP 地址。"
              },
              "ip_location": {
                "type": "string",
                "nullable": true,
                "description": "服务端根据 IP 记录的地理位置,格式通常为 国家-省份-城市。"
              },
              "success": {
                "type": "integer",
                "enum": [
                  0,
                  1
                ],
                "nullable": true,
                "description": "登录结果的数据库布尔值:1 为成功,0 为失败;数据库字段为空时为 null。"
              },
              "create_at": {
                "type": "string",
                "nullable": true,
                "description": "格式化后的登录时间,格式为 YYYY-MM-DD HH:mm:ss。"
              },
              "create_at2": {
                "type": "string",
                "nullable": true,
                "description": "与 create_at 相同的格式化登录时间字段,兼容前端展示。"
              }
            },
            "additionalProperties": false,
            "description": "单条登录日志。"
          }
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "log_login-1",
            "log_login-2",
            "login_required"
          ],
          "description": "page 格式错误、limit 格式错误或认证失败的业务错误码。"
        },
        "msg": {
          "type": "string",
          "description": "具体错误原因。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时固定为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "count": 1,
  "data": [
    {
      "id": 101,
      "uid": 12,
      "ip": "198.51.100.23",
      "ip_location": "中国-北京市-北京市",
      "success": 1,
      "create_at": "2026-01-01 12:00:00",
      "create_at2": "2026-01-01 12:00:00"
    }
  ]
}

查询成功

{
  "code": 0,
  "count": 1,
  "data": [
    {
      "id": 101,
      "uid": 12,
      "ip": "198.51.100.23",
      "ip_location": "中国-北京市-北京市",
      "success": 1,
      "create_at": "2026-01-01 12:00:00",
      "create_at2": "2026-01-01 12:00:00"
    }
  ]
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request GET \
  "https://master.example.invalid/v1/log/login" \
  --header "access-token: YOUR_ACCESS_TOKEN"

查看完整接口 JSON