first commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package setting
|
||||
|
||||
// ServerSettingS 服务配置。时间字段单位为秒(int),避免 time.Duration 对整数配置按纳秒解析的歧义。
|
||||
type ServerSettingS struct {
|
||||
Domain string // 服务域名(用于 CORS 允许来源)
|
||||
RunMode string
|
||||
HttpPort string
|
||||
ReadTimeout int // 秒
|
||||
WriteTimeout int // 秒
|
||||
}
|
||||
|
||||
type LogSettingS struct {
|
||||
LogSavePath string
|
||||
LogFileName string
|
||||
LogFileExt string
|
||||
MaxSize int
|
||||
MaxBackups int
|
||||
MaxAge int
|
||||
LogLevel string
|
||||
}
|
||||
|
||||
type MysqlSettingS struct {
|
||||
UserName string
|
||||
Password string
|
||||
Host string
|
||||
Port int
|
||||
DBName string
|
||||
MaxIdleConns int
|
||||
MaxOpenConns int
|
||||
ConnMaxLifeTime int
|
||||
ConnMaxIdleTime int
|
||||
}
|
||||
|
||||
type RedisSettingS struct {
|
||||
Host string
|
||||
Port int
|
||||
Password string
|
||||
DB int
|
||||
PoolSize int
|
||||
MaxIdleConns int
|
||||
MinIdleConns int
|
||||
MaxRetryBackoff int
|
||||
MinRetryBackoff int
|
||||
MaxRetries int
|
||||
DialTimeout int
|
||||
ReadTimeout int
|
||||
WriteTimeout int
|
||||
PoolTimeout int
|
||||
}
|
||||
|
||||
type OtelSettingS struct {
|
||||
Enabled bool
|
||||
ServiceName string
|
||||
ServiceVersion string
|
||||
Environment string
|
||||
ExporterEndpoint string
|
||||
Insecure bool
|
||||
SamplerRatio float64
|
||||
}
|
||||
|
||||
type JWTSettingS struct {
|
||||
SecretKey string
|
||||
Issuer string
|
||||
AccessTokenExpire int // 秒
|
||||
RefreshTokenExpire int // 秒
|
||||
}
|
||||
|
||||
// AdminSettingS 管理后台专属配置。
|
||||
type AdminSettingS struct {
|
||||
InitialUsername string // 初始超级管理员账号(服务启动时幂等创建)
|
||||
InitialPassword string // 初始超级管理员密码(明文仅存配置,入库为 bcrypt 哈希)
|
||||
}
|
||||
|
||||
// QuotaSettingS 免费额度底值配置(用于管理后台计算并展示「总额度」)。
|
||||
// 必须与业务服务(zt-closet-backend)的 UserDefaultQuota 免费值保持一致;
|
||||
// 使用指针类型以区分「未配置」与「显式配置为 0」,未配置或负数回落内置默认 20/3/10/5。
|
||||
type QuotaSettingS struct {
|
||||
Cos *int64 // 免费上传额度(永久,不每天重置)
|
||||
AI *int64 // 免费 AI 推荐额度(每日,每天 0 点重置)
|
||||
OutfitShare *int64 // 免费社区分享额度(每日)
|
||||
ClosetShare *int64 // 免费衣柜分享额度(每日)
|
||||
}
|
||||
|
||||
// CosSettingS CDN 下载配置(仅用于把衣物图片/头像的相对 COS key 拼接为带鉴权签名的可访问 URL)。
|
||||
// 管理后台与业务服务共用同一 COS,此处的域名与鉴权密钥须与业务服务 configs/config.yaml 的 Cos 段一致。
|
||||
type CosSettingS struct {
|
||||
CosDownloadDomain string // CDN 下载域名
|
||||
CdnDownloadSecretKey string // CDN 下载鉴权密钥(机密,仅存 config.yaml)
|
||||
}
|
||||
|
||||
func (s *Setting) ReadSection(k string, v any) error {
|
||||
err := s.vp.UnmarshalKey(k, v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user