Files

32 lines
679 B
Go
Raw Permalink Normal View History

2024-11-15 18:55:02 +08:00
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"
)
2024-11-15 19:01:25 +08:00
var platform map[consts.Platform3rdType]interfaces.Smsx
2024-11-15 18:55:02 +08:00
// 注册
func init() {
2024-11-15 19:01:25 +08:00
platform = make(map[consts.Platform3rdType]interfaces.Smsx)
2024-11-15 18:55:02 +08:00
// 阿里
2024-11-15 19:01:25 +08:00
platform[consts.Platform3rdTypeAliyun] = &aliyun.Aliyun{}
2024-11-15 18:55:02 +08:00
// 腾讯
2024-11-15 19:01:25 +08:00
platform[consts.Platform3rdTypeTencent] = &tencent.Tencent{}
2024-11-15 18:55:02 +08:00
}
2024-11-15 19:01:25 +08:00
func GetPlatform(ctx context.Context, plat consts.Platform3rdType) (interfaces.Smsx, error) {
2024-11-15 18:55:02 +08:00
iplat, ok := platform[plat]
if ok {
return iplat, nil
}
return nil, errors.New("not found" + string(plat))
}