完成文本审查服务开发

This commit is contained in:
GeekMaster
2025-08-31 18:21:09 +08:00
parent 0585edd895
commit 9a4239290b
27 changed files with 896 additions and 164 deletions

View File

@@ -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,

View File

@@ -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
}

View File

@@ -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
}