新增配置管理功能及多存储支持

- 添加管理员端 API,用于获取和更新完整配置。
- 添加公共端 API,用于获取非敏感配置信息。
- 增加本地存储(LocalStorage)、S3(S3Storage)、和 WebDAV(WebDAVStorage)存储类型的实现。
- 支持热更新存储配置和保存配置文件至磁盘。
- 更新 Swagger 文档以包含新接口定义。
This commit is contained in:
2026-01-14 14:15:20 +08:00
parent 1ffa16cf48
commit fe656fb298
13 changed files with 1043 additions and 6 deletions

View File

@@ -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 下载单个文件