新增配置管理功能及多存储支持
- 添加管理员端 API,用于获取和更新完整配置。 - 添加公共端 API,用于获取非敏感配置信息。 - 增加本地存储(LocalStorage)、S3(S3Storage)、和 WebDAV(WebDAVStorage)存储类型的实现。 - 支持热更新存储配置和保存配置文件至磁盘。 - 更新 Swagger 文档以包含新接口定义。
This commit is contained in:
268
docs/docs.go
268
docs/docs.go
@@ -426,6 +426,80 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/config": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"AdminAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统的完整配置文件内容(仅管理员)",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Admin"
|
||||
],
|
||||
"summary": "获取完整配置",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"AdminAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新系统的配置文件内容(仅管理员)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Admin"
|
||||
],
|
||||
"summary": "更新配置",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "新配置内容",
|
||||
"name": "config",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/login": {
|
||||
"post": {
|
||||
"description": "通过密码换取 JWT Token",
|
||||
@@ -698,6 +772,38 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/config": {
|
||||
"get": {
|
||||
"description": "获取前端展示所需的非敏感配置数据",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Public"
|
||||
],
|
||||
"summary": "获取公共配置",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/public.PublicConfig"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/files/{file_id}/download": {
|
||||
"get": {
|
||||
"description": "根据文件 ID 下载单个文件",
|
||||
@@ -831,6 +937,149 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.APITokenConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allowAdminAPI": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"maxTokens": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.Config": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"apitoken": {
|
||||
"$ref": "#/definitions/config.APITokenConfig"
|
||||
},
|
||||
"database": {
|
||||
"$ref": "#/definitions/config.DatabaseConfig"
|
||||
},
|
||||
"security": {
|
||||
"$ref": "#/definitions/config.SecurityConfig"
|
||||
},
|
||||
"site": {
|
||||
"$ref": "#/definitions/config.SiteConfig"
|
||||
},
|
||||
"storage": {
|
||||
"$ref": "#/definitions/config.StorageConfig"
|
||||
},
|
||||
"upload": {
|
||||
"$ref": "#/definitions/config.UploadConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.DatabaseConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.SecurityConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"adminPasswordHash": {
|
||||
"type": "string"
|
||||
},
|
||||
"jwtsecret": {
|
||||
"type": "string"
|
||||
},
|
||||
"pickupCodeLength": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pickupFailLimit": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.SiteConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.StorageConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"local": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"s3": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accessKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"bucket": {
|
||||
"type": "string"
|
||||
},
|
||||
"endpoint": {
|
||||
"type": "string"
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"useSSL": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"webDAV": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"root": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.UploadConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"maxBatchFiles": {
|
||||
"type": "integer"
|
||||
},
|
||||
"maxFileSizeMB": {
|
||||
"type": "integer"
|
||||
},
|
||||
"maxRetentionDays": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.APIToken": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -979,6 +1228,25 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.PublicConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"api_token": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"site": {
|
||||
"$ref": "#/definitions/config.SiteConfig"
|
||||
},
|
||||
"upload": {
|
||||
"$ref": "#/definitions/config.UploadConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.UploadResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -419,6 +419,80 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/config": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"AdminAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统的完整配置文件内容(仅管理员)",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Admin"
|
||||
],
|
||||
"summary": "获取完整配置",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"AdminAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新系统的配置文件内容(仅管理员)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Admin"
|
||||
],
|
||||
"summary": "更新配置",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "新配置内容",
|
||||
"name": "config",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/login": {
|
||||
"post": {
|
||||
"description": "通过密码换取 JWT Token",
|
||||
@@ -691,6 +765,38 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/config": {
|
||||
"get": {
|
||||
"description": "获取前端展示所需的非敏感配置数据",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Public"
|
||||
],
|
||||
"summary": "获取公共配置",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/public.PublicConfig"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/files/{file_id}/download": {
|
||||
"get": {
|
||||
"description": "根据文件 ID 下载单个文件",
|
||||
@@ -824,6 +930,149 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.APITokenConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allowAdminAPI": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"maxTokens": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.Config": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"apitoken": {
|
||||
"$ref": "#/definitions/config.APITokenConfig"
|
||||
},
|
||||
"database": {
|
||||
"$ref": "#/definitions/config.DatabaseConfig"
|
||||
},
|
||||
"security": {
|
||||
"$ref": "#/definitions/config.SecurityConfig"
|
||||
},
|
||||
"site": {
|
||||
"$ref": "#/definitions/config.SiteConfig"
|
||||
},
|
||||
"storage": {
|
||||
"$ref": "#/definitions/config.StorageConfig"
|
||||
},
|
||||
"upload": {
|
||||
"$ref": "#/definitions/config.UploadConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.DatabaseConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.SecurityConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"adminPasswordHash": {
|
||||
"type": "string"
|
||||
},
|
||||
"jwtsecret": {
|
||||
"type": "string"
|
||||
},
|
||||
"pickupCodeLength": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pickupFailLimit": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.SiteConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.StorageConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"local": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"s3": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accessKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"bucket": {
|
||||
"type": "string"
|
||||
},
|
||||
"endpoint": {
|
||||
"type": "string"
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"useSSL": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"webDAV": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"root": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"config.UploadConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"maxBatchFiles": {
|
||||
"type": "integer"
|
||||
},
|
||||
"maxFileSizeMB": {
|
||||
"type": "integer"
|
||||
},
|
||||
"maxRetentionDays": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.APIToken": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -972,6 +1221,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.PublicConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"api_token": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"site": {
|
||||
"$ref": "#/definitions/config.SiteConfig"
|
||||
},
|
||||
"upload": {
|
||||
"$ref": "#/definitions/config.UploadConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.UploadResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -59,6 +59,98 @@ definitions:
|
||||
status:
|
||||
type: string
|
||||
type: object
|
||||
config.APITokenConfig:
|
||||
properties:
|
||||
allowAdminAPI:
|
||||
type: boolean
|
||||
enabled:
|
||||
type: boolean
|
||||
maxTokens:
|
||||
type: integer
|
||||
type: object
|
||||
config.Config:
|
||||
properties:
|
||||
apitoken:
|
||||
$ref: '#/definitions/config.APITokenConfig'
|
||||
database:
|
||||
$ref: '#/definitions/config.DatabaseConfig'
|
||||
security:
|
||||
$ref: '#/definitions/config.SecurityConfig'
|
||||
site:
|
||||
$ref: '#/definitions/config.SiteConfig'
|
||||
storage:
|
||||
$ref: '#/definitions/config.StorageConfig'
|
||||
upload:
|
||||
$ref: '#/definitions/config.UploadConfig'
|
||||
type: object
|
||||
config.DatabaseConfig:
|
||||
properties:
|
||||
path:
|
||||
type: string
|
||||
type: object
|
||||
config.SecurityConfig:
|
||||
properties:
|
||||
adminPasswordHash:
|
||||
type: string
|
||||
jwtsecret:
|
||||
type: string
|
||||
pickupCodeLength:
|
||||
type: integer
|
||||
pickupFailLimit:
|
||||
type: integer
|
||||
type: object
|
||||
config.SiteConfig:
|
||||
properties:
|
||||
description:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
config.StorageConfig:
|
||||
properties:
|
||||
local:
|
||||
properties:
|
||||
path:
|
||||
type: string
|
||||
type: object
|
||||
s3:
|
||||
properties:
|
||||
accessKey:
|
||||
type: string
|
||||
bucket:
|
||||
type: string
|
||||
endpoint:
|
||||
type: string
|
||||
region:
|
||||
type: string
|
||||
secretKey:
|
||||
type: string
|
||||
useSSL:
|
||||
type: boolean
|
||||
type: object
|
||||
type:
|
||||
type: string
|
||||
webDAV:
|
||||
properties:
|
||||
password:
|
||||
type: string
|
||||
root:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
config.UploadConfig:
|
||||
properties:
|
||||
maxBatchFiles:
|
||||
type: integer
|
||||
maxFileSizeMB:
|
||||
type: integer
|
||||
maxRetentionDays:
|
||||
type: integer
|
||||
type: object
|
||||
model.APIToken:
|
||||
properties:
|
||||
created_at:
|
||||
@@ -158,6 +250,18 @@ definitions:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
public.PublicConfig:
|
||||
properties:
|
||||
api_token:
|
||||
properties:
|
||||
enabled:
|
||||
type: boolean
|
||||
type: object
|
||||
site:
|
||||
$ref: '#/definitions/config.SiteConfig'
|
||||
upload:
|
||||
$ref: '#/definitions/config.UploadConfig'
|
||||
type: object
|
||||
public.UploadResponse:
|
||||
properties:
|
||||
batch_id:
|
||||
@@ -440,6 +544,52 @@ paths:
|
||||
summary: 修改批次信息
|
||||
tags:
|
||||
- Admin
|
||||
/admin/config:
|
||||
get:
|
||||
description: 获取系统的完整配置文件内容(仅管理员)
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/config.Config'
|
||||
security:
|
||||
- AdminAuth: []
|
||||
summary: 获取完整配置
|
||||
tags:
|
||||
- Admin
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 更新系统的配置文件内容(仅管理员)
|
||||
parameters:
|
||||
- description: 新配置内容
|
||||
in: body
|
||||
name: config
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/config.Config'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
security:
|
||||
- AdminAuth: []
|
||||
summary: 更新配置
|
||||
tags:
|
||||
- Admin
|
||||
/admin/login:
|
||||
post:
|
||||
consumes:
|
||||
@@ -607,6 +757,24 @@ paths:
|
||||
summary: 发送长文本
|
||||
tags:
|
||||
- Public
|
||||
/api/config:
|
||||
get:
|
||||
description: 获取前端展示所需的非敏感配置数据
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/public.PublicConfig'
|
||||
type: object
|
||||
summary: 获取公共配置
|
||||
tags:
|
||||
- Public
|
||||
/api/files/{file_id}/download:
|
||||
get:
|
||||
description: 根据文件 ID 下载单个文件
|
||||
|
||||
Reference in New Issue
Block a user