修改配置
This commit is contained in:
+18
-18
@@ -18,13 +18,13 @@ import (
|
||||
type Tencent struct {
|
||||
interfaces.DefaultSmsx
|
||||
client *sms.Client
|
||||
params entity.SmsConfigData
|
||||
params consts.SmsConfigData
|
||||
logger loggerx.LoggerInterface
|
||||
}
|
||||
|
||||
func (l *Tencent) InitSmsx(ctx context.Context, params entity.SmsConfigData, logger loggerx.LoggerInterface) (interfaces.Smsx, error) {
|
||||
func (l *Tencent) InitSmsx(ctx context.Context, params consts.SmsConfigData, logger loggerx.LoggerInterface) (interfaces.Smsx, error) {
|
||||
l.logger = logger
|
||||
if params.SysType != entity.Platform3rdTypeTencent || params.Tencent == nil {
|
||||
if params.SysType != consts.Platform3rdTypeTencent || params.Tencent == nil {
|
||||
return nil, errors.New("not tencent")
|
||||
}
|
||||
|
||||
@@ -289,10 +289,10 @@ func (l *Tencent) getTemp(ctx context.Context, page uint64, internal uint64) ([]
|
||||
if val.TemplateContent != nil {
|
||||
info.Content = *val.TemplateContent
|
||||
|
||||
p := []entity.SmsTemplateParam{}
|
||||
p := []consts.SmsTemplateParam{}
|
||||
s := l.extractParams(*val.TemplateContent)
|
||||
for _, v := range s {
|
||||
p = append(p, entity.SmsTemplateParam{
|
||||
p = append(p, consts.SmsTemplateParam{
|
||||
FieldName: v,
|
||||
})
|
||||
}
|
||||
@@ -325,41 +325,41 @@ func (l *Tencent) TempDel(ctx context.Context, templateId string) error {
|
||||
}
|
||||
|
||||
// 判断作用范围
|
||||
func (l *Tencent) tempRangePlatToLocal(plat uint64) entity.SmsTemplateRange {
|
||||
func (l *Tencent) tempRangePlatToLocal(plat uint64) consts.SmsTemplateRange {
|
||||
// 是否国际/港澳台短信,其中0表示国内短信,1表示国际/港澳台短信,3表示该模板既支持国内短信也支持国际/港澳台短信。
|
||||
switch plat {
|
||||
case 0:
|
||||
return entity.SmsTemplateRangeChina
|
||||
return consts.SmsTemplateRangeChina
|
||||
case 1:
|
||||
return entity.SmsTemplateRangeInternational
|
||||
return consts.SmsTemplateRangeInternational
|
||||
case 3:
|
||||
return entity.SmsTemplateRangeGlobal
|
||||
return consts.SmsTemplateRangeGlobal
|
||||
default:
|
||||
return entity.SmsTemplateRangeChina // 若未找到匹配项,默认为国内短信
|
||||
return consts.SmsTemplateRangeChina // 若未找到匹配项,默认为国内短信
|
||||
}
|
||||
}
|
||||
|
||||
// 审核状态转换
|
||||
func (l *Tencent) auditStatusPlatToLocal(plat int64) entity.SmsTemplateStatus {
|
||||
func (l *Tencent) auditStatusPlatToLocal(plat int64) consts.SmsTemplateStatus {
|
||||
// 申请模板状态,其中0表示审核通过且已生效,1表示审核中,2表示审核通过待生效,-1表示审核未通过或审核失败。注:只有状态值为0时该模板才能使用。
|
||||
switch plat {
|
||||
case 0:
|
||||
return entity.SmsTemplateStatusPass
|
||||
return consts.SmsTemplateStatusPass
|
||||
case 1:
|
||||
return entity.SmsTemplateStatusAudit
|
||||
return consts.SmsTemplateStatusAudit
|
||||
case 2:
|
||||
return entity.SmsTemplateStatusAudit
|
||||
return consts.SmsTemplateStatusAudit
|
||||
case -1:
|
||||
return entity.SmsTemplateStatusUnPass
|
||||
return consts.SmsTemplateStatusUnPass
|
||||
default:
|
||||
return entity.SmsTemplateStatusUnPass // 若未找到匹配项,默认为审核未通过或审核失败
|
||||
return consts.SmsTemplateStatusUnPass // 若未找到匹配项,默认为审核未通过或审核失败
|
||||
}
|
||||
}
|
||||
|
||||
// 模板类型转换(查询接口没返回)
|
||||
func (l *Tencent) tempTypePlatToLocal(plat uint64) entity.SmsTemplateType {
|
||||
func (l *Tencent) tempTypePlatToLocal(plat uint64) consts.SmsTemplateType {
|
||||
// 是否国际/港澳台短信,其中0表示国内短信,1表示国际/港澳台短信,3表示该模板既支持国内短信也支持国际/港澳台短信。
|
||||
return entity.SmsTemplateTypeUnknown
|
||||
return consts.SmsTemplateTypeUnknown
|
||||
}
|
||||
|
||||
// 提取参数
|
||||
|
||||
@@ -29,9 +29,9 @@ func TestGetTemp(t *testing.T) {
|
||||
|
||||
ten := tencent.Tencent{}
|
||||
|
||||
ini, err := ten.InitSmsx(ctx, entity.SmsConfigData{
|
||||
SysType: entity.Platform3rdTypeTencent,
|
||||
Tencent: &entity.SmsConfigDataTencent{
|
||||
ini, err := ten.InitSmsx(ctx, consts.SmsConfigData{
|
||||
SysType: consts.Platform3rdTypeTencent,
|
||||
Tencent: &consts.SmsConfigDataTencent{
|
||||
SecretId: "AKIDb2b8SefT8YjgUBk8N0XtANMSZWFqLiIp",
|
||||
SecretKey: "QxqstqipqkTzfKqGVdgr3Merx0uvoU3R",
|
||||
SignName: "深圳宏建源贸易",
|
||||
@@ -69,9 +69,9 @@ func TestSend(t *testing.T) {
|
||||
// SmsSdkAppId: "1400932084",
|
||||
// },
|
||||
|
||||
ini, err := ten.InitSmsx(ctx, entity.SmsConfigData{
|
||||
SysType: entity.Platform3rdTypeTencent,
|
||||
Tencent: &entity.SmsConfigDataTencent{
|
||||
ini, err := ten.InitSmsx(ctx, consts.SmsConfigData{
|
||||
SysType: consts.Platform3rdTypeTencent,
|
||||
Tencent: &consts.SmsConfigDataTencent{
|
||||
SecretId: "AKIDb2b8SefT8YjgUBk8N0XtANMSZWFqLiIp",
|
||||
SecretKey: "QxqstqipqkTzfKqGVdgr3Merx0uvoU3R",
|
||||
SignName: "深圳宏建源贸易",
|
||||
|
||||
Reference in New Issue
Block a user