Files
2024-11-15 19:01:25 +08:00

32 lines
679 B
Go

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