短信接口增加配置

This commit is contained in:
WenG 2022-03-03 16:20:30 +08:00
parent 63bef098c5
commit a56090a64c
2 changed files with 19 additions and 12 deletions

View File

@ -1,5 +1,7 @@
package com.cm.manager.sms.config.properties; package com.cm.manager.sms.config.properties;
import org.apache.commons.lang3.StringUtils;
/** /**
* When you feel like quitting. Think about why you started * When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始 * 当你想要放弃的时候想想当初你为何开始
@ -12,11 +14,20 @@ package com.cm.manager.sms.config.properties;
**/ **/
public class SmsDefaultProperties { public class SmsDefaultProperties {
private String url;
private String account; private String account;
private String password; private String password;
private String sign; private String sign;
private SmsDefaultTemplateProperties template; private SmsDefaultTemplateProperties template;
public String getUrl() {
return StringUtils.isBlank(url) ? "https://dx.ipyy.net/sms.aspx" : url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAccount() { public String getAccount() {
return account == null ? "" : account.trim(); return account == null ? "" : account.trim();
} }
@ -51,16 +62,12 @@ public class SmsDefaultProperties {
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("{"); return "SmsDefaultProperties{" +
sb.append("\"account\":") "url='" + url + '\'' +
.append("\"").append(account).append("\""); ", account='" + account + '\'' +
sb.append(",\"password\":") ", password='" + password + '\'' +
.append("\"").append(password).append("\""); ", sign='" + sign + '\'' +
sb.append(",\"sign\":") ", template=" + template +
.append("\"").append(sign).append("\""); '}';
sb.append(",\"template\":")
.append(template);
sb.append('}');
return sb.toString();
} }
} }

View File

@ -241,7 +241,7 @@ public class SmsServiceImpl extends AbstractService implements ISmsService {
private void defaultSmsCode(String phone, String code) throws Exception { private void defaultSmsCode(String phone, String code) throws Exception {
SmsDefaultProperties smsDefaultProperties = smsProperties.getDefaultSms(); SmsDefaultProperties smsDefaultProperties = smsProperties.getDefaultSms();
String content = smsDefaultProperties.getTemplate().getVerificationCode().replace("{sign}", smsDefaultProperties.getSign()).replace("{content}", code); String content = smsDefaultProperties.getTemplate().getVerificationCode().replace("{sign}", smsDefaultProperties.getSign()).replace("{content}", code);
String url = "https://dx.ipyy.net/sms.aspx?action=send&userid=&account={account}&password={password}&mobile={mobile}&content={content}&sendTime=&extno={extno}"; String url = smsDefaultProperties.getUrl() + "?action=send&userid=&account={account}&password={password}&mobile={mobile}&content={content}&sendTime=&extno={extno}";
String[] paramArray = new String[]{ String[] paramArray = new String[]{
smsDefaultProperties.getAccount(), smsDefaultProperties.getAccount(),
smsDefaultProperties.getPassword(), smsDefaultProperties.getPassword(),