This commit is contained in:
孟帅
2023-04-10 15:31:08 +08:00
parent 075a12ce7e
commit 9ac036a542
35 changed files with 506 additions and 143 deletions

View File

@@ -1,2 +1,38 @@
package sms
import (
"context"
"fmt"
"hotgo/internal/consts"
"hotgo/internal/library/sms/aliyun"
"hotgo/internal/library/sms/tencent"
"hotgo/internal/model"
"hotgo/internal/model/input/sysin"
)
// SmsDrive 短信驱动
type SmsDrive interface {
SendCode(ctx context.Context, in sysin.SendCodeInp, config *model.SmsConfig) (err error)
}
func New(name ...string) SmsDrive {
var (
instanceName = consts.SmsDriveAliYun
drive SmsDrive
)
if len(name) > 0 && name[0] != "" {
instanceName = name[0]
}
switch instanceName {
case consts.SmsDriveAliYun:
drive = &aliyun.Handle
case consts.SmsDriveTencent:
drive = &tencent.Handle
default:
panic(fmt.Sprintf("暂不支持短信驱动:%v", instanceName))
}
return drive
}