package cn.com.v2.common.config;

import cn.com.v2.util.DataSourceUtil;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
/**
 * 动态数据源类
 * @date 2024/7/24
 */
public class DynamicDataSource extends AbstractRoutingDataSource {
    @Override
    protected Object determineCurrentLookupKey() {
        Object db = DataSourceUtil.getDB();
        if(db==null){
            DataSourceUtil.setDB("v2");
            db = DataSourceUtil.getDB();
        }
        return db;
    }
}
