- 数据库默认文件 filecodebox.db → fileshare.db(config.go 默认值与全部文档/编排同步)
- Go module filecodebox → fileshare(全部 import 同步,build/vet/test 全绿)
- 应用版本 APP_VERSION 2.5.6 → 26.9(health 接口已验证返回 26.9)
- deploy 编排统一:compose 项目名、Postgres 默认凭据、minio 桶名、env 注释
- JWT issuer、存储临时目录前缀、web 包名同步 fileshare
- CI:镜像 tag 以 APP_VERSION 为唯一版本源,main/tag 推送即发布
${VER} + latest;tag 触发时校验 tag 名与 APP_VERSION 一致,防错版
- 本地开发库文件已改名 fileshare.db(含 -shm/-wal 清理)
88 lines
3.5 KiB
Go
88 lines
3.5 KiB
Go
// Package settings — schema.go:v2 配置键 schema 常量与元数据表。
|
||
//
|
||
// 键名常量的单一事实来源在 internal/config/schema.go(defaults() 需引用);
|
||
// 本文件 re-export 供 API/管理层使用,并提供「键名/类型/默认值」全量表,
|
||
// 供管理端设置页与文档生成(t4)对齐。新增键必须同步:
|
||
// 1. config/schema.go 键名与边界常量
|
||
// 2. config/config.go defaults() 默认值
|
||
// 3. 本文件 KVSchema() 元数据行
|
||
// 4. schema 同步测试(config schema_test / settings schema_test)
|
||
package settings
|
||
|
||
import "fileshare/internal/config"
|
||
|
||
// —— 键名 re-export(与 config 包保持同一字符串,避免魔法值散落)——
|
||
const (
|
||
// 需求 ① 背景图
|
||
KeyBackground = config.KeyBackground
|
||
KeyBackgroundURL = config.KeyBackgroundURL
|
||
// 需求 ② 页脚
|
||
KeyFooterText = config.KeyFooterText
|
||
KeyFooterBeian = config.KeyFooterBeian
|
||
// 需求 ③ 系统通知
|
||
KeyNotifyEnabled = config.KeyNotifyEnabled
|
||
KeyNotifyTitle = config.KeyNotifyTitle
|
||
KeyNotifyContent = config.KeyNotifyContent
|
||
// 需求 ④ 保存策略与上传频率限制
|
||
KeyMaxSaveSeconds = config.KeyMaxSaveSeconds
|
||
KeyMaxSaveCount = config.KeyMaxSaveCount
|
||
KeyExpireStyle = config.KeyExpireStyle
|
||
KeyUploadCount = config.KeyUploadCount
|
||
KeyUploadMinute = config.KeyUploadMinute
|
||
// 需求 ④⑩ 存储策略
|
||
KeyUploadSize = config.KeyUploadSize
|
||
KeyMaxFileSize = config.KeyMaxFileSize
|
||
KeyAllowedTypes = config.KeyAllowedTypes
|
||
KeyStorageLimit = config.KeyStorageLimit
|
||
KeyOpenUpload = config.KeyOpenUpload
|
||
// v3 存储引擎
|
||
KeyStorageEngine = config.KeyStorageEngine
|
||
)
|
||
|
||
// —— 取值边界 re-export ——
|
||
const (
|
||
MaxSaveSecondsMax = config.MaxSaveSecondsMax // 最长保存秒数上限(365 天)
|
||
MaxSaveCountMax = config.MaxSaveCountMax // 保存次数上限
|
||
MaxFileSizeMax = config.MaxFileSizeMax // 单文件大小上限(10 GiB)
|
||
BackgroundURLMaxLen = config.BackgroundURLMaxLen // 背景图 URL 长度上限
|
||
FooterTextMaxLen = config.FooterTextMaxLen // 页脚内容长度上限
|
||
FooterBeianMaxLen = config.FooterBeianMaxLen // 备案号长度上限
|
||
NotifyTitleMaxLen = config.NotifyTitleMaxLen // 通知标题长度上限
|
||
NotifyContentMaxLen = config.NotifyContentMaxLen // 通知内容长度上限
|
||
)
|
||
|
||
// 敏感键:不允许出现在管理端 config get 下发/前端可见集合中(双模式下一致生效)。
|
||
// v3:引擎凭据(webdav_password/s3_secret_access_key/aws_session_token)加入敏感集——
|
||
// 管理端 get 返回掩码占位,update 时空串/掩码=不修改;公开 config 永不下发。
|
||
var SensitiveKeys = []string{
|
||
"admin_token", "jwt_secret",
|
||
"webdav_password", "s3_secret_access_key", "aws_session_token",
|
||
}
|
||
|
||
// SensitiveMaskValue 敏感键掩码占位(管理端 get 展示用)。
|
||
const SensitiveMaskValue = "******"
|
||
|
||
// IsSensitiveKey 判断键是否为敏感键(config get 必须屏蔽)。
|
||
func IsSensitiveKey(key string) bool {
|
||
for _, k := range SensitiveKeys {
|
||
if k == key {
|
||
return true
|
||
}
|
||
}
|
||
return false
|
||
}
|
||
|
||
// KVSchema 返回 v2 全量配置键元数据(键名/类型/默认值/边界/说明)。
|
||
// 默认值必须与 config defaults() 一致(schema 同步测试保证)。
|
||
func KVSchema() []config.KVSchemaEntry { return config.KVSchema() }
|
||
|
||
// KVSchemaByKey 以键名为索引查看 schema;未知键返回 nil。
|
||
func KVSchemaByKey(key string) *config.KVSchemaEntry {
|
||
for i := range config.KVSchema() {
|
||
if config.KVSchema()[i].Key == key {
|
||
return &config.KVSchema()[i]
|
||
}
|
||
}
|
||
return nil
|
||
}
|