初始化

This commit is contained in:
Yun
2024-11-15 18:55:02 +08:00
commit 9ad229dbb7
14 changed files with 1571 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package smsx
import (
"context"
"errors"
"code.yun.ink/pkg/smsx/aliyun"
"code.yun.ink/pkg/smsx/entity"
"code.yun.ink/pkg/smsx/interfaces"
"code.yun.ink/pkg/smsx/tencent"
)
var platform map[entity.Platform3rdType]interfaces.Smsx
// 注册
func init() {
platform = make(map[entity.Platform3rdType]interfaces.Smsx)
// 阿里
platform[entity.Platform3rdTypeAliyun] = &aliyun.Aliyun{}
// 腾讯
platform[entity.Platform3rdTypeTencent] = &tencent.Tencent{}
}
func GetPlatform(ctx context.Context, plat entity.Platform3rdType) (interfaces.Smsx, error) {
iplat, ok := platform[plat]
if ok {
return iplat, nil
}
return nil, errors.New("not found" + string(plat))
}