新增短信、邮箱配置
This commit is contained in:
parent
5d6f4b8a1c
commit
8f17a60faa
@ -0,0 +1,96 @@
|
||||
package ink.wgink.properties.sms;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: EmailProperties
|
||||
* @Description: 邮箱
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/7/31 4:17 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "email")
|
||||
public class EmailProperties {
|
||||
|
||||
private Boolean active = false;
|
||||
private String smtp = "smtp.163.com";
|
||||
private Integer port = 25;
|
||||
private String senderEmail;
|
||||
private String senderPassword;
|
||||
private List<String> ccPersons = new ArrayList<>();
|
||||
|
||||
public Boolean getActive() {
|
||||
return active == null ? false : active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getSmtp() {
|
||||
return smtp == null ? "" : smtp.trim();
|
||||
}
|
||||
|
||||
public void setSmtp(String smtp) {
|
||||
this.smtp = smtp;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getSenderEmail() {
|
||||
return senderEmail == null ? "" : senderEmail.trim();
|
||||
}
|
||||
|
||||
public void setSenderEmail(String senderEmail) {
|
||||
this.senderEmail = senderEmail;
|
||||
}
|
||||
|
||||
public String getSenderPassword() {
|
||||
return senderPassword == null ? "" : senderPassword.trim();
|
||||
}
|
||||
|
||||
public void setSenderPassword(String senderPassword) {
|
||||
this.senderPassword = senderPassword;
|
||||
}
|
||||
|
||||
public List<String> getCcPersons() {
|
||||
return ccPersons;
|
||||
}
|
||||
|
||||
public void setCcPersons(List<String> ccPersons) {
|
||||
this.ccPersons = ccPersons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"active\":")
|
||||
.append(active);
|
||||
sb.append(",\"smtp\":")
|
||||
.append("\"").append(smtp).append("\"");
|
||||
sb.append(",\"port\":")
|
||||
.append(port);
|
||||
sb.append(",\"senderEmail\":")
|
||||
.append("\"").append(senderEmail).append("\"");
|
||||
sb.append(",\"senderPassword\":")
|
||||
.append("\"").append(senderPassword).append("\"");
|
||||
sb.append(",\"ccPersons\":")
|
||||
.append(ccPersons);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package ink.wgink.properties.sms;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SmsDefaultProperties
|
||||
* @Description: 默认短信属性
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/3/10 12:55 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class SmsDefaultProperties {
|
||||
|
||||
private String account;
|
||||
private String password;
|
||||
private String sign;
|
||||
private SmsDefaultTemplateProperties template;
|
||||
|
||||
public String getAccount() {
|
||||
return account == null ? "" : account.trim();
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password == null ? "" : password.trim();
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign == null ? "" : sign.trim();
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public SmsDefaultTemplateProperties getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
||||
public void setTemplate(SmsDefaultTemplateProperties template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package ink.wgink.properties.sms;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SmsDefaultTemplateProperties
|
||||
* @Description: 默认短信模板属性
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/3/10 1:00 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class SmsDefaultTemplateProperties {
|
||||
|
||||
private String verificationCode;
|
||||
|
||||
public String getVerificationCode() {
|
||||
return verificationCode == null || verificationCode.isEmpty() ? "{sign} 您的验证码为 {content}, 有效时间为120秒,若非本人操作,请忽略。" : verificationCode.trim();
|
||||
}
|
||||
|
||||
public void setVerificationCode(String verificationCode) {
|
||||
this.verificationCode = verificationCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"verificationCode\":")
|
||||
.append("\"").append(verificationCode).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package ink.wgink.properties.sms;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SmsConfigProperties
|
||||
* @Description: 短信服务属性
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/3/9 10:14 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "sms")
|
||||
public class SmsProperties {
|
||||
|
||||
private Boolean active;
|
||||
private String type;
|
||||
private SmsDefaultProperties defaultSms;
|
||||
private SmsTencentProperties tencentSms;
|
||||
|
||||
public Boolean getActive() {
|
||||
return active == null ? false : active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type == null ? "" : type.trim();
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public SmsDefaultProperties getDefaultSms() {
|
||||
return defaultSms;
|
||||
}
|
||||
|
||||
public void setDefaultSms(SmsDefaultProperties defaultSms) {
|
||||
this.defaultSms = defaultSms;
|
||||
}
|
||||
|
||||
public SmsTencentProperties getTencentSms() {
|
||||
return tencentSms;
|
||||
}
|
||||
|
||||
public void setTencentSms(SmsTencentProperties tencentSms) {
|
||||
this.tencentSms = tencentSms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"active\":")
|
||||
.append(active);
|
||||
sb.append(",\"type\":\"")
|
||||
.append(type).append('\"');
|
||||
sb.append(",\"defaultSms\":")
|
||||
.append(defaultSms);
|
||||
sb.append(",\"tencentSms\":")
|
||||
.append(tencentSms);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package ink.wgink.properties.sms;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: SmsTencentProperties
|
||||
* @Description: 短信腾讯属性
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/3/10 1:02 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class SmsTencentProperties {
|
||||
|
||||
private String appId;
|
||||
private String appKey;
|
||||
private String smsSign;
|
||||
private String verificationCodeTemplateId;
|
||||
|
||||
public String getAppId() {
|
||||
return appId == null ? "" : appId.trim();
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey == null ? "" : appKey.trim();
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
public String getSmsSign() {
|
||||
return smsSign == null ? "" : smsSign.trim();
|
||||
}
|
||||
|
||||
public void setSmsSign(String smsSign) {
|
||||
this.smsSign = smsSign;
|
||||
}
|
||||
|
||||
public String getVerificationCodeTemplateId() {
|
||||
return verificationCodeTemplateId == null ? "" : verificationCodeTemplateId.trim();
|
||||
}
|
||||
|
||||
public void setVerificationCodeTemplateId(String verificationCodeTemplateId) {
|
||||
this.verificationCodeTemplateId = verificationCodeTemplateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"appId\":")
|
||||
.append("\"").append(appId).append("\"");
|
||||
sb.append(",\"appKey\":")
|
||||
.append("\"").append(appKey).append("\"");
|
||||
sb.append(",\"smsSign\":")
|
||||
.append("\"").append(smsSign).append("\"");
|
||||
sb.append(",\"verificationCodeTemplateId\":")
|
||||
.append("\"").append(verificationCodeTemplateId).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user