package com.lanyuanxiaoyao.service.check.configuration;

import java.util.List;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author lanyuanxiaoyao
 * @date 2024-02-22
 */
@Configuration
@ConfigurationProperties("checker.mysql")
@ConditionalOnProperty(value = "checker.mysql.enabled", matchIfMissing = true)
public class MysqlConfigurationProperties {
    private Boolean enabled = true;
    private List<MysqlInfo> targets;

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public List<MysqlInfo> getTargets() {
        return targets;
    }

    public void setTargets(List<MysqlInfo> targets) {
        this.targets = targets;
    }

    @Override
    public String toString() {
        return "MysqlConfigurationProperties{" +
               "enabled=" + enabled +
               ", targets=" + targets +
               '}';
    }

    public static final class MysqlInfo {
        private String url;
        private String username;
        private String password;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        @Override
        public String toString() {
            return "MysqlInfo{" +
                   "url='" + url + '\'' +
                   ", username='" + username + '\'' +
                   ", password='" + password + '\'' +
                   '}';
        }
    }
}
