mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-04-22 11:04:26 +08:00
完成文本审查服务开发
This commit is contained in:
@@ -15,14 +15,14 @@ import (
|
||||
)
|
||||
|
||||
type AliYunSmsService struct {
|
||||
config *types.SmsConfigAli
|
||||
config types.SmsConfigAli
|
||||
client *dysmsapi.Client
|
||||
domain string
|
||||
zoneId string
|
||||
}
|
||||
|
||||
func NewAliYunSmsService(sysConfig *types.SystemConfig) (*AliYunSmsService, error) {
|
||||
config := &sysConfig.SMS.Ali
|
||||
config := sysConfig.SMS.Ali
|
||||
domain := "dysmsapi.aliyuncs.com"
|
||||
zoneId := "cn-hangzhou"
|
||||
|
||||
@@ -40,7 +40,7 @@ func NewAliYunSmsService(sysConfig *types.SystemConfig) (*AliYunSmsService, erro
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
func (s *AliYunSmsService) UpdateConfig(config *types.SmsConfigAli) error {
|
||||
func (s *AliYunSmsService) UpdateConfig(config types.SmsConfigAli) error {
|
||||
client, err := dysmsapi.NewClientWithAccessKey(
|
||||
s.zoneId,
|
||||
config.AccessKey,
|
||||
|
||||
@@ -19,18 +19,18 @@ import (
|
||||
)
|
||||
|
||||
type BaoSmsService struct {
|
||||
config *types.SmsConfigBao
|
||||
config types.SmsConfigBao
|
||||
domain string
|
||||
}
|
||||
|
||||
func NewBaoSmsService(sysConfig *types.SystemConfig) *BaoSmsService {
|
||||
return &BaoSmsService{
|
||||
config: &sysConfig.SMS.Bao,
|
||||
config: sysConfig.SMS.Bao,
|
||||
domain: "api.smsbao.com",
|
||||
}
|
||||
}
|
||||
|
||||
func (s *BaoSmsService) UpdateConfig(config *types.SmsConfigBao) {
|
||||
func (s *BaoSmsService) UpdateConfig(config types.SmsConfigBao) {
|
||||
s.config = config
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,25 @@ func NewSmsManager(sysConfig *types.SystemConfig, aliyun *AliYunSmsService, bao
|
||||
}
|
||||
|
||||
func (m *SmsManager) GetService() Service {
|
||||
if m.active == Ali {
|
||||
switch m.active {
|
||||
case Ali:
|
||||
return m.aliyun
|
||||
case Bao:
|
||||
return m.bao
|
||||
}
|
||||
return m.bao
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SmsManager) SetActive(active string) {
|
||||
m.active = active
|
||||
}
|
||||
|
||||
func (m *SmsManager) UpdateConfig(config types.SMSConfig) {
|
||||
switch config.Active {
|
||||
case Ali:
|
||||
m.aliyun.UpdateConfig(config.Ali)
|
||||
case Bao:
|
||||
m.bao.UpdateConfig(config.Bao)
|
||||
}
|
||||
m.active = config.Active
|
||||
}
|
||||
Reference in New Issue
Block a user