backend/internal/config/config.go

112 lines
2.7 KiB
Go
Raw Permalink Normal View History

2025-09-30 16:53:31 +00:00
package config
import (
"time"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/rest"
)
2025-09-30 16:53:31 +00:00
type Config struct {
rest.RestConf
// Redis 配置
RedisConf redis.RedisConf
// Redis Cluster (Cache)
Cache cache.CacheConf
CacheExpireTime time.Duration
CacheWithNotFoundExpiry time.Duration
Mongo struct {
Schema string
User string
Password string
Host string
Port string
Database string
ReplicaName string
MaxStaleness time.Duration
MaxPoolSize uint64
MinPoolSize uint64
MaxConnIdleTime time.Duration
Compressors []string
EnableStandardReadWriteSplitMode bool
ConnectTimeoutMs int64
}
// 密碼加密層數
Bcrypt struct {
Cost int
}
GoogleAuth struct {
ClientID string
AuthURL string
}
LineAuth struct {
ClientID string
ClientSecret string
RedirectURI string
}
2025-10-06 08:28:39 +00:00
// JWT Token 配置
Token struct {
2025-10-22 13:40:31 +00:00
AccessSecret string
RefreshSecret string
AccessTokenExpiry time.Duration
RefreshTokenExpiry time.Duration
OneTimeTokenExpiry time.Duration
MaxTokensPerUser int
MaxTokensPerDevice int
}
// RoleConfig 角色配置
RoleConfig struct {
// UID 前綴 (例如: AM, RL)
UIDPrefix string
// UID 數字長度
UIDLength int
// 管理員角色 UID
AdminRoleUID string
// 管理員用戶 UID
AdminUserUID string
// 預設角色名稱
DefaultRoleName string
2025-10-06 08:28:39 +00:00
}
2025-11-08 06:37:41 +00:00
SMTPConfig struct {
Enable bool
GoroutinePoolNum int
Host string
Port int
Username string
Password string
Sender string
SenderName string
}
DeliveryConfig struct {
MaxRetries int `json:"max_retries"` // 最大重試次數
InitialDelay time.Duration `json:"initial_delay"` // 初始重試延遲 (100ms)
BackoffFactor float64 `json:"backoff_factor"` // 指數退避因子 (2.0)
MaxDelay time.Duration `json:"max_delay"` // 最大延遲時間
Timeout time.Duration `json:"timeout"` // 單次發送超時時間
EnableHistory bool `json:"enable_history"` // 是否啟用歷史記錄
}
2025-11-12 06:50:35 +00:00
AmazonS3Settings struct {
Region string
Bucket string
CloudFrontDomain string
CloudFrontURI string
BucketURI string
AccessKey string
SecretKey string
CloudFrontID string
}
2025-09-30 16:53:31 +00:00
}