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