+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springblade.core.mp.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * druid 连接池配置
+ *
+ * @author L.cm
+ */
+@Getter
+@Setter
+@ConfigurationProperties("blade.mybatis-plus")
+public class BladeMybatisPlusProperties {
+
+ /**
+ * 是否打印 sql
+ */
+ private boolean sqlLog = true;
+
+ /**
+ * sql 打印正则过滤
+ */
+ private List sqlLogPatterns = new ArrayList<>();
+
+}
diff --git a/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java
index 3fa819f..5bf8d79 100644
--- a/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java
+++ b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/MybatisPlusConfiguration.java
@@ -23,8 +23,8 @@ import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
import org.mybatis.spring.annotation.MapperScan;
import org.springblade.core.mp.intercept.QueryInterceptor;
+import org.springblade.core.mp.logger.SqlLogFilter;
import org.springblade.core.mp.plugins.BladePaginationInterceptor;
-import org.springblade.core.mp.plugins.SqlLogInterceptor;
import org.springblade.core.mp.props.MybatisPlusProperties;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.constant.BladeConstant;
@@ -46,7 +46,10 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
@AutoConfiguration
@AllArgsConstructor
@MapperScan("org.springblade.**.mapper.**")
-@EnableConfigurationProperties(MybatisPlusProperties.class)
+@EnableConfigurationProperties({
+ MybatisPlusProperties.class,
+ BladeMybatisPlusProperties.class
+})
public class MybatisPlusConfiguration {
@@ -101,8 +104,8 @@ public class MybatisPlusConfiguration {
*/
@Bean
@ConditionalOnProperty(value = "blade.mybatis-plus.sql-log", matchIfMissing = true)
- public SqlLogInterceptor sqlLogInterceptor() {
- return new SqlLogInterceptor();
+ public SqlLogFilter sqlLogFilter(BladeMybatisPlusProperties properties) {
+ return new SqlLogFilter(properties);
}
}
diff --git a/blade-starter-mybatis/src/main/java/org/springblade/core/mp/logger/SqlLogFilter.java b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/logger/SqlLogFilter.java
new file mode 100644
index 0000000..a33e555
--- /dev/null
+++ b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/logger/SqlLogFilter.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springblade.core.mp.logger;
+
+import com.alibaba.druid.DbType;
+import com.alibaba.druid.filter.FilterChain;
+import com.alibaba.druid.filter.FilterEventAdapter;
+import com.alibaba.druid.proxy.jdbc.JdbcParameter;
+import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
+import com.alibaba.druid.proxy.jdbc.StatementProxy;
+import com.alibaba.druid.sql.SQLUtils;
+import com.alibaba.druid.util.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.core.mp.config.BladeMybatisPlusProperties;
+import org.springblade.core.tool.utils.StringUtil;
+
+import java.sql.SQLException;
+import java.time.temporal.TemporalAccessor;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * 打印可执行的 sql 日志
+ *
+ *