提交 183750d5 编写于 作者: Tyl666's avatar Tyl666

【Liquibase逆向工程】第二版 优化内容

上级 382b2cc7
...@@ -6,6 +6,7 @@ import cn.ibizlab.core.lite.extensions.service.LiteCoreService; ...@@ -6,6 +6,7 @@ import cn.ibizlab.core.lite.extensions.service.LiteCoreService;
import cn.ibizlab.core.lite.service.IDstDataSourceService; import cn.ibizlab.core.lite.service.IDstDataSourceService;
import cn.ibizlab.core.lite.service.impl.DstDataSourceServiceImpl; import cn.ibizlab.core.lite.service.impl.DstDataSourceServiceImpl;
import cn.ibizlab.util.domain.LiquibaseProp; import cn.ibizlab.util.domain.LiquibaseProp;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.creator.BasicDataSourceCreator; import com.baomidou.dynamic.datasource.creator.BasicDataSourceCreator;
...@@ -21,6 +22,7 @@ import org.springframework.context.annotation.Lazy; ...@@ -21,6 +22,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -149,12 +151,24 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl { ...@@ -149,12 +151,24 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
String datasourceMessage = ds.getDsCfg(); String datasourceMessage = ds.getDsCfg();
Map datasourceMap = parseDatasource(datasourceMessage); Map datasourceMap = parseDatasource(datasourceMessage);
if(ObjectUtils.isEmpty(datasourceMap.get("username"))){
throw new BadRequestAlertException("数据源用户名不能为空!","","ibzInit");
}
if(ObjectUtils.isEmpty(datasourceMap.get("password"))){
throw new BadRequestAlertException("数据源密码不能为空!","","ibzInit");
}
if(ObjectUtils.isEmpty(datasourceMap.get("url"))){
throw new BadRequestAlertException("数据源地址不能为空!","","ibzInit");
}
if(ObjectUtils.isEmpty(datasourceMap.get("defaultSchema"))){
throw new BadRequestAlertException("数据源默认数据库不能为空!","","ibzInit");
}
LiquibaseProp lp = new LiquibaseProp(); LiquibaseProp lp = new LiquibaseProp();
lp.setUsername(datasourceMap.get("username") == null?"":datasourceMap.get("username").toString()); lp.setUsername(datasourceMap.get("username") == null?"":datasourceMap.get("username").toString());
lp.setPassword(datasourceMap.get("password") == null?"":datasourceMap.get("password").toString()); lp.setPassword(datasourceMap.get("password") == null?"":datasourceMap.get("password").toString());
lp.setUrl(datasourceMap.get("url") == null?"":datasourceMap.get("url").toString()); lp.setUrl(datasourceMap.get("url") == null?"":datasourceMap.get("url").toString());
lp.setDefaultSchema(datasourceMap.get("defaultSchema") == null?"":datasourceMap.get("defaultSchema").toString()); lp.setDefaultSchema(datasourceMap.get("defaultSchema") == null?"":datasourceMap.get("defaultSchema").toString());
// 调用liquibase逆向工程的逻辑,生成一个xml,并返回一个SysModel对象 // 调用liquibase逆向工程的逻辑,生成一个xml,并返回一个SysModel对象
SysModel sysModel = generateLiquibaseChangeLog.liquibaseGenerateChangeLog(lp,ds.getDsId()); SysModel sysModel = generateLiquibaseChangeLog.liquibaseGenerateChangeLog(lp,ds.getDsId());
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册