package cfg import ( "time" ) // Config 短信验证码配置 type SMSConfig struct { // 区域配置 +86/.../global Regions map[string]RegionConfig `json:"regions"` Default RegionConfig `json:"default"` // 默认区域配置 // 全局配置 Global GlobalConfig `json:"global"` } // RegionConfig 区域配置 type RegionConfig struct { Provider string `json:"provider"` // aliyun, tencent TemplateID string `json:"template_id"` // 模板ID Key string `json:"key"` Secret string `json:"secret"` SignName string `json:"sign_name"` Endpoint string `json:"endpoint"` } // GlobalConfig 全局配置 type GlobalConfig struct { CodeLength int `json:"code_length" usage:"验证码长度,默认6位"` CodeExpiry time.Duration `json:"code_expiry" usage:"验证码有效期,默认5分钟"` SendInterval time.Duration `json:"send_interval" usage:"发送间隔,默认60秒"` MaxAttempts int `json:"max_attempts" usage:"最大重试次数,默认3次"` MaxDailyCount int `json:"max_daily_count" usage:"每日最大发送次数,默认100次,0禁用,-1不限制"` } // DefaultConfig 默认配置 func defaultSMS() *SMSConfig { return &SMSConfig{ Global: GlobalConfig{ CodeLength: 6, CodeExpiry: 5 * time.Minute, SendInterval: 60 * time.Second, MaxAttempts: 3, MaxDailyCount: 100, }, Default: RegionConfig{ Provider: "aliyun", }, } }