Browse Source

选装件 包调整

miemie 5 years ago
parent
commit
2e4f0bc94b

+ 84 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/AlwaysUpdateSomeColumnById.java

@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 com.baomidou.mybatisplus.extension.injector.methods;
+
+import com.baomidou.mybatisplus.core.enums.SqlMethod;
+import com.baomidou.mybatisplus.core.injector.AbstractMethod;
+import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlSource;
+
+import java.util.function.Predicate;
+
+/**
+ * 根据 ID 更新固定的那几个字段(但是不包含逻辑删除)
+ *
+ * <p>
+ * 自己的通用 mapper 如下使用:
+ * <pre>
+ * int alwaysUpdateSomeColumnById(@Param(Constants.ENTITY) T entity);
+ * </pre>
+ * </p>
+ *
+ * <p> 如何筛选字段参考请 {@link InsertBatchSomeColumn} 里面的注释 </p>
+ *
+ * @author hubin
+ * @since 2019-04-12
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+public class AlwaysUpdateSomeColumnById extends AbstractMethod {
+
+    /**
+     * 字段筛选条件
+     */
+    @Setter
+    @Accessors(chain = true)
+    private Predicate<TableFieldInfo> predicate;
+
+    @Override
+    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
+        SqlMethod sqlMethod = SqlMethod.UPDATE_BY_ID;
+        final String additional = optlockVersion() + tableInfo.getLogicDeleteSql(true, true);
+        String sqlSet = this.filterTableFieldInfo(tableInfo.getFieldList(), getPredicate(),
+            i -> i.getSqlSet(true, ENTITY_DOT), NEWLINE);
+        sqlSet = SqlScriptUtils.convertSet(sqlSet);
+        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlSet,
+            tableInfo.getKeyColumn(), ENTITY_DOT + tableInfo.getKeyProperty(), additional);
+        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
+        return addUpdateMappedStatement(mapperClass, modelClass, getMethod(sqlMethod), sqlSource);
+    }
+
+    private Predicate<TableFieldInfo> getPredicate() {
+        Predicate<TableFieldInfo> noLogic = t -> !t.isLogicDelete();
+        if (predicate != null) {
+            return noLogic.and(predicate);
+        }
+        return noLogic;
+    }
+
+    @Override
+    public String getMethod(SqlMethod sqlMethod) {
+        // 自定义 mapper 方法名
+        return "alwaysUpdateSomeColumnById";
+    }
+}

+ 115 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/InsertBatchSomeColumn.java

@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 com.baomidou.mybatisplus.extension.injector.methods;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.core.enums.SqlMethod;
+import com.baomidou.mybatisplus.core.injector.AbstractMethod;
+import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
+import org.apache.ibatis.executor.keygen.KeyGenerator;
+import org.apache.ibatis.executor.keygen.NoKeyGenerator;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlSource;
+
+import java.util.List;
+import java.util.function.Predicate;
+
+/**
+ * 批量新增数据,自选字段 insert
+ * <p> 不同的数据库支持度不一样!!!  只在 mysql 下测试过!!!  只在 mysql 下测试过!!!  只在 mysql 下测试过!!! </p>
+ * <p> 除了主键是 <strong> 数据库自增的未测试 </strong> 外理论上都可以使用!!! </p>
+ * <p> 如果你使用自增有报错或主键值无法回写到entity,就不要跑来问为什么了,因为我也不知道!!! </p>
+ * <p>
+ * 自己的通用 mapper 如下使用:
+ * <pre>
+ * int insertBatchSomeColumn(List<T> entityList);
+ * </pre>
+ * </p>
+ *
+ * <li> 注意: 这是自选字段 insert !!,如果个别字段在 entity 里为 null 但是数据库中有配置默认值, insert 后数据库字段是为 null 而不是默认值 </li>
+ *
+ * <p>
+ * 常用的 {@link Predicate}:
+ * </p>
+ *
+ * <li> 例1: t -> !t.isLogicDelete() , 表示不要逻辑删除字段 </li>
+ * <li> 例2: t -> !t.getProperty().equals("version") , 表示不要字段名为 version 的字段 </li>
+ * <li> 例3: t -> t.getFieldFill() != FieldFill.UPDATE) , 表示不要填充策略为 UPDATE 的字段 </li>
+ *
+ * @author miemie
+ * @since 2018-11-29
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsertBatchSomeColumn extends AbstractMethod {
+
+    /**
+     * 字段筛选条件
+     */
+    @Setter
+    @Accessors(chain = true)
+    private Predicate<TableFieldInfo> predicate;
+
+    @SuppressWarnings("Duplicates")
+    @Override
+    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
+        KeyGenerator keyGenerator = new NoKeyGenerator();
+        SqlMethod sqlMethod = SqlMethod.INSERT_ONE;
+        List<TableFieldInfo> fieldList = tableInfo.getFieldList();
+        String insertSqlColumn = tableInfo.getKeyInsertSqlColumn(false) +
+            this.filterTableFieldInfo(fieldList, predicate, TableFieldInfo::getInsertSqlColumn, EMPTY);
+        String columnScript = LEFT_BRACKET + insertSqlColumn.substring(0, insertSqlColumn.length() - 1) + RIGHT_BRACKET;
+        String insertSqlProperty = tableInfo.getKeyInsertSqlProperty(ENTITY_DOT, false) +
+            this.filterTableFieldInfo(fieldList, predicate, i -> i.getInsertSqlProperty(ENTITY_DOT), EMPTY);
+        insertSqlProperty = LEFT_BRACKET + insertSqlProperty.substring(0, insertSqlProperty.length() - 1) + RIGHT_BRACKET;
+        String valuesScript = SqlScriptUtils.convertForeach(insertSqlProperty, "list", null, ENTITY, COMMA);
+        String keyProperty = null;
+        String keyColumn = null;
+        // 表包含主键处理逻辑,如果不包含主键当普通字段处理
+        if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) {
+            if (tableInfo.getIdType() == IdType.AUTO) {
+                /* 自增主键 */
+                keyGenerator = new Jdbc3KeyGenerator();
+                keyProperty = tableInfo.getKeyProperty();
+                keyColumn = tableInfo.getKeyColumn();
+            } else {
+                if (null != tableInfo.getKeySequence()) {
+                    keyGenerator = TableInfoHelper.genKeyGenerator(getMethod(sqlMethod), tableInfo, builderAssistant);
+                    keyProperty = tableInfo.getKeyProperty();
+                    keyColumn = tableInfo.getKeyColumn();
+                }
+            }
+        }
+        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), columnScript, valuesScript);
+        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
+        return this.addInsertMappedStatement(mapperClass, modelClass, getMethod(sqlMethod), sqlSource, keyGenerator, keyProperty, keyColumn);
+    }
+
+    @Override
+    public String getMethod(SqlMethod sqlMethod) {
+        // 自定义 mapper 方法名
+        return "insertBatchSomeColumn";
+    }
+}

+ 78 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicDeleteByIdWithFill.java

@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * https://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 com.baomidou.mybatisplus.extension.injector.methods;
+
+import com.baomidou.mybatisplus.core.enums.SqlMethod;
+import com.baomidou.mybatisplus.core.injector.AbstractMethod;
+import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlSource;
+
+import java.util.List;
+
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toList;
+
+/**
+ * 根据 id 逻辑删除数据,并带字段填充功能
+ * <p>注意入参是 entity !!! ,如果字段没有自动填充,就只是单纯的逻辑删除</p>
+ * <p>
+ * 自己的通用 mapper 如下使用:
+ * <pre>
+ * int deleteByIdWithFill(T entity);
+ * </pre>
+ * </p>
+ *
+ * @author miemie
+ * @since 2018-11-09
+ */
+public class LogicDeleteByIdWithFill extends AbstractMethod {
+
+    @Override
+    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
+        String sql;
+        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_ID;
+        if (tableInfo.isLogicDelete()) {
+            List<TableFieldInfo> fieldInfos = tableInfo.getFieldList().stream()
+                .filter(TableFieldInfo::isWithUpdateFill)
+                .collect(toList());
+            if (CollectionUtils.isNotEmpty(fieldInfos)) {
+                String sqlSet = "SET " + fieldInfos.stream().map(i -> i.getSqlSet(EMPTY)).collect(joining(EMPTY))
+                    + tableInfo.getLogicDeleteSql(false, false);
+                sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlSet, tableInfo.getKeyColumn(),
+                    tableInfo.getKeyProperty(), tableInfo.getLogicDeleteSql(true, true));
+            } else {
+                sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
+                    tableInfo.getKeyColumn(), tableInfo.getKeyProperty(),
+                    tableInfo.getLogicDeleteSql(true, true));
+            }
+        } else {
+            sqlMethod = SqlMethod.DELETE_BY_ID;
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
+                tableInfo.getKeyProperty());
+        }
+        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
+        return addUpdateMappedStatement(mapperClass, modelClass, getMethod(sqlMethod), sqlSource);
+    }
+
+    @Override
+    public String getMethod(SqlMethod sqlMethod) {
+        // 自定义 mapper 方法名
+        return "deleteByIdWithFill";
+    }
+}

+ 5 - 56
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/additional/AlwaysUpdateSomeColumnById.java

@@ -15,70 +15,19 @@
  */
 package com.baomidou.mybatisplus.extension.injector.methods.additional;
 
-import com.baomidou.mybatisplus.core.enums.SqlMethod;
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
-import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
-import lombok.AllArgsConstructor;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.experimental.Accessors;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
 
 import java.util.function.Predicate;
 
 /**
- * 根据 ID 更新固定的那几个字段(但是不包含逻辑删除)
- *
- * <p>
- * 自己的通用 mapper 如下使用:
- * <pre>
- * int alwaysUpdateSomeColumnById(@Param(Constants.ENTITY) T entity);
- * </pre>
- * </p>
- *
- * <p> 如何筛选字段参考请 {@link InsertBatchSomeColumn} 里面的注释 </p>
- *
  * @author hubin
  * @since 2019-04-12
+ * @deprecated
  */
-@NoArgsConstructor
-@AllArgsConstructor
-public class AlwaysUpdateSomeColumnById extends AbstractMethod {
-
-    /**
-     * 字段筛选条件
-     */
-    @Setter
-    @Accessors(chain = true)
-    private Predicate<TableFieldInfo> predicate;
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.UPDATE_BY_ID;
-        final String additional = optlockVersion() + tableInfo.getLogicDeleteSql(true, true);
-        String sqlSet = this.filterTableFieldInfo(tableInfo.getFieldList(), getPredicate(),
-            i -> i.getSqlSet(true, ENTITY_DOT), NEWLINE);
-        sqlSet = SqlScriptUtils.convertSet(sqlSet);
-        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlSet,
-            tableInfo.getKeyColumn(), ENTITY_DOT + tableInfo.getKeyProperty(), additional);
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addUpdateMappedStatement(mapperClass, modelClass, getMethod(sqlMethod), sqlSource);
-    }
-
-    private Predicate<TableFieldInfo> getPredicate() {
-        Predicate<TableFieldInfo> noLogic = t -> !t.isLogicDelete();
-        if (predicate != null) {
-            return noLogic.and(predicate);
-        }
-        return noLogic;
-    }
+@Deprecated
+public class AlwaysUpdateSomeColumnById extends com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById {
 
-    @Override
-    public String getMethod(SqlMethod sqlMethod) {
-        // 自定义 mapper 方法名
-        return "alwaysUpdateSomeColumnById";
+    public AlwaysUpdateSomeColumnById(Predicate<TableFieldInfo> predicate) {
+        super(predicate);
     }
 }

+ 5 - 87
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/additional/InsertBatchSomeColumn.java

@@ -15,101 +15,19 @@
  */
 package com.baomidou.mybatisplus.extension.injector.methods.additional;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.core.enums.SqlMethod;
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
-import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
-import lombok.AllArgsConstructor;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import lombok.experimental.Accessors;
-import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
-import org.apache.ibatis.executor.keygen.KeyGenerator;
-import org.apache.ibatis.executor.keygen.NoKeyGenerator;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
 
-import java.util.List;
 import java.util.function.Predicate;
 
 /**
- * 批量新增数据,自选字段 insert
- * <p> 不同的数据库支持度不一样!!!  只在 mysql 下测试过!!!  只在 mysql 下测试过!!!  只在 mysql 下测试过!!! </p>
- * <p> 除了主键是 <strong> 数据库自增的未测试 </strong> 外理论上都可以使用!!! </p>
- * <p> 如果你使用自增有报错或主键值无法回写到entity,就不要跑来问为什么了,因为我也不知道!!! </p>
- * <p>
- * 自己的通用 mapper 如下使用:
- * <pre>
- * int insertBatchSomeColumn(List<T> entityList);
- * </pre>
- * </p>
- *
- * <li> 注意: 这是自选字段 insert !!,如果个别字段在 entity 里为 null 但是数据库中有配置默认值, insert 后数据库字段是为 null 而不是默认值 </li>
- *
- * <p>
- * 常用的 {@link Predicate}:
- * </p>
- *
- * <li> 例1: t -> !t.isLogicDelete() , 表示不要逻辑删除字段 </li>
- * <li> 例2: t -> !t.getProperty().equals("version") , 表示不要字段名为 version 的字段 </li>
- * <li> 例3: t -> t.getFieldFill() != FieldFill.UPDATE) , 表示不要填充策略为 UPDATE 的字段 </li>
- *
  * @author miemie
  * @since 2018-11-29
+ * @deprecated
  */
-@NoArgsConstructor
-@AllArgsConstructor
-public class InsertBatchSomeColumn extends AbstractMethod {
-
-    /**
-     * 字段筛选条件
-     */
-    @Setter
-    @Accessors(chain = true)
-    private Predicate<TableFieldInfo> predicate;
-
-    @SuppressWarnings("Duplicates")
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        KeyGenerator keyGenerator = new NoKeyGenerator();
-        SqlMethod sqlMethod = SqlMethod.INSERT_ONE;
-        List<TableFieldInfo> fieldList = tableInfo.getFieldList();
-        String insertSqlColumn = tableInfo.getKeyInsertSqlColumn(false) +
-            this.filterTableFieldInfo(fieldList, predicate, TableFieldInfo::getInsertSqlColumn, EMPTY);
-        String columnScript = LEFT_BRACKET + insertSqlColumn.substring(0, insertSqlColumn.length() - 1) + RIGHT_BRACKET;
-        String insertSqlProperty = tableInfo.getKeyInsertSqlProperty(ENTITY_DOT, false) +
-            this.filterTableFieldInfo(fieldList, predicate, i -> i.getInsertSqlProperty(ENTITY_DOT), EMPTY);
-        insertSqlProperty = LEFT_BRACKET + insertSqlProperty.substring(0, insertSqlProperty.length() - 1) + RIGHT_BRACKET;
-        String valuesScript = SqlScriptUtils.convertForeach(insertSqlProperty, "list", null, ENTITY, COMMA);
-        String keyProperty = null;
-        String keyColumn = null;
-        // 表包含主键处理逻辑,如果不包含主键当普通字段处理
-        if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) {
-            if (tableInfo.getIdType() == IdType.AUTO) {
-                /* 自增主键 */
-                keyGenerator = new Jdbc3KeyGenerator();
-                keyProperty = tableInfo.getKeyProperty();
-                keyColumn = tableInfo.getKeyColumn();
-            } else {
-                if (null != tableInfo.getKeySequence()) {
-                    keyGenerator = TableInfoHelper.genKeyGenerator(getMethod(sqlMethod), tableInfo, builderAssistant);
-                    keyProperty = tableInfo.getKeyProperty();
-                    keyColumn = tableInfo.getKeyColumn();
-                }
-            }
-        }
-        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), columnScript, valuesScript);
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return this.addInsertMappedStatement(mapperClass, modelClass, getMethod(sqlMethod), sqlSource, keyGenerator, keyProperty, keyColumn);
-    }
+@Deprecated
+public class InsertBatchSomeColumn extends com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn {
 
-    @Override
-    public String getMethod(SqlMethod sqlMethod) {
-        // 自定义 mapper 方法名
-        return "insertBatchSomeColumn";
+    public InsertBatchSomeColumn(Predicate<TableFieldInfo> predicate) {
+        super(predicate);
     }
 }

+ 3 - 56
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/additional/LogicDeleteByIdWithFill.java

@@ -15,64 +15,11 @@
  */
 package com.baomidou.mybatisplus.extension.injector.methods.additional;
 
-import com.baomidou.mybatisplus.core.enums.SqlMethod;
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
-import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
-import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-import java.util.List;
-
-import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toList;
-
 /**
- * 根据 id 逻辑删除数据,并带字段填充功能
- * <p>注意入参是 entity !!! ,如果字段没有自动填充,就只是单纯的逻辑删除</p>
- * <p>
- * 自己的通用 mapper 如下使用:
- * <pre>
- * int deleteByIdWithFill(T entity);
- * </pre>
- * </p>
- *
  * @author miemie
  * @since 2018-11-09
+ * @deprecated
  */
-public class LogicDeleteByIdWithFill extends AbstractMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        String sql;
-        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_ID;
-        if (tableInfo.isLogicDelete()) {
-            List<TableFieldInfo> fieldInfos = tableInfo.getFieldList().stream()
-                .filter(TableFieldInfo::isWithUpdateFill)
-                .collect(toList());
-            if (CollectionUtils.isNotEmpty(fieldInfos)) {
-                String sqlSet = "SET " + fieldInfos.stream().map(i -> i.getSqlSet(EMPTY)).collect(joining(EMPTY))
-                    + tableInfo.getLogicDeleteSql(false, false);
-                sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlSet, tableInfo.getKeyColumn(),
-                    tableInfo.getKeyProperty(), tableInfo.getLogicDeleteSql(true, true));
-            } else {
-                sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
-                    tableInfo.getKeyColumn(), tableInfo.getKeyProperty(),
-                    tableInfo.getLogicDeleteSql(true, true));
-            }
-        } else {
-            sqlMethod = SqlMethod.DELETE_BY_ID;
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
-                tableInfo.getKeyProperty());
-        }
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addUpdateMappedStatement(mapperClass, modelClass, getMethod(sqlMethod), sqlSource);
-    }
-
-    @Override
-    public String getMethod(SqlMethod sqlMethod) {
-        // 自定义 mapper 方法名
-        return "deleteByIdWithFill";
-    }
+@Deprecated
+public class LogicDeleteByIdWithFill extends com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill {
 }

+ 3 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/config/MybatisPlusConfig.java

@@ -22,9 +22,9 @@ import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
 import com.baomidou.mybatisplus.core.parser.ISqlParser;
 import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory;
-import com.baomidou.mybatisplus.extension.injector.methods.additional.AlwaysUpdateSomeColumnById;
-import com.baomidou.mybatisplus.extension.injector.methods.additional.InsertBatchSomeColumn;
-import com.baomidou.mybatisplus.extension.injector.methods.additional.LogicDeleteByIdWithFill;
+import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
+import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
+import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill;
 import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;