package com.lingniu.ingest.tdenginehistory.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "lingniu.ingest.tdengine-history")
public class TdengineHistoryProperties {

    /**
     * 默认关闭，避免未配置 TDengine 连接时影响现有历史查询服务启动。
     */
    private boolean enabled = false;

    /**
     * TDengine 历史库名。
     */
    private String database = "vehicle_history";

    /**
     * TDengine RESTful JDBC 地址。默认走 6041，部署时可用 TDENGINE_JDBC_URL 覆盖。
     */
    private String jdbcUrl;

    private String username = "root";

    private String password = "taosdata";

    private String driverClassName = "com.taosdata.jdbc.rs.RestfulDriver";

    private int maximumPoolSize = 16;

    private int minimumIdle = 0;

    private long connectionTimeoutMillis = 5000;

    private long initializationFailTimeoutMillis = -1;

    public boolean isEnabled() {
        return enabled;
    }

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

    public String getDatabase() {
        return database;
    }

    public void setDatabase(String database) {
        this.database = database;
    }

    public String getJdbcUrl() {
        if (jdbcUrl == null || jdbcUrl.isBlank()) {
            return "jdbc:TAOS-RS://127.0.0.1:6041/" + database;
        }
        return jdbcUrl;
    }

    public void setJdbcUrl(String jdbcUrl) {
        this.jdbcUrl = jdbcUrl;
    }

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

    public String getDriverClassName() {
        return driverClassName;
    }

    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }

    public int getMaximumPoolSize() {
        return maximumPoolSize;
    }

    public void setMaximumPoolSize(int maximumPoolSize) {
        this.maximumPoolSize = maximumPoolSize;
    }

    public int getMinimumIdle() {
        return minimumIdle;
    }

    public void setMinimumIdle(int minimumIdle) {
        this.minimumIdle = minimumIdle;
    }

    public long getConnectionTimeoutMillis() {
        return connectionTimeoutMillis;
    }

    public void setConnectionTimeoutMillis(long connectionTimeoutMillis) {
        this.connectionTimeoutMillis = connectionTimeoutMillis;
    }

    public long getInitializationFailTimeoutMillis() {
        return initializationFailTimeoutMillis;
    }

    public void setInitializationFailTimeoutMillis(long initializationFailTimeoutMillis) {
        this.initializationFailTimeoutMillis = initializationFailTimeoutMillis;
    }
}
