Sfoglia il codice sorgente

逻辑删除功能下放到 core 包,默认集成,只需要注解即可开启

miemie 6 anni fa
parent
commit
94a9163045
35 ha cambiato i file con 143 aggiunte e 915 eliminazioni
  1. 59 19
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/AbstractMethod.java
  2. 10 2
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/Delete.java
  3. 12 3
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/DeleteBatchByIds.java
  4. 14 6
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/DeleteById.java
  5. 13 6
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/DeleteByMap.java
  6. 3 3
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectBatchByIds.java
  7. 4 3
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectById.java
  8. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectByMap.java
  9. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectCount.java
  10. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectList.java
  11. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectMaps.java
  12. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectMapsPage.java
  13. 3 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectObjs.java
  14. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectPage.java
  15. 2 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/Update.java
  16. 14 6
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/UpdateById.java
  17. 0 84
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/AbstractLogicMethod.java
  18. 3 48
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/LogicSqlInjector.java
  19. 0 47
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicDelete.java
  20. 0 50
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicDeleteBatchByIds.java
  21. 0 48
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicDeleteById.java
  22. 0 27
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicDeleteByIdWithFill.java
  23. 0 47
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicDeleteByMap.java
  24. 0 42
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectBatchByIds.java
  25. 0 42
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectById.java
  26. 0 42
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectByMap.java
  27. 0 39
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectCount.java
  28. 0 40
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectList.java
  29. 0 42
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectMaps.java
  30. 0 42
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectMapsPage.java
  31. 0 41
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectObjs.java
  32. 0 40
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectOne.java
  33. 0 40
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicSelectPage.java
  34. 0 41
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicUpdate.java
  35. 0 54
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/LogicUpdateById.java

+ 59 - 19
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/AbstractMethod.java

@@ -61,6 +61,16 @@ public abstract class AbstractMethod implements Constants {
         return configuration.hasStatement(mappedStatement, false);
     }
 
+    /**
+     * SQL 更新 set 语句
+     *
+     * @param table 表信息
+     * @return sql set 片段
+     */
+    protected String sqlLogicSet(TableInfo table) {
+        return "SET " + table.getLogicDeleteSql(false, true);
+    }
+
     /**
      * SQL 更新 set 语句
      *
@@ -130,13 +140,24 @@ public abstract class AbstractMethod implements Constants {
      * SQL map 查询条件
      */
     protected String sqlWhereByMap(TableInfo table) {
-        String sqlScript = SqlScriptUtils.convertChoose("v == null", " ${k} IS NULL ",
-            " ${k} = #{v} ");
-        sqlScript = SqlScriptUtils.convertForeach(sqlScript, COLUMN_MAP, "k", "v", "AND");
-        sqlScript = SqlScriptUtils.convertWhere(sqlScript);
-        sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null and !%s", COLUMN_MAP,
-            COLUMN_MAP_IS_EMPTY), true);
-        return sqlScript;
+        if (table.isLogicDelete()) {
+            // 逻辑删除
+            String sqlScript = SqlScriptUtils.convertChoose("v == null", " ${k} IS NULL ",
+                " ${k} = #{v} ");
+            sqlScript = SqlScriptUtils.convertForeach(sqlScript, "cm", "k", "v", "AND");
+            sqlScript = SqlScriptUtils.convertIf(sqlScript, "cm != null and !cm.isEmpty", true);
+            sqlScript += (NEWLINE + table.getLogicDeleteSql(true, false));
+            sqlScript = SqlScriptUtils.convertWhere(sqlScript);
+            return sqlScript;
+        } else {
+            String sqlScript = SqlScriptUtils.convertChoose("v == null", " ${k} IS NULL ",
+                " ${k} = #{v} ");
+            sqlScript = SqlScriptUtils.convertForeach(sqlScript, COLUMN_MAP, "k", "v", "AND");
+            sqlScript = SqlScriptUtils.convertWhere(sqlScript);
+            sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null and !%s", COLUMN_MAP,
+                COLUMN_MAP_IS_EMPTY), true);
+            return sqlScript;
+        }
     }
 
     /**
@@ -147,18 +168,37 @@ public abstract class AbstractMethod implements Constants {
      * @return String
      */
     protected String sqlWhereEntityWrapper(boolean newLine, TableInfo table) {
-        String sqlScript = table.getAllSqlWhere(false, true, WRAPPER_ENTITY_DOT);
-        sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER_ENTITY), true);
-        sqlScript += NEWLINE;
-        sqlScript += SqlScriptUtils.convertIf(String.format(SqlScriptUtils.convertIf(" AND", String.format("%s and %s", WRAPPER_NONEMPTYOFENTITY, WRAPPER_NONEMPTYOFNORMAL), false) + " ${%s}", WRAPPER_SQLSEGMENT),
-            String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
-                WRAPPER_NONEMPTYOFWHERE), true);
-        sqlScript = SqlScriptUtils.convertWhere(sqlScript) + NEWLINE;
-        sqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT),
-            String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
-                WRAPPER_EMPTYOFWHERE), true);
-        sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER), true);
-        return newLine ? NEWLINE + sqlScript : sqlScript;
+        if (table.isLogicDelete()) {
+            String sqlScript = table.getAllSqlWhere(true, true, WRAPPER_ENTITY_DOT);
+            sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER_ENTITY),
+                true);
+            sqlScript += (NEWLINE + table.getLogicDeleteSql(true, false) + NEWLINE);
+            String normalSqlScript = SqlScriptUtils.convertIf(String.format("AND ${%s}", WRAPPER_SQLSEGMENT),
+                String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
+                    WRAPPER_NONEMPTYOFNORMAL), true);
+            normalSqlScript += NEWLINE;
+            normalSqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT),
+                String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
+                    WRAPPER_EMPTYOFNORMAL), true);
+            sqlScript += normalSqlScript;
+            sqlScript = SqlScriptUtils.convertChoose(String.format("%s != null", WRAPPER), sqlScript,
+                table.getLogicDeleteSql(false, false));
+            sqlScript = SqlScriptUtils.convertWhere(sqlScript);
+            return newLine ? NEWLINE + sqlScript : sqlScript;
+        } else {
+            String sqlScript = table.getAllSqlWhere(false, true, WRAPPER_ENTITY_DOT);
+            sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER_ENTITY), true);
+            sqlScript += NEWLINE;
+            sqlScript += SqlScriptUtils.convertIf(String.format(SqlScriptUtils.convertIf(" AND", String.format("%s and %s", WRAPPER_NONEMPTYOFENTITY, WRAPPER_NONEMPTYOFNORMAL), false) + " ${%s}", WRAPPER_SQLSEGMENT),
+                String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
+                    WRAPPER_NONEMPTYOFWHERE), true);
+            sqlScript = SqlScriptUtils.convertWhere(sqlScript) + NEWLINE;
+            sqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT),
+                String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
+                    WRAPPER_EMPTYOFWHERE), true);
+            sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER), true);
+            return newLine ? NEWLINE + sqlScript : sqlScript;
+        }
     }
 
     /**

+ 10 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/Delete.java

@@ -31,8 +31,16 @@ public class Delete extends AbstractMethod {
 
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.DELETE;
-        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo));
+        String sql;
+        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE;
+        if (tableInfo.isLogicDelete()) {
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
+                sqlWhereEntityWrapper(true, tableInfo));
+        } else {
+            sqlMethod = SqlMethod.DELETE;
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(),
+                sqlWhereEntityWrapper(true, tableInfo));
+        }
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addDeleteMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource);
     }

+ 12 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/DeleteBatchByIds.java

@@ -32,9 +32,18 @@ public class DeleteBatchByIds extends AbstractMethod {
 
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.DELETE_BATCH_BY_IDS;
-        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
-            SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA));
+        String sql;
+        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BATCH_BY_IDS;
+        if (tableInfo.isLogicDelete()) {
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
+                tableInfo.getKeyColumn(),
+                SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA),
+                tableInfo.getLogicDeleteSql(true, false));
+        } else {
+            sqlMethod = SqlMethod.DELETE_BATCH_BY_IDS;
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
+                SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA));
+        }
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Object.class);
         return this.addDeleteMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource);
     }

+ 14 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/DeleteById.java

@@ -15,12 +15,11 @@
  */
 package com.baomidou.mybatisplus.core.injector.methods;
 
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
 import com.baomidou.mybatisplus.core.enums.SqlMethod;
 import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlSource;
 
 /**
  * 根据 ID 删除
@@ -32,9 +31,18 @@ public class DeleteById extends AbstractMethod {
 
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.DELETE_BY_ID;
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, String.format(sqlMethod.getSql(),
-            tableInfo.getTableName(), tableInfo.getKeyColumn(), tableInfo.getKeyProperty()), Object.class);
+        String sql;
+        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_ID;
+        if (tableInfo.isLogicDelete()) {
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
+                tableInfo.getKeyColumn(), tableInfo.getKeyProperty(),
+                tableInfo.getLogicDeleteSql(true, false));
+        } else {
+            sqlMethod = SqlMethod.DELETE_BY_ID;
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
+                tableInfo.getKeyProperty());
+        }
+        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Object.class);
         return this.addDeleteMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource);
     }
 }

+ 13 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/DeleteByMap.java

@@ -15,12 +15,13 @@
  */
 package com.baomidou.mybatisplus.core.injector.methods;
 
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
 import com.baomidou.mybatisplus.core.enums.SqlMethod;
 import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlSource;
+
+import java.util.Map;
 
 /**
  * 根据columnMap 条件删除记录
@@ -32,9 +33,15 @@ public class DeleteByMap extends AbstractMethod {
 
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.DELETE_BY_MAP;
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, String.format(sqlMethod.getSql(),
-            tableInfo.getTableName(), this.sqlWhereByMap(tableInfo)), modelClass);
+        String sql;
+        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_MAP;
+        if (tableInfo.isLogicDelete()) {
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo), sqlWhereByMap(tableInfo));
+        } else {
+            sqlMethod = SqlMethod.DELETE_BY_MAP;
+            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), this.sqlWhereByMap(tableInfo));
+        }
+        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Map.class);
         return this.addDeleteMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource);
     }
 }

+ 3 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectBatchByIds.java

@@ -32,11 +32,11 @@ public class SelectBatchByIds extends AbstractMethod {
 
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_BATCH_BY_IDS;
+        SqlMethod sqlMethod = SqlMethod.LOGIC_SELECT_BATCH_BY_IDS;
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, String.format(sqlMethod.getSql(),
             sqlSelectColumns(tableInfo, false), tableInfo.getTableName(), tableInfo.getKeyColumn(),
-            SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA)),
-            Object.class);
+            SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA),
+            tableInfo.getLogicDeleteSql(true, false)), Object.class);
         return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
     }
 }

+ 4 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectById.java

@@ -32,10 +32,11 @@ public class SelectById extends AbstractMethod {
 
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_BY_ID;
+        SqlMethod sqlMethod = SqlMethod.LOGIC_SELECT_BY_ID;
         SqlSource sqlSource = new RawSqlSource(configuration, String.format(sqlMethod.getSql(),
-            this.sqlSelectColumns(tableInfo, false),
-            tableInfo.getTableName(), tableInfo.getKeyColumn(), tableInfo.getKeyProperty()), Object.class);
+            sqlSelectColumns(tableInfo, false),
+            tableInfo.getTableName(), tableInfo.getKeyColumn(), tableInfo.getKeyProperty(),
+            tableInfo.getLogicDeleteSql(true, false)), Object.class);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
     }
 }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectByMap.java

@@ -35,7 +35,7 @@ public class SelectByMap extends AbstractMethod {
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.SELECT_BY_MAP;
         String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, false),
-            tableInfo.getTableName(), this.sqlWhereByMap(tableInfo));
+            tableInfo.getTableName(), sqlWhereByMap(tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Map.class);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
     }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectCount.java

@@ -32,7 +32,7 @@ public class SelectCount extends AbstractMethod {
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.SELECT_COUNT;
-        String sql = String.format(sqlMethod.getSql(), this.sqlCount(), tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo));
+        String sql = String.format(sqlMethod.getSql(), this.sqlCount(), tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Integer.class, null);
     }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectList.java

@@ -33,7 +33,7 @@ public class SelectList extends AbstractMethod {
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.SELECT_LIST;
         String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo));
+            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
     }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectMaps.java

@@ -35,7 +35,7 @@ public class SelectMaps extends AbstractMethod {
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.SELECT_MAPS;
         String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo));
+            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Map.class, tableInfo);
     }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectMapsPage.java

@@ -35,7 +35,7 @@ public class SelectMapsPage extends AbstractMethod {
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.SELECT_MAPS_PAGE;
         String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo));
+            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Map.class, tableInfo);
     }

+ 3 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectObjs.java

@@ -15,12 +15,11 @@
  */
 package com.baomidou.mybatisplus.core.injector.methods;
 
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
 import com.baomidou.mybatisplus.core.enums.SqlMethod;
 import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlSource;
 
 /**
  * 查询满足条件所有数据
@@ -34,7 +33,7 @@ public class SelectObjs extends AbstractMethod {
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.SELECT_OBJS;
         String sql = String.format(sqlMethod.getSql(), sqlSelectObjsColumns(tableInfo),
-            tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo));
+            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Object.class, tableInfo);
     }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/SelectPage.java

@@ -33,7 +33,7 @@ public class SelectPage extends AbstractMethod {
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.SELECT_PAGE;
         String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo));
+            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
     }

+ 2 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/Update.java

@@ -33,7 +33,8 @@ public class Update extends AbstractMethod {
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
         SqlMethod sqlMethod = SqlMethod.UPDATE;
         String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(),
-            sqlSet(false, true, tableInfo, true, ENTITY, ENTITY_DOT), sqlWhereEntityWrapper(true, tableInfo));
+            sqlSet(true, true, tableInfo, true, ENTITY, ENTITY_DOT),
+            sqlWhereEntityWrapper(true, tableInfo));
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
     }

+ 14 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/UpdateById.java

@@ -18,6 +18,7 @@ package com.baomidou.mybatisplus.core.injector.methods;
 import com.baomidou.mybatisplus.core.enums.SqlMethod;
 import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import org.apache.ibatis.mapping.MappedStatement;
 import org.apache.ibatis.mapping.SqlSource;
 
@@ -31,14 +32,21 @@ public class UpdateById extends AbstractMethod {
 
     @Override
     public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
+        String sql;
+        boolean logicDelete = tableInfo.isLogicDelete();
         SqlMethod sqlMethod = SqlMethod.UPDATE_BY_ID;
-        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(),
-            sqlSet(false, false, tableInfo, false, ENTITY, ENTITY_DOT),
+        StringBuilder append = new StringBuilder("<if test=\"et instanceof java.util.Map\">")
+            .append("<if test=\"et.").append(OptimisticLockerInterceptor.MP_OPTLOCK_VERSION_ORIGINAL).append("!=null\">")
+            .append(" AND ${et.").append(OptimisticLockerInterceptor.MP_OPTLOCK_VERSION_COLUMN)
+            .append("}=#{et.").append(OptimisticLockerInterceptor.MP_OPTLOCK_VERSION_ORIGINAL).append(StringPool.RIGHT_BRACE)
+            .append("</if></if>");
+        if (logicDelete) {
+            append.append(tableInfo.getLogicDeleteSql(true, false));
+        }
+        sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(),
+            sqlSet(logicDelete, false, tableInfo, false, ENTITY, ENTITY_DOT),
             tableInfo.getKeyColumn(), ENTITY_DOT + tableInfo.getKeyProperty(),
-            new StringBuilder("<if test=\"et instanceof java.util.Map\">")
-                .append("<if test=\"et.MP_OPTLOCK_VERSION_ORIGINAL!=null\">")
-                .append(" AND ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}")
-                .append("</if></if>"));
+            append);
         SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
         return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
     }

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

@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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;
-
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
-import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
-
-/**
- * 抽象的注入方法类
- *
- * @author hubin
- * @since 2018-04-06
- */
-public abstract class AbstractLogicMethod extends AbstractMethod {
-
-    public AbstractLogicMethod() {
-        // TO DO NOTHING
-    }
-
-    /**
-     * SQL 更新 set 语句
-     *
-     * @param table 表信息
-     * @return sql set 片段
-     */
-    protected String sqlLogicSet(TableInfo table) {
-        return "SET " + table.getLogicDeleteSql(false, true);
-    }
-
-    // ------------ 处理逻辑删除条件过滤 ------------
-
-    @Override
-    protected String sqlWhereEntityWrapper(boolean newLine, TableInfo table) {
-        if (table.isLogicDelete()) {
-            String sqlScript = table.getAllSqlWhere(true, true, WRAPPER_ENTITY_DOT);
-            sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER_ENTITY),
-                true);
-            sqlScript += (NEWLINE + table.getLogicDeleteSql(true, false) + NEWLINE);
-            String normalSqlScript = SqlScriptUtils.convertIf(String.format("AND ${%s}", WRAPPER_SQLSEGMENT),
-                String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
-                    WRAPPER_NONEMPTYOFNORMAL), true);
-            normalSqlScript += NEWLINE;
-            normalSqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT),
-                String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
-                    WRAPPER_EMPTYOFNORMAL), true);
-            sqlScript += normalSqlScript;
-            sqlScript = SqlScriptUtils.convertChoose(String.format("%s != null", WRAPPER), sqlScript,
-                table.getLogicDeleteSql(false, false));
-            sqlScript = SqlScriptUtils.convertWhere(sqlScript);
-            return newLine ? NEWLINE + sqlScript : sqlScript;
-        }
-        // 正常逻辑
-        return super.sqlWhereEntityWrapper(newLine, table);
-    }
-
-    @Override
-    protected String sqlWhereByMap(TableInfo table) {
-        if (table.isLogicDelete()) {
-            // 逻辑删除
-            String sqlScript = SqlScriptUtils.convertChoose("v == null", " ${k} IS NULL ",
-                " ${k} = #{v} ");
-            sqlScript = SqlScriptUtils.convertForeach(sqlScript, "cm", "k", "v", "AND");
-            sqlScript = SqlScriptUtils.convertIf(sqlScript, "cm != null and !cm.isEmpty", true);
-            sqlScript += (NEWLINE + table.getLogicDeleteSql(true, false));
-            sqlScript = SqlScriptUtils.convertWhere(sqlScript);
-            return sqlScript;
-        }
-        return super.sqlWhereByMap(table);
-    }
-}

+ 3 - 48
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/LogicSqlInjector.java

@@ -15,30 +15,7 @@
  */
 package com.baomidou.mybatisplus.extension.injector;
 
-import static java.util.stream.Collectors.toList;
-
-import java.util.List;
-import java.util.stream.Stream;
-
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
-import com.baomidou.mybatisplus.core.injector.AbstractSqlInjector;
-import com.baomidou.mybatisplus.core.injector.methods.Insert;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicDelete;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteBatchByIds;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteById;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByMap;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectBatchByIds;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectById;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectByMap;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectCount;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectList;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectMaps;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectMapsPage;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectObjs;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectOne;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicSelectPage;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicUpdate;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicUpdateById;
+import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
 
 /**
  * SQL 逻辑删除注入器
@@ -46,28 +23,6 @@ import com.baomidou.mybatisplus.extension.injector.methods.LogicUpdateById;
  * @author hubin
  * @since 2018-06-12
  */
-public class LogicSqlInjector extends AbstractSqlInjector {
-
-    @Override
-    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
-        return Stream.of(
-            new Insert(),
-            new LogicDelete(),
-            new LogicDeleteByMap(),
-            new LogicDeleteById(),
-            new LogicDeleteBatchByIds(),
-            new LogicUpdate(),
-            new LogicUpdateById(),
-            new LogicSelectById(),
-            new LogicSelectBatchByIds(),
-            new LogicSelectByMap(),
-            new LogicSelectOne(),
-            new LogicSelectCount(),
-            new LogicSelectMaps(),
-            new LogicSelectMapsPage(),
-            new LogicSelectObjs(),
-            new LogicSelectList(),
-            new LogicSelectPage()
-        ).collect(toList());
-    }
+@Deprecated
+public class LogicSqlInjector extends DefaultSqlInjector {
 }

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

@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 queryWrapper 删除
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicDelete extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        String sql;
-        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE;
-        if (tableInfo.isLogicDelete()) {
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
-                sqlWhereEntityWrapper(true, tableInfo));
-        } else {
-            sqlMethod = SqlMethod.DELETE;
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(),
-                sqlWhereEntityWrapper(true, tableInfo));
-        }
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
-    }
-}

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

@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 ID 集合删除
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicDeleteBatchByIds extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        String sql;
-        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BATCH_BY_IDS;
-        if (tableInfo.isLogicDelete()) {
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
-                tableInfo.getKeyColumn(),
-                SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA),
-                tableInfo.getLogicDeleteSql(true, false));
-        } else {
-            sqlMethod = SqlMethod.DELETE_BATCH_BY_IDS;
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
-                SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA));
-        }
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Object.class);
-        return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
-    }
-}

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

@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 ID 删除
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicDeleteById extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        String sql;
-        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_ID;
-        if (tableInfo.isLogicDelete()) {
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo),
-                tableInfo.getKeyColumn(), tableInfo.getKeyProperty(),
-                tableInfo.getLogicDeleteSql(true, false));
-        } else {
-            sqlMethod = SqlMethod.DELETE_BY_ID;
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
-                tableInfo.getKeyProperty());
-        }
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Object.class);
-        return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
-    }
-}

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

@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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;
-
-/**
- * use {@link com.baomidou.mybatisplus.extension.injector.methods.additional.LogicDeleteByIdWithFill}
- *
- * @author miemie
- * @since 2018-09-13
- * @deprecated 2018-11-09
- */
-@Deprecated
-public class LogicDeleteByIdWithFill extends com.baomidou.mybatisplus.extension.injector.methods.additional.LogicDeleteByIdWithFill {
-}

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

@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-import java.util.Map;
-
-/**
- * 根据 map 条件删除
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicDeleteByMap extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        String sql;
-        SqlMethod sqlMethod = SqlMethod.LOGIC_DELETE_BY_MAP;
-        if (tableInfo.isLogicDelete()) {
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), sqlLogicSet(tableInfo), sqlWhereByMap(tableInfo));
-        } else {
-            sqlMethod = SqlMethod.DELETE_BY_MAP;
-            sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(), this.sqlWhereByMap(tableInfo));
-        }
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Map.class);
-        return addUpdateMappedStatement(mapperClass, Map.class, sqlMethod.getMethod(), sqlSource);
-    }
-}

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

@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 ID 集合查询
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectBatchByIds extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.LOGIC_SELECT_BATCH_BY_IDS;
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, String.format(sqlMethod.getSql(),
-            sqlSelectColumns(tableInfo, false), tableInfo.getTableName(), tableInfo.getKeyColumn(),
-            SqlScriptUtils.convertForeach("#{item}", COLLECTION, null, "item", COMMA),
-            tableInfo.getLogicDeleteSql(true, false)), Object.class);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
-    }
-}

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

@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-import org.apache.ibatis.scripting.defaults.RawSqlSource;
-
-/**
- * 根据 ID 查询
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectById extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.LOGIC_SELECT_BY_ID;
-        SqlSource sqlSource = new RawSqlSource(configuration, String.format(sqlMethod.getSql(),
-            sqlSelectColumns(tableInfo, false),
-            tableInfo.getTableName(), tableInfo.getKeyColumn(), tableInfo.getKeyProperty(),
-            tableInfo.getLogicDeleteSql(true, false)), Object.class);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
-    }
-}

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

@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-import java.util.Map;
-
-/**
- * 根据 map 条件查询多条数据
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectByMap extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_BY_MAP;
-        String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, false),
-            tableInfo.getTableName(), sqlWhereByMap(tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Map.class);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
-    }
-}

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

@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 queryWrapper 条件查询 count
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectCount extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_COUNT;
-        String sql = String.format(sqlMethod.getSql(), this.sqlCount(), tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Integer.class, null);
-    }
-}

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

@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 queryWrapper 条件查询多条数据
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectList extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_LIST;
-        String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
-    }
-}

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

@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-import java.util.Map;
-
-/**
- * 根据 queryWrapper 条件查询多条数据
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectMaps extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_MAPS;
-        String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Map.class, tableInfo);
-    }
-}

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

@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-import java.util.Map;
-
-/**
- * 根据 queryWrapper 条件查询多条数据
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectMapsPage extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_MAPS_PAGE;
-        String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Map.class, tableInfo);
-    }
-}

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

@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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 org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-import com.baomidou.mybatisplus.core.enums.SqlMethod;
-import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-
-/**
- * 根据 queryWrapper 条件查询多条数据
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectObjs extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_OBJS;
-        String sql = String.format(sqlMethod.getSql(), sqlSelectObjsColumns(tableInfo),
-            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Object.class, tableInfo);
-    }
-}

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

@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 queryWrapper 条件查询一条数据
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectOne extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_ONE;
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, String.format(sqlMethod.getSql(),
-            this.sqlSelectColumns(tableInfo, true), tableInfo.getTableName(),
-            this.sqlWhereEntityWrapper(true, tableInfo)), modelClass);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
-    }
-}

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

@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 queryWrapper 条件分页查询
- *
- * @author hubin
- * @since 2018-06-13
- */
-public class LogicSelectPage extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.SELECT_PAGE;
-        String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(tableInfo, true),
-            tableInfo.getTableName(), sqlWhereEntityWrapper(true, tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, tableInfo);
-    }
-}

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

@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 entity 有值字段 以及 updateWrapper 的条件更新
- *
- * @author hubin
- * @since 2018-04-06
- */
-public class LogicUpdate extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        SqlMethod sqlMethod = SqlMethod.UPDATE;
-        String sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(),
-            sqlSet(true, true, tableInfo, true, ENTITY, ENTITY_DOT),
-            sqlWhereEntityWrapper(true, tableInfo));
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
-    }
-}

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

@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (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.metadata.TableInfo;
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.extension.injector.AbstractLogicMethod;
-import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.mapping.SqlSource;
-
-/**
- * 根据 ID 更新有值字段
- *
- * @author hubin
- * @since 2018-04-06
- */
-public class LogicUpdateById extends AbstractLogicMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        String sql;
-        boolean logicDelete = tableInfo.isLogicDelete();
-        SqlMethod sqlMethod = SqlMethod.UPDATE_BY_ID;
-        StringBuilder append = new StringBuilder("<if test=\"et instanceof java.util.Map\">")
-            .append("<if test=\"et.").append(OptimisticLockerInterceptor.MP_OPTLOCK_VERSION_ORIGINAL).append("!=null\">")
-            .append(" AND ${et.").append(OptimisticLockerInterceptor.MP_OPTLOCK_VERSION_COLUMN)
-            .append("}=#{et.").append(OptimisticLockerInterceptor.MP_OPTLOCK_VERSION_ORIGINAL).append(StringPool.RIGHT_BRACE)
-            .append("</if></if>");
-        if (logicDelete) {
-            append.append(tableInfo.getLogicDeleteSql(true, false));
-        }
-        sql = String.format(sqlMethod.getSql(), tableInfo.getTableName(),
-            sqlSet(logicDelete, false, tableInfo, false, ENTITY, ENTITY_DOT),
-            tableInfo.getKeyColumn(), ENTITY_DOT + tableInfo.getKeyProperty(),
-            append);
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
-        return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
-    }
-}