Commit a0d5103c authored by 耿迪迪's avatar 耿迪迪

语音服务修改 gengdidi

parent 85a19eb0
......@@ -19,6 +19,13 @@ public class SendBatchSms extends BaseRequestModel{
@NotBlank(message = "短信模板不能为空")
private String templateCode;
/**
* 群发短信签名
* [\"泽宏云\",\"泽宏云\"]
*/
@NotBlank(message = "短信签名不能为空")
private String signNameJson;
/**
* [{\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"},{\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"}]
* 群发短信变量
......
......@@ -22,6 +22,12 @@ public class SendSms extends BaseRequestModel {
@NotBlank(message = "短信模板不能为空")
private String templateCode;
/**
* 短信签名
*/
@NotBlank(message = "短信签名不能为空")
private String signName;
/**
* 模板变量
* {\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"}
......
package com.zehong.communication.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsRequest;
......@@ -20,8 +19,6 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Arrays;
@Service
public class SmsServiceImpl implements SmsService {
......@@ -31,12 +28,6 @@ public class SmsServiceImpl implements SmsService {
@Value("${accessKeySecret}")
private String accessKeySecret;
@Value("${signName}")
private String signName;
@Value("${signNameJson}")
private String signNameJson;
/**
* 短信API产品名称(短信产品名固定,无需修改)
*/
......@@ -58,7 +49,14 @@ public class SmsServiceImpl implements SmsService {
accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", PRODUCT, DOMAIN);
IAcsClient acsClient = new DefaultAcsClient(profile);
SendSmsRequest request = getSmsRequest();
//组装请求对象
SendSmsRequest request = new SendSmsRequest();
//使用post提交
request.setMethod(MethodType.POST);
//必填:短信签名-可在短信控制台中找到
request.setSignName(sendSms.getSignName());
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request.setOutId("yourOutId");
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000”
request.setPhoneNumbers(sendSms.getPhoneNumber());
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
......@@ -97,7 +95,7 @@ public class SmsServiceImpl implements SmsService {
//"[\"1500000000\",\"1500000001\"]"
request.setPhoneNumberJson(sendBatchSms.getPhoneNumberJson());
//必填:短信签名-支持不同的号码发送不同的短信签名
request.setSignNameJson(signNameJson);
request.setSignNameJson(sendBatchSms.getSignNameJson());
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode(sendBatchSms.getTemplateCode());
//必填:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
......@@ -116,15 +114,4 @@ public class SmsServiceImpl implements SmsService {
return new Result(ResultEnum.FAIL.getCode(),sendSmsResponse.getMessage());
}
private SendSmsRequest getSmsRequest(){
//组装请求对象
SendSmsRequest request = new SendSmsRequest();
//使用post提交
request.setMethod(MethodType.POST);
//必填:短信签名-可在短信控制台中找到
request.setSignName(signName);
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request.setOutId("yourOutId");
return request;
}
}
......@@ -33,13 +33,9 @@ appKey: IE5F7Jih
#批量发送语音
batchVoiceNotifyURL: https://api.253.com/open/notify/batch-voice-notify
#阿里云发送短信
#阿里云发送短信或批量发送短信
accessKeyId: LTAI2xiZNF3iV2aV
accessKeySecret: bprEWwn1M0xgglRQCQEMYSPiYctDk4
signName: 泽宏云
#阿里批量发送短信
signNameJson: "[\"泽宏云\"]"
#ip白名单
iPWhite: 192.168.2.23
......
......@@ -5,8 +5,8 @@ log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c - %L]%m%n
log4j.appender.File = org.apache.log4j.DailyRollingFileAppender
#log4j.appender.File.File = E:/java/work/info.log
log4j.appender.File.File = /data/java/communication/log/info
log4j.appender.File.File = E:/java/work/info
#log4j.appender.File.File = /data/java/communication/log/info
log4j.appender.File.DatePattern= _yyyy-MM-dd'.log'
log4j.appender.File.Append = true
log4j.appender.File.File.MaxFileSize = 30MB
......@@ -18,8 +18,8 @@ log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%
log4j.logger.RequestLog=INFO,S
log4j.additivity.RequestLog = false
log4j.appender.S = org.apache.log4j.DailyRollingFileAppender
#log4j.appender.S.File =E:/java/work/log.log
log4j.appender.S.File = /data/java/communication/log/requestLog
log4j.appender.S.File =E:/java/work/requestLog
#log4j.appender.S.File = /data/java/communication/log/requestLog
log4j.appender.S.DatePattern= _yyyy-MM-dd'.log'
log4j.appender.S.Append = true
log4j.appender.S.Threshold = info
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment