package com.njzscloud.common.mp.config;

import com.njzscloud.common.mp.support.DBTunnel;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "mybatis-plus.tunnel", name = "enable", havingValue = "true")
@EnableConfigurationProperties({DbTunnelProperties.class})
public class DBTunnelAutoConfiguration {

    @Bean(destroyMethod = "close")
    public DBTunnel dbTunnel(DbTunnelProperties dbTunnelProperties) {
        return new DBTunnel(dbTunnelProperties);
    }

}
