From a56090a64ca8fd29ca3a76335487fe9da5e7199d Mon Sep 17 00:00:00 2001 From: WenG <450292408@qq.com> Date: Thu, 3 Mar 2022 16:20:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=8E=A5=E5=8F=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/SmsDefaultProperties.java | 29 ++++++++++++------- .../sms/service/impl/SmsServiceImpl.java | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/cloud-manager-sms/src/main/java/com/cm/manager/sms/config/properties/SmsDefaultProperties.java b/cloud-manager-sms/src/main/java/com/cm/manager/sms/config/properties/SmsDefaultProperties.java index ac77392..e649f70 100644 --- a/cloud-manager-sms/src/main/java/com/cm/manager/sms/config/properties/SmsDefaultProperties.java +++ b/cloud-manager-sms/src/main/java/com/cm/manager/sms/config/properties/SmsDefaultProperties.java @@ -1,5 +1,7 @@ package com.cm.manager.sms.config.properties; +import org.apache.commons.lang3.StringUtils; + /** * When you feel like quitting. Think about why you started * 当你想要放弃的时候,想想当初你为何开始 @@ -12,11 +14,20 @@ package com.cm.manager.sms.config.properties; **/ public class SmsDefaultProperties { + private String url; private String account; private String password; private String sign; 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() { return account == null ? "" : account.trim(); } @@ -51,16 +62,12 @@ public class SmsDefaultProperties { @Override public String toString() { - final StringBuilder sb = new StringBuilder("{"); - sb.append("\"account\":") - .append("\"").append(account).append("\""); - sb.append(",\"password\":") - .append("\"").append(password).append("\""); - sb.append(",\"sign\":") - .append("\"").append(sign).append("\""); - sb.append(",\"template\":") - .append(template); - sb.append('}'); - return sb.toString(); + return "SmsDefaultProperties{" + + "url='" + url + '\'' + + ", account='" + account + '\'' + + ", password='" + password + '\'' + + ", sign='" + sign + '\'' + + ", template=" + template + + '}'; } } diff --git a/cloud-manager-sms/src/main/java/com/cm/manager/sms/service/impl/SmsServiceImpl.java b/cloud-manager-sms/src/main/java/com/cm/manager/sms/service/impl/SmsServiceImpl.java index 72018dd..d86d176 100644 --- a/cloud-manager-sms/src/main/java/com/cm/manager/sms/service/impl/SmsServiceImpl.java +++ b/cloud-manager-sms/src/main/java/com/cm/manager/sms/service/impl/SmsServiceImpl.java @@ -241,7 +241,7 @@ public class SmsServiceImpl extends AbstractService implements ISmsService { private void defaultSmsCode(String phone, String code) throws Exception { SmsDefaultProperties smsDefaultProperties = smsProperties.getDefaultSms(); 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[]{ smsDefaultProperties.getAccount(), smsDefaultProperties.getPassword(),