feat: 从黄果 NET hgdjnet-server 9bfbafe 导入 HKDJ 官网后端
来源:hgdjnet-server 9bfbafe10d417deea959bd53117bc88a10e60a83 项目身份 HKDJ / JHA-216,独立官网仓库,Jenkins 守卫键 hkdjnet 测试目录 /server/hkdj_net,App/Web API 30331/30332 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package sms
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hkdj-web-server/pub/common/sms/fengniao"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Provider = int
|
||||
|
||||
const (
|
||||
tmplID1 = "6029f19a99fd8b404062e4d2" // 大陆
|
||||
tmplID2 = "5f8412c39396d16f787e561b" // 非大陆
|
||||
)
|
||||
|
||||
const (
|
||||
FengNiao Provider = 1 //蜂鸟
|
||||
YunPian Provider = 2 //云片
|
||||
)
|
||||
|
||||
func sendByFengNiao(mobile string, code string) error {
|
||||
if os.Getenv("HKDJNET_SMS_CN_SECRET") == "" || os.Getenv("HKDJNET_SMS_GLOBAL_SECRET") == "" {
|
||||
return errors.New("SMS provider is not configured")
|
||||
}
|
||||
var tmplID string
|
||||
if strings.HasPrefix(mobile, "+86") {
|
||||
tmplID = tmplID1
|
||||
return (&fengniao.FengNiao{
|
||||
Url: "https://t9x6k.cc/api/sms/sendSms",
|
||||
MercId: "10177",
|
||||
Secret: os.Getenv("HKDJNET_SMS_CN_SECRET"),
|
||||
Tmpl: tmplID,
|
||||
}).Send(mobile, code)
|
||||
} else {
|
||||
tmplID = tmplID2
|
||||
return (&fengniao.FengNiao{
|
||||
Url: "https://t9x6k.cc/api/sms/sendSms",
|
||||
MercId: "10228",
|
||||
Secret: os.Getenv("HKDJNET_SMS_GLOBAL_SECRET"),
|
||||
Tmpl: tmplID,
|
||||
}).Send(mobile, code)
|
||||
}
|
||||
// return
|
||||
}
|
||||
|
||||
// Send 发送短信
|
||||
func Send(mobile string, code string) error {
|
||||
return sendByFengNiao(mobile, code)
|
||||
}
|
||||
Reference in New Issue
Block a user