修改配置信息

pull/1/head
liushaodong 5 years ago
parent 4440d0cc15
commit b16109c894
  1. 110
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/common/utils/SendSmsgCode.java
  2. 8
      spring-cloud/spring-cloud-config/src/main/resources/properties/emailconf-dev.yml
  3. 8
      spring-cloud/spring-cloud-config/src/main/resources/properties/imjgconf-dev.yml
  4. 20
      spring-cloud/spring-cloud-config/src/main/resources/properties/smsconf-dev.yml

@ -1,30 +1,28 @@
package com.blockchain.server.user.common.utils; package com.blockchain.server.user.common.utils;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import lombok.Data; import lombok.Data;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.util.Arrays;
import java.util.List;
/** /**
* 短信API服务调用  阿里云短信 * 短信API服务调用
**/ **/
@Data @Data
@Configuration @Configuration
@Component @Component
@ConfigurationProperties(prefix = "aliyunsms") @ConfigurationProperties(prefix = "feigesms")
public class SendSmsgCode { public class SendSmsgCode {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@ -34,93 +32,69 @@ public class SendSmsgCode {
private boolean closed;//是否开启 private boolean closed;//是否开启
private long timeout;//超时时间,单位:分钟 private long timeout;//超时时间,单位:分钟
//阿里云 //参数
private String ACCESS_KEY_ID; private String URL;
private String ACCESS_SECRET; private String Account;
private String ENGLISH_MSG; private String Pwd;
private String BIG5_MSG; private String TemplateId_ZH_CN;
private String SginName; private String SignId_ZH_CN;
private String TemplateCode;
private String MSG_CODE_PLACEHOLDER = "${code}";
private String CHINA_CODE = "86"; private String CHINA_CODE = "86";
private String BIG5_CODE = "852,853,886";
//参数
private String TemplateId_ZH_HK;
private String TemplateId_EN_US;
private String SignId_EN_US;
private String SignId_ZH_HK;
private List<String> BIG5_CODE = Arrays.asList(new String[]{"852", "853", "886"});
/** /**
* 请求阿里云短信接口发送短信验证码 * 请求短信接口发送短信验证码
* *
* @param mobile 手机号 * @param mobile 手机号
* @param smsCode 短信验证码 * @param smsCode 短信验证码
* @param templateId 模板ID
* @return * @return
*/ */
@Async @Async
public void sendSmsg(String mobile, String smsCode, String internationalCode, String templateId) { public void sendSmsg(String mobile, String smsCode, String internationalCode) {
if (closed) {//如果没有开启短信,则不发送短信 if (closed) {//如果没有开启短信,则不发送短信
return; return;
} }
DefaultProfile profile = DefaultProfile.getProfile("ap-southeast-1", ACCESS_KEY_ID, ACCESS_SECRET); MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
IAcsClient client = new DefaultAcsClient(profile); requestEntity.add("Account", Account);
CommonRequest request = new CommonRequest(); requestEntity.add("Pwd", Pwd);
request.setMethod(MethodType.POST); requestEntity.add("Content", smsCode);
//域名,请勿修改 //国内手机
request.setDomain("dysmsapi.ap-southeast-1.aliyuncs.com");
//API版本号,请勿修改
request.setVersion("2018-05-01");
//接收号码,格式为:国际码+号码,必填
request.putQueryParameter("To", internationalCode + mobile);
//国际代码
if (CHINA_CODE.equals(internationalCode)) { if (CHINA_CODE.equals(internationalCode)) {
//请求国内服务器发送短信 requestEntity.add("Mobile", mobile);
sendTelCode(mobile, smsCode, internationalCode, templateId); requestEntity.add("TemplateId", TemplateId_ZH_CN);
requestEntity.add("SignId", SignId_ZH_CN);
// //API名称 try {
// request.setAction("SendMessageWithTemplate"); ResponseEntity<String> res = restTemplate.postForEntity(URL, requestEntity, String.class);
// LOG.info("===send sms end==== : {} ", res);
// request.putQueryParameter("From", SginName); } catch (Exception e) {
// request.putQueryParameter("TemplateCode", TemplateCode); e.printStackTrace();
// request.putQueryParameter("TemplateParam", "{\"code\":\"" + smsCode + "\"}"); }
} else { } else {
//API名称 //国际代码
request.setAction("SendMessageToGlobe");
//短信内容,必填
if (BIG5_CODE.contains(internationalCode)) { if (BIG5_CODE.contains(internationalCode)) {
//香港,用繁体 requestEntity.add("SignId", SignId_ZH_HK);
request.putQueryParameter("Message", BIG5_MSG.replace(MSG_CODE_PLACEHOLDER, smsCode)); requestEntity.add("TemplateId", TemplateId_ZH_HK);
} else { } else {
//其他,用英文 requestEntity.add("SignId", SignId_EN_US);
request.putQueryParameter("Message", ENGLISH_MSG.replace(MSG_CODE_PLACEHOLDER, smsCode)); requestEntity.add("TemplateId", TemplateId_EN_US);
} }
try { try {
CommonResponse response = client.getCommonResponse(request); ResponseEntity<String> res = restTemplate.postForEntity(URL, requestEntity, String.class);
LOG.info("===send sms end==== {} ", response.getData()); LOG.info("===send sms end==== : {} ", res);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
} }
/**
* 请求国内服务器发送短信
*/
private void sendTelCode(String mobile, String smsCode, String internationalCode, String templateId) {
String url = "http://47.112.194.145:9220/sendsms";
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
multiValueMap.add("mobile", mobile);
multiValueMap.add("smsCode", smsCode);
multiValueMap.add("internationalCode", internationalCode);
multiValueMap.add("templateId", templateId);
try {
String res = restTemplate.postForEntity(url, multiValueMap, String.class).getBody();
LOG.info("===send sms end==== : {} ", res);
} catch (Exception e) {
e.printStackTrace();
}
} }
} }

@ -1,12 +1,12 @@
#邮件发送方的email #邮件发送方的email
email: email:
fromAccount: flamex333@gmail.com fromAccount: zhixinchain@163.com
#主机名 126邮箱为smtp.126.com,163邮箱为163.smtp.com,QQ为smtp.qq.com #主机名 126邮箱为smtp.126.com,163邮箱为163.smtp.com,QQ为smtp.qq.com
hostName: smtp.gmail.com hostName: 163.smtp.com
#邮件发送方的授权码 #邮件发送方的授权码
authCode: yanhuo888@99 authCode: zxc2019
#邮件发送方的用户名 #邮件发送方的用户名
userName: FLAMEX userName: ZHIXINLIAN
#过期时间,单位:分钟,默认30分钟 #过期时间,单位:分钟,默认30分钟
timeout: 30 timeout: 30
#是否关闭邮箱 关闭(true) | 开启(false) #是否关闭邮箱 关闭(true) | 开启(false)

@ -1,10 +1,10 @@
#极光配置信息 #极光配置信息
JiGuang: JiGuang:
p_type: yanhuo p_type: zhixinlian
appkey: d8496dd94124ee33209f3fc4 appkey: f701f93f8bd22f5aedb4fb08
secret: 7f728916dfb2a81e734c59c4 secret: ea9d66b884aa962579b2c03a
#随机数,随便填 #随机数,随便填
random_str: d8496dd94124ee33209f3fc42019 random_str: d8496dd94124ee33209f3fc41106
api: api:
address: https://api.im.jpush.cn address: https://api.im.jpush.cn
address_v2: https://report.im.jpush.cn/v2 address_v2: https://report.im.jpush.cn/v2

@ -1,9 +1,13 @@
aliyunsms: feigesms:
closed: true closed: false
timeout: 5 timeout: 5
SginName: 焰火网 #国内短信接口
TemplateCode: SMS_10505006 URL: http://api.feige.ee/SmsService/Inter
ACCESS_KEY_ID: LTAI46NrbdbBtAdS Account: 18818574533
ACCESS_SECRET: oG4lZDX0dyH98CQNjSQ9gfTYdc5tj5 Pwd: zxc2019
ENGLISH_MSG: "【FLAME】Your verification code is: ${code}, which is valid within 5 minutes. Please do not disclose it to others." TemplateId_ZH_CN: 38129
BIG5_MSG: 【焰火網】您的驗證碼為:${code},該驗證碼5分鐘內有效,請勿泄漏於他人。 SignId_ZH_CN: 38944
TemplateId_ZH_HK: 38120
TemplateId_EN_US: 38138
SignId_ZH_HK: 38944
SignId_EN_US: 38944

Loading…
Cancel
Save