新增短信发送激活配置
This commit is contained in:
parent
c104c3a589
commit
54565ed1e5
@ -17,10 +17,19 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@ConfigurationProperties(prefix = "sms")
|
@ConfigurationProperties(prefix = "sms")
|
||||||
public class SmsProperties {
|
public class SmsProperties {
|
||||||
|
|
||||||
|
private Boolean active;
|
||||||
private String type;
|
private String type;
|
||||||
private SmsDefaultProperties defaultSms;
|
private SmsDefaultProperties defaultSms;
|
||||||
private SmsTencentProperties tencentSms;
|
private SmsTencentProperties tencentSms;
|
||||||
|
|
||||||
|
public Boolean getActive() {
|
||||||
|
return active == null ? true : active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(Boolean active) {
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type == null ? "" : type.trim();
|
return type == null ? "" : type.trim();
|
||||||
}
|
}
|
||||||
@ -48,8 +57,10 @@ public class SmsProperties {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder sb = new StringBuilder("{");
|
final StringBuilder sb = new StringBuilder("{");
|
||||||
sb.append("\"type\":")
|
sb.append("\"active\":")
|
||||||
.append("\"").append(type).append("\"");
|
.append(active);
|
||||||
|
sb.append(",\"type\":\"")
|
||||||
|
.append(type).append('\"');
|
||||||
sb.append(",\"defaultSms\":")
|
sb.append(",\"defaultSms\":")
|
||||||
.append(defaultSms);
|
.append(defaultSms);
|
||||||
sb.append(",\"tencentSms\":")
|
sb.append(",\"tencentSms\":")
|
||||||
|
@ -180,6 +180,9 @@ public class SmsServiceImpl extends AbstractService implements ISmsService {
|
|||||||
@Override
|
@Override
|
||||||
public void saveSms(String phone, String content) throws Exception {
|
public void saveSms(String phone, String content) throws Exception {
|
||||||
LOG.info(">>>>> 向手机号:{},发送短信:{}", phone, content);
|
LOG.info(">>>>> 向手机号:{},发送短信:{}", phone, content);
|
||||||
|
if (!smsProperties.getActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (StringUtils.equals(TENCENT_TYPE, smsProperties.getType())) {
|
if (StringUtils.equals(TENCENT_TYPE, smsProperties.getType())) {
|
||||||
tencentSms(phone, content);
|
tencentSms(phone, content);
|
||||||
} else {
|
} else {
|
||||||
@ -218,12 +221,14 @@ public class SmsServiceImpl extends AbstractService implements ISmsService {
|
|||||||
|
|
||||||
private void sendCode(String phone, String code) throws Exception {
|
private void sendCode(String phone, String code) throws Exception {
|
||||||
LOG.info(">>>>> 向手机号:{},发送验证码:{}", phone, code);
|
LOG.info(">>>>> 向手机号:{},发送验证码:{}", phone, code);
|
||||||
|
if (!smsProperties.getActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (StringUtils.equals(TENCENT_TYPE, smsProperties.getType())) {
|
if (StringUtils.equals(TENCENT_TYPE, smsProperties.getType())) {
|
||||||
tencentSmsCode(phone, code);
|
tencentSmsCode(phone, code);
|
||||||
} else {
|
} else {
|
||||||
defaultSmsCode(phone, code);
|
defaultSmsCode(phone, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user