From a92f479733b438d1cadb8a1906db62046c357c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com> Date: Thu, 2 Jan 2025 12:40:32 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=B0=83=E6=95=B4=20sql=20?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/config/BladeMybatisPlusProperties.java | 5 ----- .../springblade/core/mp/logger/SqlLogFilter.java | 15 ++------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/BladeMybatisPlusProperties.java b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/BladeMybatisPlusProperties.java index 3d214c3..e39e87f 100644 --- a/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/BladeMybatisPlusProperties.java +++ b/blade-starter-mybatis/src/main/java/org/springblade/core/mp/config/BladeMybatisPlusProperties.java @@ -38,9 +38,4 @@ public class BladeMybatisPlusProperties { */ private boolean sqlLog = true; - /** - * sql 打印正则过滤 - */ - private List sqlLogPatterns = new ArrayList<>(); - } 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 index a33e555..7d71c2e 100644 --- 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 @@ -24,6 +24,7 @@ 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.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.config.BladeMybatisPlusProperties; import org.springblade.core.tool.utils.StringUtil; @@ -32,7 +33,6 @@ import java.sql.SQLException; import java.time.temporal.TemporalAccessor; import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; /** * 打印可执行的 sql 日志 @@ -44,15 +44,10 @@ import java.util.regex.Pattern; * @author L.cm */ @Slf4j +@RequiredArgsConstructor public class SqlLogFilter extends FilterEventAdapter { private static final SQLUtils.FormatOption FORMAT_OPTION = new SQLUtils.FormatOption(false, false); private final BladeMybatisPlusProperties properties; - private final List sqlLogPatternList; - - public SqlLogFilter(BladeMybatisPlusProperties properties) { - this.properties = properties; - this.sqlLogPatternList = properties.getSqlLogPatterns().stream().map(Pattern::compile).toList(); - } @Override protected void statementExecuteBefore(StatementProxy statement, String sql) { @@ -112,12 +107,6 @@ public class SqlLogFilter extends FilterEventAdapter { if (StringUtils.isEmpty(sql)) { return; } - boolean isSqlMatch = sqlLogPatternList.stream() - .anyMatch(pattern -> pattern.matcher(sql).matches()); - if (!isSqlMatch) { - log.debug("sql:{} not match in SqlPatternList:{}", sql, properties.getSqlLogPatterns()); - return; - } int parametersSize = statement.getParametersSize(); List parameters = new ArrayList<>(parametersSize); for (int i = 0; i < parametersSize; ++i) {