mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	feat: add configuration handler for AliYun SMS signature and template ID
This commit is contained in:
		@@ -52,6 +52,8 @@ type AliYunSmsConfig struct {
 | 
			
		||||
	AccessSecret string
 | 
			
		||||
	Product      string
 | 
			
		||||
	Domain       string
 | 
			
		||||
	Sign         string // 短信签名
 | 
			
		||||
	CodeTempId   string // 验证码短信模板 ID
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type RedisConfig struct {
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AliYunSmsService struct {
 | 
			
		||||
	config *types.AppConfig
 | 
			
		||||
	config *types.AliYunSmsConfig
 | 
			
		||||
	db     *store.LevelDB
 | 
			
		||||
	client *dysmsapi.Client
 | 
			
		||||
}
 | 
			
		||||
@@ -24,7 +24,7 @@ func NewAliYunSmsService(config *types.AppConfig, db *store.LevelDB) (*AliYunSms
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &AliYunSmsService{
 | 
			
		||||
		config: config,
 | 
			
		||||
		config: &config.SmsConfig,
 | 
			
		||||
		db:     db,
 | 
			
		||||
		client: client,
 | 
			
		||||
	}, nil
 | 
			
		||||
@@ -34,10 +34,10 @@ func (s *AliYunSmsService) SendVerifyCode(mobile string, code int) error {
 | 
			
		||||
	// 创建短信请求并设置参数
 | 
			
		||||
	request := dysmsapi.CreateSendSmsRequest()
 | 
			
		||||
	request.Scheme = "https"
 | 
			
		||||
	request.Domain = s.config.SmsConfig.Domain
 | 
			
		||||
	request.Domain = s.config.Domain
 | 
			
		||||
	request.PhoneNumbers = mobile
 | 
			
		||||
	request.SignName = "飞行的蜗牛"
 | 
			
		||||
	request.TemplateCode = "SMS_281460317"
 | 
			
		||||
	request.SignName = s.config.Sign
 | 
			
		||||
	request.TemplateCode = s.config.CodeTempId
 | 
			
		||||
	request.TemplateParam = fmt.Sprintf("{\"code\":\"%d\"}", code) // 短信模板中的参数
 | 
			
		||||
 | 
			
		||||
	// 发送短信
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user