From 878aac7abc028778666a69001e8bafcf16c52226 Mon Sep 17 00:00:00 2001 From: jovlog Date: Mon, 16 Nov 2020 17:24:59 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fixing=20a=20bug.=20#I25JZN=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E4=B8=AD=E7=9A=84=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E3=80=81=E4=B8=8B=E8=BD=BD=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/datasource/config/LastParamDsProcessor.java | 8 +++++++- .../pig/codegen/service/impl/GeneratorServiceImpl.java | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/LastParamDsProcessor.java b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/LastParamDsProcessor.java index e7ea493e..87e13f3c 100644 --- a/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/LastParamDsProcessor.java +++ b/pig-common/pig-common-datasource/src/main/java/com/pig4cloud/pig/common/datasource/config/LastParamDsProcessor.java @@ -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; } /** diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java index 71864c57..570ea10e 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java @@ -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 formConfList = genFormConfMapper.selectList(Wrappers.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(); }