Documentation
¶
Overview ¶
Package config 基础配置模块
Package config 数据库配置模块 ¶
Package config 分层配置管理器 ¶
Package config 配置管理器 ¶
Package config MCP配置模块 ¶
Package config 存储配置模块 ¶
Package config 配置存储策略 ¶
Package config 上传下载配置模块 ¶
Package config 用户系统配置模块
Index ¶
- type BaseConfig
- func (bc *BaseConfig) Clone() *BaseConfig
- func (bc *BaseConfig) FromMap(data map[string]string) error
- func (bc *BaseConfig) GetAddress() string
- func (bc *BaseConfig) IsLocalhost() bool
- func (bc *BaseConfig) IsPublic() bool
- func (bc *BaseConfig) ToMap() map[string]string
- func (bc *BaseConfig) Update(updates map[string]interface{}) error
- func (bc *BaseConfig) Validate() error
- type BusinessConfig
- type ConfigCategory
- type ConfigManager
- func (cm *ConfigManager) Clone() *ConfigManager
- func (cm *ConfigManager) GetAddress() string
- func (cm *ConfigManager) GetDatabaseDSN() (string, error)
- func (cm *ConfigManager) InitDefaultDataInDB() error
- func (cm *ConfigManager) InitWithDB(db *gorm.DB) error
- func (cm *ConfigManager) IsMCPEnabled() bool
- func (cm *ConfigManager) IsUserSystemEnabled() bool
- func (cm *ConfigManager) LoadFromDatabase() error
- func (cm *ConfigManager) ReloadConfig() error
- func (cm *ConfigManager) Save() error
- func (cm *ConfigManager) SetDB(db *gorm.DB)
- func (cm *ConfigManager) Validate() error
- type ConfigMetadata
- type ConfigStorageStrategy
- func (s *ConfigStorageStrategy) GetConfig(key string, result interface{}) error
- func (s *ConfigStorageStrategy) GetConfigMetadata(key string) (ConfigMetadata, error)
- func (s *ConfigStorageStrategy) InitTables() error
- func (s *ConfigStorageStrategy) ListConfigsByCategory(category ConfigCategory) ([]ConfigMetadata, error)
- func (s *ConfigStorageStrategy) SetConfig(key string, value interface{}) error
- func (s *ConfigStorageStrategy) ValidateConfig(key string, value interface{}) error
- type ConfigStorageType
- type DatabaseConfig
- func (dc *DatabaseConfig) Clone() *DatabaseConfig
- func (dc *DatabaseConfig) FromMap(data map[string]string) error
- func (dc *DatabaseConfig) GetDSN() (string, error)
- func (dc *DatabaseConfig) GetDefaultPort() int
- func (dc *DatabaseConfig) HasPassword() bool
- func (dc *DatabaseConfig) IsMySQL() bool
- func (dc *DatabaseConfig) IsPostgreSQL() bool
- func (dc *DatabaseConfig) IsSQLite() bool
- func (dc *DatabaseConfig) SetPassword(password string)
- func (dc *DatabaseConfig) ToMap() map[string]string
- func (dc *DatabaseConfig) Update(updates map[string]interface{}) error
- func (dc *DatabaseConfig) Validate() error
- type DownloadConfig
- func (dc *DownloadConfig) Clone() *DownloadConfig
- func (dc *DownloadConfig) FromMap(data map[string]string) error
- func (dc *DownloadConfig) GetDownloadTimeoutMinutes() float64
- func (dc *DownloadConfig) IsDownloadConcurrentEnabled() bool
- func (dc *DownloadConfig) ToMap() map[string]string
- func (dc *DownloadConfig) Update(updates map[string]interface{}) error
- func (dc *DownloadConfig) Validate() error
- type LayeredConfigManager
- func (m *LayeredConfigManager) ClearCache()
- func (m *LayeredConfigManager) GetCacheStats() map[string]interface{}
- func (m *LayeredConfigManager) GetConfigByCategory(category ConfigCategory) (map[string]interface{}, error)
- func (m *LayeredConfigManager) InitTables() error
- func (m *LayeredConfigManager) LoadAllConfigs() error
- func (m *LayeredConfigManager) SaveAllConfigs() error
- func (m *LayeredConfigManager) ValidateAllConfigs() error
- type MCPConfig
- func (mc *MCPConfig) Clone() *MCPConfig
- func (mc *MCPConfig) DisableMCP()
- func (mc *MCPConfig) EnableMCP()
- func (mc *MCPConfig) FromMap(data map[string]string) error
- func (mc *MCPConfig) GetMCPAddress() string
- func (mc *MCPConfig) GetMCPPortInt() (int, error)
- func (mc *MCPConfig) IsMCPEnabled() bool
- func (mc *MCPConfig) SetHost(host string) error
- func (mc *MCPConfig) SetPort(port string) error
- func (mc *MCPConfig) ToMap() map[string]string
- func (mc *MCPConfig) Update(updates map[string]interface{}) error
- func (mc *MCPConfig) Validate() error
- type NFSConfig
- type NotificationConfig
- type OneDriveConfig
- type RateLimitConfig
- type RuntimeConfig
- type S3Config
- type StaticConfig
- type StorageConfig
- func (sc *StorageConfig) Clone() *StorageConfig
- func (sc *StorageConfig) FromMap(data map[string]string) error
- func (sc *StorageConfig) IsLocal() bool
- func (sc *StorageConfig) IsNFS() bool
- func (sc *StorageConfig) IsOneDrive() bool
- func (sc *StorageConfig) IsS3() bool
- func (sc *StorageConfig) IsWebDAV() bool
- func (sc *StorageConfig) ToMap() map[string]string
- func (sc *StorageConfig) Validate() error
- type SystemConfig
- type Theme
- type ThemeConfig
- type TransferConfig
- type UploadConfig
- func (uc *UploadConfig) Clone() *UploadConfig
- func (uc *UploadConfig) FromMap(data map[string]string) error
- func (uc *UploadConfig) GetChunkSizeMB() float64
- func (uc *UploadConfig) GetMaxSaveHours() float64
- func (uc *UploadConfig) GetUploadSizeMB() float64
- func (uc *UploadConfig) IsChunkEnabled() bool
- func (uc *UploadConfig) IsUploadEnabled() bool
- func (uc *UploadConfig) ToMap() map[string]string
- func (uc *UploadConfig) Update(updates map[string]interface{}) error
- func (uc *UploadConfig) Validate() error
- type UserSystemConfig
- func (usc *UserSystemConfig) Clone() *UserSystemConfig
- func (usc *UserSystemConfig) DisableEmailVerify()
- func (usc *UserSystemConfig) DisableRegistration()
- func (usc *UserSystemConfig) EnableEmailVerify()
- func (usc *UserSystemConfig) EnableRegistration()
- func (usc *UserSystemConfig) FromMap(data map[string]string) error
- func (usc *UserSystemConfig) GenerateRandomJWTSecret() error
- func (usc *UserSystemConfig) GetSessionDuration() time.Duration
- func (usc *UserSystemConfig) GetSessionExpiryDays() float64
- func (usc *UserSystemConfig) GetUserStorageQuotaGB() float64
- func (usc *UserSystemConfig) GetUserUploadSizeMB() float64
- func (usc *UserSystemConfig) IsEmailVerifyRequired() bool
- func (usc *UserSystemConfig) IsRegistrationAllowed() bool
- func (usc *UserSystemConfig) IsStorageQuotaUnlimited() bool
- func (usc *UserSystemConfig) IsUserSystemEnabled() bool
- func (usc *UserSystemConfig) SetSessionExpiryDays(days int) error
- func (usc *UserSystemConfig) SetUserStorageQuotaGB(quotaGB int64) error
- func (usc *UserSystemConfig) SetUserUploadSizeMB(sizeMB int64) error
- func (usc *UserSystemConfig) ToMap() map[string]string
- func (usc *UserSystemConfig) Update(updates map[string]interface{}) error
- func (usc *UserSystemConfig) Validate() error
- type WebDAVConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseConfig ¶
type BaseConfig struct {
Name string `json:"name"`
Description string `json:"description"`
Keywords string `json:"keywords"`
Port int `json:"port"`
Host string `json:"host"`
DataPath string `json:"data_path"`
Production bool `json:"production"`
}
BaseConfig 基础配置
func (*BaseConfig) FromMap ¶
func (bc *BaseConfig) FromMap(data map[string]string) error
FromMap 从map加载配置
func (*BaseConfig) Update ¶
func (bc *BaseConfig) Update(updates map[string]interface{}) error
Update 更新配置
type BusinessConfig ¶
type BusinessConfig struct {
ID uint `gorm:"primaryKey" json:"id"`
ConfigKey string `gorm:"uniqueIndex;size:100" json:"config_key"`
ConfigValue string `gorm:"type:json" json:"config_value"`
Module string `gorm:"size:50;index" json:"module"` // 模块名称
SubModule string `gorm:"size:50;index" json:"sub_module,omitempty"`
IsEnabled bool `gorm:"default:true" json:"is_enabled"`
ValidFrom time.Time `json:"valid_from"`
ValidTo *time.Time `json:"valid_to,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
BusinessConfig 业务配置(通知、限流等)
type ConfigCategory ¶
type ConfigCategory string
ConfigCategory 配置分类
const ( CategoryStatic ConfigCategory = "static" // 静态配置(文件) CategoryRuntime ConfigCategory = "runtime" // 运行时配置(数据库) CategorySystem ConfigCategory = "system" // 系统配置(专用表) CategoryBusiness ConfigCategory = "business" // 业务配置(业务表) )
type ConfigManager ¶
type ConfigManager struct {
Base *BaseConfig `json:"base"`
Database *DatabaseConfig `json:"database"`
Transfer *TransferConfig `json:"transfer"`
Storage *StorageConfig `json:"storage"`
User *UserSystemConfig `json:"user"`
MCP *MCPConfig `json:"mcp"`
// 其他配置字段
NotifyTitle string `json:"notify_title"`
NotifyContent string `json:"notify_content"`
PageExplain string `json:"page_explain"`
ExpireStyle []string `json:"expire_style"`
// 限流配置
UploadMinute int `json:"upload_minute"`
UploadCount int `json:"upload_count"`
ErrorMinute int `json:"error_minute"`
ErrorCount int `json:"error_count"`
// 主题配置
ThemesSelect string `json:"themes_select"`
ThemesChoices []Theme `json:"themes_choices"`
Opacity float64 `json:"opacity"`
Background string `json:"background"`
// 管理配置
AdminToken string `json:"admin_token"`
ShowAdminAddr int `json:"show_admin_address"`
RobotsText string `json:"robots_text"`
// contains filtered or unexported fields
}
ConfigManager 配置管理器
func (*ConfigManager) GetAddress ¶
func (cm *ConfigManager) GetAddress() string
GetAddress 获取服务器完整地址
func (*ConfigManager) GetDatabaseDSN ¶
func (cm *ConfigManager) GetDatabaseDSN() (string, error)
GetDatabaseDSN 获取数据库连接字符串
func (*ConfigManager) InitDefaultDataInDB ¶
func (cm *ConfigManager) InitDefaultDataInDB() error
InitDefaultDataInDB 在数据库中初始化默认配置数据
func (*ConfigManager) InitWithDB ¶
func (cm *ConfigManager) InitWithDB(db *gorm.DB) error
InitWithDB 使用数据库初始化配置管理器
func (*ConfigManager) IsMCPEnabled ¶
func (cm *ConfigManager) IsMCPEnabled() bool
IsMCPEnabled 判断是否启用MCP服务器
func (*ConfigManager) IsUserSystemEnabled ¶
func (cm *ConfigManager) IsUserSystemEnabled() bool
IsUserSystemEnabled 判断是否启用用户系统
func (*ConfigManager) LoadFromDatabase ¶
func (cm *ConfigManager) LoadFromDatabase() error
LoadFromDatabase 从数据库加载配置
func (*ConfigManager) ReloadConfig ¶
func (cm *ConfigManager) ReloadConfig() error
ReloadConfig 重新加载配置(热重载)
type ConfigMetadata ¶
type ConfigMetadata struct {
Key string `json:"key"`
Category ConfigCategory `json:"category"`
StorageType ConfigStorageType `json:"storage_type"`
TableName string `json:"table_name,omitempty"`
FileName string `json:"file_name,omitempty"`
Description string `json:"description"`
Volatile bool `json:"volatile"` // 是否易变
Cacheable bool `json:"cacheable"` // 是否可缓存
Version int `json:"version"` // 配置版本
LastModified time.Time `json:"last_modified"`
}
ConfigMetadata 配置元数据
type ConfigStorageStrategy ¶
type ConfigStorageStrategy struct {
// contains filtered or unexported fields
}
ConfigStorageStrategy 配置存储策略
func NewConfigStorageStrategy ¶
func NewConfigStorageStrategy(db *gorm.DB) *ConfigStorageStrategy
NewConfigStorageStrategy 创建配置存储策略
func (*ConfigStorageStrategy) GetConfig ¶
func (s *ConfigStorageStrategy) GetConfig(key string, result interface{}) error
GetConfig 获取配置
func (*ConfigStorageStrategy) GetConfigMetadata ¶
func (s *ConfigStorageStrategy) GetConfigMetadata(key string) (ConfigMetadata, error)
GetConfigMetadata 获取配置元数据
func (*ConfigStorageStrategy) InitTables ¶
func (s *ConfigStorageStrategy) InitTables() error
InitTables 初始化配置相关表
func (*ConfigStorageStrategy) ListConfigsByCategory ¶
func (s *ConfigStorageStrategy) ListConfigsByCategory(category ConfigCategory) ([]ConfigMetadata, error)
ListConfigsByCategory 按分类列出配置
func (*ConfigStorageStrategy) SetConfig ¶
func (s *ConfigStorageStrategy) SetConfig(key string, value interface{}) error
SetConfig 设置配置
func (*ConfigStorageStrategy) ValidateConfig ¶
func (s *ConfigStorageStrategy) ValidateConfig(key string, value interface{}) error
ValidateConfig 验证配置
type ConfigStorageType ¶
type ConfigStorageType string
ConfigStorageType 配置存储类型
const ( StorageTypeFile ConfigStorageType = "file" // 配置文件 StorageTypeDatabase ConfigStorageType = "database" // 数据库表 StorageTypeKeyValue ConfigStorageType = "keyvalue" // 键值对存储 StorageTypeJSON ConfigStorageType = "json" // JSON配置 )
type DatabaseConfig ¶
type DatabaseConfig struct {
Type string `json:"database_type"` // sqlite, mysql, postgres
Host string `json:"database_host"`
Port int `json:"database_port"`
Name string `json:"database_name"`
User string `json:"database_user"`
Pass string `json:"database_pass"`
SSL string `json:"database_ssl"` // disable, require, verify-full (for postgres)
}
DatabaseConfig 数据库配置
func (*DatabaseConfig) FromMap ¶
func (dc *DatabaseConfig) FromMap(data map[string]string) error
FromMap 从map加载配置
func (*DatabaseConfig) GetDSN ¶
func (dc *DatabaseConfig) GetDSN() (string, error)
GetDSN 获取数据库连接字符串
func (*DatabaseConfig) GetDefaultPort ¶
func (dc *DatabaseConfig) GetDefaultPort() int
GetDefaultPort 获取默认端口
func (*DatabaseConfig) HasPassword ¶
func (dc *DatabaseConfig) HasPassword() bool
HasPassword 检查是否设置了密码
func (*DatabaseConfig) IsPostgreSQL ¶
func (dc *DatabaseConfig) IsPostgreSQL() bool
IsPostgreSQL 判断是否为PostgreSQL数据库
func (*DatabaseConfig) SetPassword ¶
func (dc *DatabaseConfig) SetPassword(password string)
SetPassword 安全地设置密码
func (*DatabaseConfig) Update ¶
func (dc *DatabaseConfig) Update(updates map[string]interface{}) error
Update 更新配置
type DownloadConfig ¶
type DownloadConfig struct {
EnableConcurrentDownload int `json:"enable_concurrent_download"` // 是否启用并发下载
MaxConcurrentDownloads int `json:"max_concurrent_downloads"` // 最大并发下载数
DownloadTimeout int `json:"download_timeout"` // 下载超时时间(秒)
}
DownloadConfig 下载配置
func (*DownloadConfig) FromMap ¶
func (dc *DownloadConfig) FromMap(data map[string]string) error
FromMap 从map加载下载配置
func (*DownloadConfig) GetDownloadTimeoutMinutes ¶
func (dc *DownloadConfig) GetDownloadTimeoutMinutes() float64
GetDownloadTimeoutMinutes 获取下载超时时间(分钟)
func (*DownloadConfig) IsDownloadConcurrentEnabled ¶
func (dc *DownloadConfig) IsDownloadConcurrentEnabled() bool
IsDownloadConcurrentEnabled 判断是否启用并发下载
func (*DownloadConfig) ToMap ¶
func (dc *DownloadConfig) ToMap() map[string]string
ToMap 下载配置转换为map格式
func (*DownloadConfig) Update ¶
func (dc *DownloadConfig) Update(updates map[string]interface{}) error
Update 更新下载配置
type LayeredConfigManager ¶
type LayeredConfigManager struct {
// 配置模块
Base *BaseConfig `json:"base"`
Database *DatabaseConfig `json:"database"`
Transfer *TransferConfig `json:"transfer"`
Storage *StorageConfig `json:"storage"`
User *UserSystemConfig `json:"user"`
MCP *MCPConfig `json:"mcp"`
// 业务配置
Notification *NotificationConfig `json:"notification"`
RateLimit *RateLimitConfig `json:"rate_limit"`
Theme *ThemeConfig `json:"theme"`
// contains filtered or unexported fields
}
LayeredConfigManager 分层配置管理器
func NewLayeredConfigManager ¶
func NewLayeredConfigManager(db *gorm.DB) *LayeredConfigManager
NewLayeredConfigManager 创建分层配置管理器
func (*LayeredConfigManager) ClearCache ¶
func (m *LayeredConfigManager) ClearCache()
ClearCache 清除缓存
func (*LayeredConfigManager) GetCacheStats ¶
func (m *LayeredConfigManager) GetCacheStats() map[string]interface{}
GetCacheStats 获取缓存统计
func (*LayeredConfigManager) GetConfigByCategory ¶
func (m *LayeredConfigManager) GetConfigByCategory(category ConfigCategory) (map[string]interface{}, error)
GetConfigByCategory 按分类获取配置
func (*LayeredConfigManager) InitTables ¶
func (m *LayeredConfigManager) InitTables() error
InitTables 初始化数据库表
func (*LayeredConfigManager) LoadAllConfigs ¶
func (m *LayeredConfigManager) LoadAllConfigs() error
LoadAllConfigs 加载所有配置
func (*LayeredConfigManager) SaveAllConfigs ¶
func (m *LayeredConfigManager) SaveAllConfigs() error
SaveAllConfigs 保存所有配置
func (*LayeredConfigManager) ValidateAllConfigs ¶
func (m *LayeredConfigManager) ValidateAllConfigs() error
ValidateAllConfigs 验证所有配置
type MCPConfig ¶
type MCPConfig struct {
EnableMCPServer int `json:"enable_mcp_server"` // 是否启用 MCP 服务器
MCPPort string `json:"mcp_port"` // MCP 服务器端口
MCPHost string `json:"mcp_host"` // MCP 服务器绑定地址
}
MCPConfig MCP服务器配置
func (*MCPConfig) GetMCPAddress ¶
GetMCPAddress 获取MCP服务器地址
func (*MCPConfig) GetMCPPortInt ¶
GetMCPPortInt 获取MCP端口号(整数)
type NFSConfig ¶
type NFSConfig struct {
Server string `json:"nfs_server"` // NFS服务器地址
Path string `json:"nfs_path"` // NFS路径
MountPoint string `json:"nfs_mount_point"` // 本地挂载点
Version string `json:"nfs_version"` // NFS版本
Options string `json:"nfs_options"` // 挂载选项
Timeout int `json:"nfs_timeout"` // 超时时间(秒)
AutoMount int `json:"nfs_auto_mount"` // 是否自动挂载
RetryCount int `json:"nfs_retry_count"` // 重试次数
SubPath string `json:"nfs_sub_path"` // 子路径
}
NFSConfig NFS存储配置
type NotificationConfig ¶
type NotificationConfig struct {
Title string `json:"title"`
Content string `json:"content"`
Explain string `json:"explain"`
}
NotificationConfig 通知配置
type OneDriveConfig ¶
type OneDriveConfig struct {
Domain string `json:"onedrive_domain"`
ClientID string `json:"onedrive_client_id"`
Username string `json:"onedrive_username"`
Password string `json:"onedrive_password"`
RootPath string `json:"onedrive_root_path"`
Proxy int `json:"onedrive_proxy"`
}
OneDriveConfig OneDrive存储配置
func (*OneDriveConfig) FromMap ¶
func (oc *OneDriveConfig) FromMap(data map[string]string) error
FromMap 从map加载OneDrive配置
func (*OneDriveConfig) ToMap ¶
func (oc *OneDriveConfig) ToMap() map[string]string
ToMap OneDrive配置转换为map格式
type RateLimitConfig ¶
type RateLimitConfig struct {
UploadMinute int `json:"upload_minute"`
UploadCount int `json:"upload_count"`
ErrorMinute int `json:"error_minute"`
ErrorCount int `json:"error_count"`
}
RateLimitConfig 限流配置
type RuntimeConfig ¶
type RuntimeConfig struct {
ID uint `gorm:"primaryKey" json:"id"`
ConfigKey string `gorm:"uniqueIndex;size:100" json:"config_key"`
ConfigValue string `gorm:"type:text" json:"config_value"`
DataType string `gorm:"size:20" json:"data_type"` // string, int, bool, json
Category string `gorm:"size:50;index" json:"category"`
UserID *uint `gorm:"index" json:"user_id,omitempty"` // 用户专属配置
IsGlobal bool `gorm:"default:true" json:"is_global"`
Priority int `gorm:"default:0" json:"priority"` // 优先级
ExpiresAt *time.Time `json:"expires_at,omitempty"` // 过期时间
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
RuntimeConfig 运行时配置(存储在数据库中)
type S3Config ¶
type S3Config struct {
AccessKeyID string `json:"s3_access_key_id"`
SecretAccessKey string `json:"s3_secret_access_key"`
BucketName string `json:"s3_bucket_name"`
EndpointURL string `json:"s3_endpoint_url"`
RegionName string `json:"s3_region_name"`
SignatureVersion string `json:"s3_signature_version"`
Hostname string `json:"s3_hostname"`
Proxy int `json:"s3_proxy"`
SessionToken string `json:"aws_session_token"`
}
S3Config S3存储配置
type StaticConfig ¶
type StaticConfig struct {
ID uint `gorm:"primaryKey" json:"id"`
ConfigKey string `gorm:"uniqueIndex;size:100" json:"config_key"`
ConfigValue string `gorm:"type:text" json:"config_value"`
Category string `gorm:"size:50;index" json:"category"`
Description string `gorm:"size:255" json:"description"`
IsActive bool `gorm:"default:true" json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
StaticConfig 静态配置(存储在文件中)
type StorageConfig ¶
type StorageConfig struct {
Type string `json:"file_storage"` // local, s3, webdav, onedrive, nfs
StoragePath string `json:"storage_path"`
S3 *S3Config `json:"s3,omitempty"`
WebDAV *WebDAVConfig `json:"webdav,omitempty"`
OneDrive *OneDriveConfig `json:"onedrive,omitempty"`
NFS *NFSConfig `json:"nfs,omitempty"`
}
StorageConfig 存储配置
func (*StorageConfig) FromMap ¶
func (sc *StorageConfig) FromMap(data map[string]string) error
FromMap 从map加载存储配置
func (*StorageConfig) IsOneDrive ¶
func (sc *StorageConfig) IsOneDrive() bool
IsOneDrive 判断是否为OneDrive存储
type SystemConfig ¶
type SystemConfig struct {
ID uint `gorm:"primaryKey" json:"id"`
ConfigKey string `gorm:"uniqueIndex;size:100" json:"config_key"`
ConfigValue string `gorm:"type:json" json:"config_value"`
ConfigSchema string `gorm:"type:text" json:"config_schema"` // JSON Schema
Version int `gorm:"default:1" json:"version"`
Environment string `gorm:"size:20;default:'production'" json:"environment"`
IsEncrypted bool `gorm:"default:false" json:"is_encrypted"`
Checksum string `gorm:"size:64" json:"checksum"` // 配置校验和
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SystemConfig 系统配置(存储配置、传输配置等)
type Theme ¶
type Theme struct {
Name string `json:"name"`
Key string `json:"key"`
Author string `json:"author"`
Version string `json:"version"`
}
Theme 主题配置
type ThemeConfig ¶
type ThemeConfig struct {
Select string `json:"select"`
Choices []Theme `json:"choices"`
Opacity float64 `json:"opacity"`
Background string `json:"background"`
}
ThemeConfig 主题配置
type TransferConfig ¶
type TransferConfig struct {
Upload *UploadConfig `json:"upload"`
Download *DownloadConfig `json:"download"`
}
TransferConfig 文件传输配置(包含上传和下载)
func (*TransferConfig) FromMap ¶
func (tc *TransferConfig) FromMap(data map[string]string) error
FromMap 从map加载传输配置
func (*TransferConfig) ToMap ¶
func (tc *TransferConfig) ToMap() map[string]string
ToMap 传输配置转换为map格式
func (*TransferConfig) Update ¶
func (tc *TransferConfig) Update(updates map[string]interface{}) error
Update 更新传输配置
type UploadConfig ¶
type UploadConfig struct {
OpenUpload int `json:"open_upload"` // 是否开启上传 0-禁用 1-启用
UploadSize int64 `json:"upload_size"` // 上传文件大小限制(字节)
EnableChunk int `json:"enable_chunk"` // 是否启用分片上传 0-禁用 1-启用
ChunkSize int64 `json:"chunk_size"` // 分片大小(字节)
MaxSaveSeconds int `json:"max_save_seconds"` // 最大保存时间(秒)
}
UploadConfig 上传配置
func (*UploadConfig) FromMap ¶
func (uc *UploadConfig) FromMap(data map[string]string) error
FromMap 从map加载上传配置
func (*UploadConfig) GetChunkSizeMB ¶
func (uc *UploadConfig) GetChunkSizeMB() float64
GetChunkSizeMB 获取分片大小(MB)
func (*UploadConfig) GetMaxSaveHours ¶
func (uc *UploadConfig) GetMaxSaveHours() float64
GetMaxSaveHours 获取最大保存时间(小时)
func (*UploadConfig) GetUploadSizeMB ¶
func (uc *UploadConfig) GetUploadSizeMB() float64
GetUploadSizeMB 获取上传大小限制(MB)
func (*UploadConfig) IsChunkEnabled ¶
func (uc *UploadConfig) IsChunkEnabled() bool
IsChunkEnabled 判断是否启用分片上传
func (*UploadConfig) IsUploadEnabled ¶
func (uc *UploadConfig) IsUploadEnabled() bool
IsUploadEnabled 判断是否启用上传
func (*UploadConfig) Update ¶
func (uc *UploadConfig) Update(updates map[string]interface{}) error
Update 更新上传配置
type UserSystemConfig ¶
type UserSystemConfig struct {
AllowUserRegistration int `json:"allow_user_registration"` // 是否允许用户注册
RequireEmailVerify int `json:"require_email_verify"` // 是否需要邮箱验证
UserUploadSize int64 `json:"user_upload_size"` // 用户上传文件大小限制
UserStorageQuota int64 `json:"user_storage_quota"` // 用户存储配额
SessionExpiryHours int `json:"session_expiry_hours"` // 用户会话过期时间
MaxSessionsPerUser int `json:"max_sessions_per_user"` // 每个用户最大会话数
JWTSecret string `json:"jwt_secret"` // JWT签名密钥
}
UserSystemConfig 用户系统配置
func NewUserSystemConfig ¶
func NewUserSystemConfig() *UserSystemConfig
NewUserSystemConfig 创建用户系统配置
func (*UserSystemConfig) DisableEmailVerify ¶
func (usc *UserSystemConfig) DisableEmailVerify()
DisableEmailVerify 禁用邮箱验证
func (*UserSystemConfig) DisableRegistration ¶
func (usc *UserSystemConfig) DisableRegistration()
DisableRegistration 禁用用户注册
func (*UserSystemConfig) EnableEmailVerify ¶
func (usc *UserSystemConfig) EnableEmailVerify()
EnableEmailVerify 启用邮箱验证
func (*UserSystemConfig) EnableRegistration ¶
func (usc *UserSystemConfig) EnableRegistration()
EnableRegistration 启用用户注册
func (*UserSystemConfig) FromMap ¶
func (usc *UserSystemConfig) FromMap(data map[string]string) error
FromMap 从map加载配置
func (*UserSystemConfig) GenerateRandomJWTSecret ¶
func (usc *UserSystemConfig) GenerateRandomJWTSecret() error
GenerateRandomJWTSecret 生成随机JWT密钥
func (*UserSystemConfig) GetSessionDuration ¶
func (usc *UserSystemConfig) GetSessionDuration() time.Duration
GetSessionDuration 获取会话持续时间
func (*UserSystemConfig) GetSessionExpiryDays ¶
func (usc *UserSystemConfig) GetSessionExpiryDays() float64
GetSessionExpiryDays 获取会话过期天数
func (*UserSystemConfig) GetUserStorageQuotaGB ¶
func (usc *UserSystemConfig) GetUserStorageQuotaGB() float64
GetUserStorageQuotaGB 获取用户存储配额(GB)
func (*UserSystemConfig) GetUserUploadSizeMB ¶
func (usc *UserSystemConfig) GetUserUploadSizeMB() float64
GetUserUploadSizeMB 获取用户上传大小限制(MB)
func (*UserSystemConfig) IsEmailVerifyRequired ¶
func (usc *UserSystemConfig) IsEmailVerifyRequired() bool
IsEmailVerifyRequired 判断是否需要邮箱验证
func (*UserSystemConfig) IsRegistrationAllowed ¶
func (usc *UserSystemConfig) IsRegistrationAllowed() bool
IsRegistrationAllowed 判断是否允许用户注册
func (*UserSystemConfig) IsStorageQuotaUnlimited ¶
func (usc *UserSystemConfig) IsStorageQuotaUnlimited() bool
IsStorageQuotaUnlimited 判断存储配额是否无限制
func (*UserSystemConfig) IsUserSystemEnabled ¶
func (usc *UserSystemConfig) IsUserSystemEnabled() bool
IsUserSystemEnabled 判断是否启用用户系统 - 始终返回true
func (*UserSystemConfig) SetSessionExpiryDays ¶
func (usc *UserSystemConfig) SetSessionExpiryDays(days int) error
SetSessionExpiryDays 设置会话过期天数
func (*UserSystemConfig) SetUserStorageQuotaGB ¶
func (usc *UserSystemConfig) SetUserStorageQuotaGB(quotaGB int64) error
SetUserStorageQuotaGB 设置用户存储配额(GB)
func (*UserSystemConfig) SetUserUploadSizeMB ¶
func (usc *UserSystemConfig) SetUserUploadSizeMB(sizeMB int64) error
SetUserUploadSizeMB 设置用户上传大小限制(MB)
func (*UserSystemConfig) ToMap ¶
func (usc *UserSystemConfig) ToMap() map[string]string
ToMap 转换为map格式
func (*UserSystemConfig) Update ¶
func (usc *UserSystemConfig) Update(updates map[string]interface{}) error
Update 更新配置
type WebDAVConfig ¶
type WebDAVConfig struct {
Hostname string `json:"webdav_hostname"`
RootPath string `json:"webdav_root_path"`
Proxy int `json:"webdav_proxy"`
URL string `json:"webdav_url"`
Password string `json:"webdav_password"`
Username string `json:"webdav_username"`
}
WebDAVConfig WebDAV存储配置
func (*WebDAVConfig) FromMap ¶
func (wc *WebDAVConfig) FromMap(data map[string]string) error
FromMap 从map加载WebDAV配置
func (*WebDAVConfig) ToMap ¶
func (wc *WebDAVConfig) ToMap() map[string]string
ToMap WebDAV配置转换为map格式