package org.springblade.sqlfly.config;

import org.springblade.bi.client.model.DataSourceModel;

import lombok.Data;

/**
 * 数据配置类
 * 
 * @author William
 * @date 2022年10月28日 上午11:28:48
 */
@Data
public class DbConfig {
	private String url;
	private String user;
	private String password;
	private DbType dbType;
	private String driver;

	private String dbName;
	private String host;
	private int port;

	public static DbConfig get(DataSourceModel source) {
		DbConfig config = new DbConfig();
		config.setDbType(DbType.reslove(source.getDsType()));
		config.setDriver(source.getDriverClassName());
		config.setPassword(source.getDsPassword());
		config.setUrl(source.getUrl());
		config.setUser(source.getDsUser());
		config.setDbName(source.getDsDb());
		config.setHost(source.getDsIp());
		config.setPort(source.getDsPort());
		return config;
	}

}
