This commit is contained in:
ryan
2026-06-09 11:26:57 +08:00
parent e100441e8a
commit 31f0fb4ceb
9 changed files with 1411 additions and 306 deletions
+376
View File
@@ -517,6 +517,156 @@ const docTemplate = `{
}
}
},
"/api/v1/admin/logs/access": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "分页并按照用户、接口路径、时间范围等维度检索 ClickHouse 用户访问日志列表(需要管理员权限,ClickHouse 未启用时报错)",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "获取用户访问日志",
"parameters": [
{
"type": "integer",
"default": 1,
"description": "页码",
"name": "page",
"in": "query"
},
{
"type": "integer",
"default": 20,
"description": "每页条数",
"name": "page_size",
"in": "query"
},
{
"type": "string",
"description": "用户名模糊搜索",
"name": "username",
"in": "query"
},
{
"type": "string",
"description": "接口路径模糊搜索",
"name": "path",
"in": "query"
},
{
"type": "string",
"description": "起始时间(RFC3339 或 YYYY-MM-DD HH:MM:SS)",
"name": "start_time",
"in": "query"
},
{
"type": "string",
"description": "结束时间(RFC3339 或 YYYY-MM-DD HH:MM:SS)",
"name": "end_time",
"in": "query"
}
],
"responses": {
"200": {
"description": "访问日志列表",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/logs.accessLogsResponse"
}
}
}
]
}
},
"400": {
"description": "ClickHouse 未启用或参数错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/logs/analytics": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "聚合统计最近 7 天的每日访问趋势、浏览器分布以及前 10 名最活跃用户排行(需要管理员权限,ClickHouse 未启用时报错)",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "获取访问日志分析数据",
"responses": {
"200": {
"description": "分析统计数据",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/logs.logsAnalyticsResponse"
}
}
}
]
}
},
"400": {
"description": "ClickHouse 未启用",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/logs/ws": {
"get": {
"description": "通过 WebSocket 实时推送系统日志,需要管理员权限",
@@ -2650,6 +2800,49 @@ const docTemplate = `{
}
}
},
"/api/v1/user-info": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "返回当前登录用户的基本信息及余额数据,需要登录。包括用户 ID、用户名、信任等级、各类余额信息等。",
"produces": [
"application/json"
],
"tags": [
"oauth"
],
"summary": "获取当前登录用户信息",
"responses": {
"200": {
"description": "用户信息",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/oauth.BasicUserInfo"
}
}
}
]
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/user/access-tokens": {
"get": {
"security": [
@@ -3130,6 +3323,49 @@ const docTemplate = `{
}
}
},
"/api/v1/user/self": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "返回当前登录用户的基本信息及余额数据,需要登录。包括用户 ID、用户名、信任等级、各类余额信息等。",
"produces": [
"application/json"
],
"tags": [
"oauth"
],
"summary": "获取当前登录用户信息",
"responses": {
"200": {
"description": "用户信息",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/oauth.BasicUserInfo"
}
}
}
]
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/user/send-email-code": {
"post": {
"description": "向指定邮箱发送验证码(用于注册场景)",
@@ -3216,6 +3452,26 @@ const docTemplate = `{
}
}
}
},
"/robots.txt": {
"get": {
"description": "根据系统配置决定是否允许搜索引擎检索,并返回相应的 robots.txt 文件内容",
"produces": [
"text/plain"
],
"tags": [
"config"
],
"summary": "获取 robots.txt",
"responses": {
"200": {
"description": "robots.txt 内容",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {
@@ -3344,6 +3600,97 @@ const docTemplate = `{
}
}
},
"logs.accessLogItem": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"headers": {
"type": "string"
},
"id": {
"type": "string",
"example": "0"
},
"ip": {
"type": "string"
},
"latency": {
"type": "integer"
},
"method": {
"type": "string"
},
"nickname": {
"type": "string"
},
"path": {
"type": "string"
},
"status": {
"type": "integer"
},
"user_agent": {
"type": "string"
},
"user_id": {
"type": "string",
"example": "0"
},
"username": {
"type": "string"
}
}
},
"logs.accessLogsResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/logs.accessLogItem"
}
},
"total": {
"type": "integer"
}
}
},
"logs.browserItem": {
"type": "object",
"properties": {
"browser": {
"type": "string"
},
"count": {
"type": "integer"
}
}
},
"logs.logsAnalyticsResponse": {
"type": "object",
"properties": {
"browsers": {
"type": "array",
"items": {
"$ref": "#/definitions/logs.browserItem"
}
},
"top_users": {
"type": "array",
"items": {
"$ref": "#/definitions/logs.topUserItem"
}
},
"trend": {
"type": "array",
"items": {
"$ref": "#/definitions/logs.trendItem"
}
}
}
},
"logs.logsResponse": {
"type": "object",
"properties": {
@@ -3362,6 +3709,35 @@ const docTemplate = `{
}
}
},
"logs.topUserItem": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"nickname": {
"type": "string"
},
"user_id": {
"type": "string",
"example": "0"
},
"username": {
"type": "string"
}
}
},
"logs.trendItem": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"date": {
"type": "string"
}
}
},
"model.AccessToken": {
"type": "object",
"properties": {