Merge branch 'dev'

This commit is contained in:
lengleng 2020-11-17 16:35:29 +08:00
commit d7bc5f822f
2 changed files with 8 additions and 4 deletions

View File

@ -17,6 +17,7 @@
package com.pig4cloud.pig.common.datasource.config;
import com.baomidou.dynamic.datasource.processor.DsProcessor;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import org.aopalliance.intercept.MethodInvocation;
/**
@ -36,7 +37,12 @@ public class LastParamDsProcessor extends DsProcessor {
*/
@Override
public boolean matches(String key) {
return key.startsWith(LAST_PREFIX);
if (key.startsWith(LAST_PREFIX)) {
// https://github.com/baomidou/dynamic-datasource-spring-boot-starter/issues/213
DynamicDataSourceContextHolder.clear();
return true;
}
return false;
}
/**

View File

@ -21,7 +21,6 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -76,8 +75,6 @@ public class GeneratorServiceImpl implements GeneratorService {
List<GenFormConf> formConfList = genFormConfMapper.selectList(Wrappers.<GenFormConf>lambdaQuery()
.eq(GenFormConf::getTableName, genConfig.getTableName()).orderByDesc(GenFormConf::getCreateTime));
DynamicDataSourceContextHolder.push(genConfig.getDsName());
String tableNames = genConfig.getTableName();
for (String tableName : StrUtil.split(tableNames, StrUtil.DASHED)) {
// 查询表信息
@ -92,6 +89,7 @@ public class GeneratorServiceImpl implements GeneratorService {
return CodeGenUtils.generatorCode(genConfig, table, columns, null, null);
}
}
return MapUtil.empty();
}