From 3b8cf849b25326814fb2ff83f1b4812bad775662 Mon Sep 17 00:00:00 2001 From: nieqiurong Date: Thu, 28 Mar 2024 14:27:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/inner/BlockAttackInnerInterceptor.java | 4 +++- .../plugins/inner/IllegalSQLInnerInterceptor.java | 4 +++- .../baomidou/mybatisplus/generator/AutoGenerator.java | 4 +++- .../mybatisplus/generator/FastAutoGenerator.java | 10 ++++++++++ .../mybatisplus/generator/config/TemplateConfig.java | 2 ++ .../generator/config/builder/ConfigBuilder.java | 8 ++++++++ .../generator/config/builder/CustomFile.java | 6 ------ .../generator/config/builder/GeneratorBuilder.java | 4 ++++ .../generator/config/converts/TypeConverts.java | 4 +++- .../mybatisplus/generator/config/po/TableField.java | 1 - .../mybatisplus/generator/config/po/TableInfo.java | 2 -- .../generator/engine/AbstractTemplateEngine.java | 1 + 12 files changed, 37 insertions(+), 13 deletions(-) diff --git a/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/BlockAttackInnerInterceptor.java b/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/BlockAttackInnerInterceptor.java index 9dc50f017f..77a5c70593 100644 --- a/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/BlockAttackInnerInterceptor.java +++ b/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/BlockAttackInnerInterceptor.java @@ -54,7 +54,9 @@ public void beforePrepare(StatementHandler sh, Connection connection, Integer tr MappedStatement ms = handler.mappedStatement(); SqlCommandType sct = ms.getSqlCommandType(); if (sct == SqlCommandType.UPDATE || sct == SqlCommandType.DELETE) { - if (InterceptorIgnoreHelper.willIgnoreBlockAttack(ms.getId())) return; + if (InterceptorIgnoreHelper.willIgnoreBlockAttack(ms.getId())) { + return; + } BoundSql boundSql = handler.boundSql(); parserMulti(boundSql.getSql(), null); } diff --git a/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/IllegalSQLInnerInterceptor.java b/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/IllegalSQLInnerInterceptor.java index 656c83bea1..2e2229c72a 100644 --- a/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/IllegalSQLInnerInterceptor.java +++ b/mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/IllegalSQLInnerInterceptor.java @@ -99,7 +99,9 @@ public void beforePrepare(StatementHandler sh, Connection connection, Integer tr PluginUtils.MPStatementHandler mpStatementHandler = PluginUtils.mpStatementHandler(sh); MappedStatement ms = mpStatementHandler.mappedStatement(); SqlCommandType sct = ms.getSqlCommandType(); - if (sct == SqlCommandType.INSERT || InterceptorIgnoreHelper.willIgnoreIllegalSql(ms.getId())) return; + if (sct == SqlCommandType.INSERT || InterceptorIgnoreHelper.willIgnoreIllegalSql(ms.getId())) { + return; + } BoundSql boundSql = mpStatementHandler.boundSql(); String originalSql = boundSql.getSql(); logger.debug("检查SQL是否合规,SQL:" + originalSql); diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java index cbf96ca2e8..5a7a29dd3e 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java @@ -60,7 +60,9 @@ public class AutoGenerator { private PackageConfig packageInfo; /** * 模板 相关配置 + * @deprecated 3.5.6 {@link #strategy} */ + @Deprecated private TemplateConfig template; /** * 全局 相关配置 @@ -123,7 +125,7 @@ public AutoGenerator packageInfo(@NotNull PackageConfig packageConfig) { * * @param templateConfig 模板配置 * @return this - * @see #strategy + * @deprecated 3.5.6 {@link #strategy(StrategyConfig)} * @since 3.5.0 */ @Deprecated diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/FastAutoGenerator.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/FastAutoGenerator.java index e2b852e4fd..a245d84368 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/FastAutoGenerator.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/FastAutoGenerator.java @@ -60,7 +60,9 @@ public final class FastAutoGenerator { /** * 模板配置 Builder + * @deprecated 3.5.6 {@link #strategyConfigBuilder} */ + @Deprecated private final TemplateConfig.Builder templateConfigBuilder; /** @@ -191,12 +193,20 @@ public FastAutoGenerator injectionConfig(BiConsumer, In * * @param consumer 自定义模板配置 * @return FastAutoGenerator + * @deprecated 3.5.6 {@link #strategyConfig(Consumer)} */ + @Deprecated public FastAutoGenerator templateConfig(Consumer consumer) { consumer.accept(this.templateConfigBuilder); return this; } + /** + * @param biConsumer + * @return FastAutoGenerator + * @deprecated 3.5.6 {@link #strategyConfig(BiConsumer)} + */ + @Deprecated public FastAutoGenerator templateConfig(BiConsumer, TemplateConfig.Builder> biConsumer) { biConsumer.accept(this::scannerNext, this.templateConfigBuilder); return this; diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java index 9f56d9536b..e542e05fca 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java @@ -30,6 +30,7 @@ * * @author tzg hubin * @since 2017-06-17 + * @deprecated 3.5.6 {@link StrategyConfig} */ @Deprecated public class TemplateConfig { @@ -175,6 +176,7 @@ public TemplateConfig disable() { * 模板路径配置构建者 * * @author nieqiurong 3.5.0 + * @deprecated 3.5.6 {@link StrategyConfig} */ @Deprecated public static class Builder implements IConfigBuilder { diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java index 35467b322e..b4a817841c 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java @@ -35,6 +35,8 @@ public class ConfigBuilder { /** * 模板路径配置信息 + * + * @deprecated 3.5.6 */ @Deprecated private final TemplateConfig templateConfig; @@ -142,6 +144,12 @@ public ConfigBuilder setInjectionConfig(@NotNull InjectionConfig injectionConfig return this; } + /** + * 获取模板配置 + * + * @return 模板配置 + * @deprecated 3.5.6 {@link #strategyConfig} + */ @NotNull @Deprecated public TemplateConfig getTemplateConfig() { diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/CustomFile.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/CustomFile.java index f5d3361e24..0e3f7293ad 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/CustomFile.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/CustomFile.java @@ -60,12 +60,6 @@ public class CustomFile { */ private boolean fileOverride; - /** - * 是否生成 - */ - @Getter - private boolean generate; - /** * 构建者 */ diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/GeneratorBuilder.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/GeneratorBuilder.java index 76febdfe9d..1d8e9b7d80 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/GeneratorBuilder.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/GeneratorBuilder.java @@ -83,7 +83,9 @@ public static StrategyConfig.Builder strategyConfigBuilder() { * 模板路径配置项 * * @return TemplateConfig + * @deprecated 3.5.6 {@link #strategyConfig()} */ + @Deprecated public static TemplateConfig templateConfig() { return new TemplateConfig.Builder().build(); } @@ -92,7 +94,9 @@ public static TemplateConfig templateConfig() { * 模板路径配置项 Builder * * @return TemplateConfig.Builder + * @deprecated 3.5.6 {@link #strategyConfigBuilder()} */ + @Deprecated public static TemplateConfig.Builder templateConfigBuilder() { return new TemplateConfig.Builder(); } diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/converts/TypeConverts.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/converts/TypeConverts.java index 1f05ef79a9..6b3c963d8b 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/converts/TypeConverts.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/converts/TypeConverts.java @@ -92,7 +92,9 @@ static BranchBuilder contains(CharSequence value) { static BranchBuilder containsAny(CharSequence... values) { return BranchBuilder.of(s -> { for (CharSequence value : values) { - if (s.contains(value)) return true; + if (s.contains(value)) { + return true; + } } return false; }); diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableField.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableField.java index 4b6e48b838..fb46083147 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableField.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableField.java @@ -267,7 +267,6 @@ public TableField setType(String type) { } public TableField setComment(String comment) { - //TODO 暂时挪动到这 this.comment = this.globalConfig.isSwagger() && StringUtils.isNotBlank(comment) ? comment.replace("\"", "\\\"") : comment; return this; diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java index a5ecc2f62a..1a315155ca 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java @@ -171,7 +171,6 @@ public String getEntityPath() { */ public TableInfo setEntityName(@NotNull String entityName) { this.entityName = entityName; - //TODO 先放置在这里 setConvert(); return this; } @@ -211,7 +210,6 @@ public TableInfo addImportPackages(@NotNull List pkgList) { * 转换filed实体为 xml mapper 中的 base column 字符串信息 */ public String getFieldNames() { - //TODO 感觉这个也啥必要,不打算公开set方法了 if (StringUtils.isBlank(fieldNames)) { this.fieldNames = this.fields.stream().map(TableField::getColumnName).collect(Collectors.joining(", ")); } diff --git a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java index c6df774a5d..b640e2e0ec 100644 --- a/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java +++ b/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java @@ -206,6 +206,7 @@ protected void outputFile(@NotNull File file, @NotNull Map objec * @param function function * @return 模板路径 * @since 3.5.0 + * @deprecated 3.5.6 */ @NotNull @Deprecated