package com.cm.manager.sms.config.properties;

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;
    }

    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();
    }
}
