修改配置
This commit is contained in:
+22
-22
@@ -19,13 +19,13 @@ import (
|
||||
type Aliyun struct {
|
||||
interfaces.DefaultSmsx
|
||||
client *dysmsapi20170525.Client
|
||||
params entity.SmsConfigData
|
||||
params consts.SmsConfigData
|
||||
logger loggerx.LoggerInterface
|
||||
}
|
||||
|
||||
func (l *Aliyun) InitSmsx(ctx context.Context, params entity.SmsConfigData, logger loggerx.LoggerInterface) (interfaces.Smsx, error) {
|
||||
func (l *Aliyun) InitSmsx(ctx context.Context, params consts.SmsConfigData, logger loggerx.LoggerInterface) (interfaces.Smsx, error) {
|
||||
l.logger = logger
|
||||
if params.SysType != entity.Platform3rdTypeAliyun {
|
||||
if params.SysType != consts.Platform3rdTypeAliyun {
|
||||
return nil, errors.New("not aliyun")
|
||||
}
|
||||
|
||||
@@ -233,9 +233,9 @@ func (l *Aliyun) getTemp(ctx context.Context, page int32) ([]interfaces.Template
|
||||
for _, val := range resp.Body.SmsTemplateList {
|
||||
s := l.extractParams(tea.StringValue(val.TemplateContent))
|
||||
|
||||
params := []entity.SmsTemplateParam{}
|
||||
params := []consts.SmsTemplateParam{}
|
||||
for _, p := range s {
|
||||
params = append(params, entity.SmsTemplateParam{
|
||||
params = append(params, consts.SmsTemplateParam{
|
||||
FieldName: p,
|
||||
})
|
||||
}
|
||||
@@ -339,7 +339,7 @@ func (l *Aliyun) TempDel(ctx context.Context, templateId string) error {
|
||||
}
|
||||
|
||||
// 审核状态转换 短信平台=>本地
|
||||
func (l *Aliyun) auditStatusPlatToLocal(status string) entity.SmsTemplateStatus {
|
||||
func (l *Aliyun) auditStatusPlatToLocal(status string) consts.SmsTemplateStatus {
|
||||
|
||||
// AUDIT_STATE_INIT:审核中。
|
||||
// AUDIT_STATE_PASS:通过审核。
|
||||
@@ -349,21 +349,21 @@ func (l *Aliyun) auditStatusPlatToLocal(status string) entity.SmsTemplateStatus
|
||||
|
||||
switch status {
|
||||
case "AUDIT_STATE_INIT":
|
||||
return entity.SmsTemplateStatusAudit
|
||||
return consts.SmsTemplateStatusAudit
|
||||
case "AUDIT_STATE_PASS":
|
||||
return entity.SmsTemplateStatusPass
|
||||
return consts.SmsTemplateStatusPass
|
||||
case "AUDIT_STATE_NOT_PASS":
|
||||
return entity.SmsTemplateStatusUnPass
|
||||
return consts.SmsTemplateStatusUnPass
|
||||
case "AUDIT_STATE_CANCEL":
|
||||
return entity.SmsTemplateStatusCancel
|
||||
return consts.SmsTemplateStatusCancel
|
||||
case "AUDIT_SATE_CANCEL":
|
||||
return entity.SmsTemplateStatusCancel
|
||||
return consts.SmsTemplateStatusCancel
|
||||
default:
|
||||
return entity.SmsTemplateStatusUnknown
|
||||
return consts.SmsTemplateStatusUnknown
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Aliyun) tempTypePlatToLocal(platType int32) entity.SmsTemplateType {
|
||||
func (l *Aliyun) tempTypePlatToLocal(platType int32) consts.SmsTemplateType {
|
||||
// 0:验证码短信。
|
||||
// 1:通知短信。
|
||||
// 2:推广短信。
|
||||
@@ -372,26 +372,26 @@ func (l *Aliyun) tempTypePlatToLocal(platType int32) entity.SmsTemplateType {
|
||||
|
||||
switch platType {
|
||||
case 0:
|
||||
return entity.SmsTemplateTypeVerifyCode
|
||||
return consts.SmsTemplateTypeVerifyCode
|
||||
case 1:
|
||||
return entity.SmsTemplateTypeNotice
|
||||
return consts.SmsTemplateTypeNotice
|
||||
case 2:
|
||||
return entity.SmsTemplateTypePromotion
|
||||
return consts.SmsTemplateTypePromotion
|
||||
case 3:
|
||||
return entity.SmsTemplateTypeInternational
|
||||
return consts.SmsTemplateTypeInternational
|
||||
case 7:
|
||||
return entity.SmsTemplateTypeDigital
|
||||
return consts.SmsTemplateTypeDigital
|
||||
default:
|
||||
return entity.SmsTemplateTypeUnknown
|
||||
return consts.SmsTemplateTypeUnknown
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Aliyun) tempRangePlatToLocal(platType int32) entity.SmsTemplateRange {
|
||||
func (l *Aliyun) tempRangePlatToLocal(platType int32) consts.SmsTemplateRange {
|
||||
// 非国际/港澳台短信。
|
||||
if platType == 3 {
|
||||
return entity.SmsTemplateRangeInternational
|
||||
return consts.SmsTemplateRangeInternational
|
||||
}
|
||||
return entity.SmsTemplateRangeChina
|
||||
return consts.SmsTemplateRangeChina
|
||||
}
|
||||
|
||||
// 提取参数
|
||||
|
||||
@@ -16,9 +16,9 @@ func TestSend(t *testing.T) {
|
||||
|
||||
logger := loggerx.NewLogger(ctx)
|
||||
|
||||
params := entity.SmsConfigData{
|
||||
SysType: entity.Platform3rdTypeAliyun,
|
||||
Aliyun: &entity.SmsConfigDataAliyun{
|
||||
params := consts.SmsConfigData{
|
||||
SysType: consts.Platform3rdTypeAliyun,
|
||||
Aliyun: &consts.SmsConfigDataAliyun{
|
||||
AccessKeyId: "LTAI5tSgopmbntKXnq8ESrvh",
|
||||
AccessKeySecret: "BEgEFCOh4eokzhg8EfxeETbSk4B2UJ",
|
||||
SignName: "深圳展鸣科技",
|
||||
@@ -46,9 +46,9 @@ func TestGetTemp(t *testing.T) {
|
||||
|
||||
logger := loggerx.NewLogger(ctx)
|
||||
|
||||
params := entity.SmsConfigData{
|
||||
SysType: entity.Platform3rdTypeAliyun,
|
||||
Aliyun: &entity.SmsConfigDataAliyun{
|
||||
params := consts.SmsConfigData{
|
||||
SysType: consts.Platform3rdTypeAliyun,
|
||||
Aliyun: &consts.SmsConfigDataAliyun{
|
||||
AccessKeyId: "LTAI5tSgopmbntKXnq8ESrvh",
|
||||
AccessKeySecret: "BEgEFCOh4eokzhg8EfxeETbSk4B2UJ",
|
||||
SignName: "深圳展鸣科技",
|
||||
|
||||
Reference in New Issue
Block a user