Prechádzať zdrojové kódy

重命名修改下逻辑

hubin 7 rokov pred
rodič
commit
a8f0a5b042
14 zmenil súbory, kde vykonal 311 pridanie a 298 odobranie
  1. 46 7
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractWrapper.java
  2. 10 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/Wrapper.java
  3. 0 65
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/AbstractUpdWrapper.java
  4. 0 47
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/LamUpdWrapper.java
  5. 60 0
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/LambdaUpdateWrapper.java
  6. 0 44
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/StrUpdWrapper.java
  7. 66 0
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/UpdateWrapper.java
  8. 0 42
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/AbstractEntityWrapper.java
  9. 88 0
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/EntityWrapper.java
  10. 35 15
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/LambdaEntityWrapper.java
  11. 0 67
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/StrEntityWrapper.java
  12. 0 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/SqlHelper.java
  13. 6 8
      mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/core/test/WrapperTest.java
  14. 0 1
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserTest.java

+ 46 - 7
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractWrapper.java

@@ -15,17 +15,41 @@
  */
 package com.baomidou.mybatisplus.core.conditions;
 
-import com.baomidou.mybatisplus.core.enums.SqlKeyword;
-import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-
-import java.util.*;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.AND;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.ASC;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.BETWEEN;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.DESC;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.EQ;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.EXISTS;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.GE;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.GROUP_BY;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.GT;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.HAVING;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.IN;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.IS_NOT_NULL;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.IS_NULL;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.LE;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.LIKE;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.LT;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.NE;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.NOT;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.OR;
+import static com.baomidou.mybatisplus.core.enums.SqlKeyword.ORDER_BY;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
-import static com.baomidou.mybatisplus.core.enums.SqlKeyword.*;
+import com.baomidou.mybatisplus.core.enums.SqlKeyword;
+import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 
 
 /**
@@ -51,6 +75,21 @@ public abstract class AbstractWrapper<T, R, This extends AbstractWrapper<T, R, T
     private List<ISqlSegment> expression = new ArrayList<>();
     private boolean didOrderBy = false;
 
+    /**
+     * 数据库表映射实体类
+     */
+    protected T entity;
+
+    @Override
+    public T getEntity() {
+        return this.entity;
+    }
+
+    public This setEntity(T entity) {
+        this.entity = entity;
+        return typedThis();
+    }
+
     public abstract String columnToString(R column);
 
     public This apply(String condition) {

+ 10 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/Wrapper.java

@@ -28,9 +28,18 @@ import java.io.Serializable;
 public abstract class Wrapper<T> implements ISqlSegment, Serializable {
 
     /**
+     * <p>
      * 实体对象(子类实现)
+     * </p>
+     *
+     * @return 泛型 T
      */
-    public T getEntity() {
+    public abstract T getEntity();
+
+    /**
+     * 查询条件 SQL 片段(子类实现)
+     */
+    public String getSqlSelect() {
         return null;
     }
 

+ 0 - 65
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/AbstractUpdWrapper.java

@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2011-2020, 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>
- * http://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.core.conditions.update;
-
-
-import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
-
-/**
- * <p>
- * Entity 对象封装操作类,定义T-SQL语法
- * </p>
- *
- * @author hubin , yanghu , Dyang , Caratacus
- * @Date 2016-11-7
- */
-public abstract class AbstractUpdWrapper<T, R, This extends AbstractUpdWrapper<T, R, This>> extends AbstractWrapper<T, R, This> {
-
-    /**
-     * 数据库表映射实体类
-     */
-    protected T entity = null;
-    /**
-     * SQL 更新字段内容,例如:name='1',age=2
-     */
-    protected String sqlSet = null;
-
-    @Override
-    public T getEntity() {
-        return entity;
-    }
-
-    public This setEntity(T entity) {
-        this.entity = entity;
-        return typedThis();
-    }
-
-    /**
-     * SQL SET 字段
-     */
-    @Override
-    public String getSqlSet() {
-        return sqlSet;
-    }
-
-    /**
-     * SQL 片段
-     */
-    @Override
-    public String getSqlSegment() {
-        return null;
-    }
-}

+ 0 - 47
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/LamUpdWrapper.java

@@ -1,47 +0,0 @@
-package com.baomidou.mybatisplus.core.conditions.update;
-
-import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
-import com.baomidou.mybatisplus.core.toolkit.support.Property;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author hubin miemie HCL
- * @since 2018-05-30
- */
-public class LamUpdWrapper<T> extends AbstractUpdWrapper<T, Property<T, ?>, LamUpdWrapper<T>> {
-
-    public LamUpdWrapper() {
-        /* 注意,传入查询参数 */
-        initNeed();
-    }
-
-    public LamUpdWrapper(T entity) {
-        this.entity = entity;
-        initNeed();
-    }
-
-    public LamUpdWrapper(T entity, String sqlSet) {
-        this.entity = entity;
-        this.sqlSet = sqlSet;
-        initNeed();
-    }
-
-    private LamUpdWrapper(T entity, String sqlSet, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
-        this.entity = entity;
-        this.sqlSet = sqlSet;
-        this.paramNameSeq = paramNameSeq;
-        this.paramNameValuePairs = paramNameValuePairs;
-    }
-
-    @Override
-    public String columnToString(Property<T, ?> column) {
-        return TableInfoHelper.toColumn(column);
-    }
-
-    @Override
-    protected LamUpdWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
-        return new LamUpdWrapper<>(entity, sqlSet, paramNameSeq, paramNameValuePairs);
-    }
-}

+ 60 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/LambdaUpdateWrapper.java

@@ -0,0 +1,60 @@
+package com.baomidou.mybatisplus.core.conditions.update;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
+import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
+import com.baomidou.mybatisplus.core.toolkit.support.Property;
+
+/**
+ * @author hubin miemie HCL
+ * @since 2018-05-30
+ */
+public class LambdaUpdateWrapper<T> extends AbstractWrapper<T, Property<T, ?>, LambdaUpdateWrapper<T>> {
+
+    /**
+     * SQL 更新字段内容,例如:name='1',age=2
+     */
+    protected String sqlSet;
+
+    public LambdaUpdateWrapper() {
+        this(null, null);
+    }
+
+    public LambdaUpdateWrapper(T entity) {
+        this(entity, null);
+    }
+
+    public LambdaUpdateWrapper(T entity, String sqlSet) {
+        this.entity = entity;
+        this.sqlSet = sqlSet;
+        this.initNeed();
+    }
+
+    private LambdaUpdateWrapper(T entity, String sqlSet, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+        this.entity = entity;
+        this.sqlSet = sqlSet;
+        this.paramNameSeq = paramNameSeq;
+        this.paramNameValuePairs = paramNameValuePairs;
+    }
+
+    @Override
+    public String getSqlSet() {
+        return sqlSet;
+    }
+
+    public void setSqlSet(String sqlSet) {
+        this.sqlSet = sqlSet;
+    }
+
+    @Override
+    public String columnToString(Property<T, ?> column) {
+        return TableInfoHelper.toColumn(column);
+    }
+
+    @Override
+    protected LambdaUpdateWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+        return new LambdaUpdateWrapper<>(entity, sqlSet, paramNameSeq, paramNameValuePairs);
+    }
+}

+ 0 - 44
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/StrUpdWrapper.java

@@ -1,44 +0,0 @@
-package com.baomidou.mybatisplus.core.conditions.update;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author hubin miemie HCL
- * @since 2018-05-30
- */
-public class StrUpdWrapper<T> extends AbstractUpdWrapper<T, String, StrUpdWrapper<T>> {
-
-    public StrUpdWrapper() {
-        /* 注意,传入查询参数 */
-        initNeed();
-    }
-
-    public StrUpdWrapper(T entity) {
-        this.entity = entity;
-        initNeed();
-    }
-
-    public StrUpdWrapper(T entity, String sqlSet) {
-        this.entity = entity;
-        this.sqlSet = sqlSet;
-        initNeed();
-    }
-
-    private StrUpdWrapper(T entity, String sqlSet, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
-        this.entity = entity;
-        this.sqlSet = sqlSet;
-        this.paramNameSeq = paramNameSeq;
-        this.paramNameValuePairs = paramNameValuePairs;
-    }
-
-    @Override
-    public String columnToString(String column) {
-        return column;
-    }
-
-    @Override
-    protected StrUpdWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
-        return new StrUpdWrapper<>(entity, sqlSet, paramNameSeq, paramNameValuePairs);
-    }
-}

+ 66 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/UpdateWrapper.java

@@ -0,0 +1,66 @@
+package com.baomidou.mybatisplus.core.conditions.update;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
+
+/**
+ * <p>
+ * Update 条件封装
+ * </p>
+ *
+ * @author hubin miemie HCL
+ * @since 2018-05-30
+ */
+public class UpdateWrapper<T> extends AbstractWrapper<T, String, UpdateWrapper<T>> {
+
+    /**
+     * SQL 更新字段内容,例如:name='1',age=2
+     */
+    protected String sqlSet;
+
+    public UpdateWrapper() {
+        this(null, null);
+    }
+
+    public UpdateWrapper(T entity) {
+        this(entity, null);
+    }
+
+    public UpdateWrapper(T entity, String sqlSet) {
+        this.entity = entity;
+        this.sqlSet = sqlSet;
+        this.initNeed();
+    }
+
+    private UpdateWrapper(T entity, String sqlSet, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+        this.entity = entity;
+        this.sqlSet = sqlSet;
+        this.paramNameSeq = paramNameSeq;
+        this.paramNameValuePairs = paramNameValuePairs;
+    }
+
+    public LambdaUpdateWrapper<T> stream() {
+        return new LambdaUpdateWrapper<>(this.entity, this.sqlSet);
+    }
+
+    @Override
+    public String getSqlSet() {
+        return sqlSet;
+    }
+
+    public void setSqlSet(String sqlSet) {
+        this.sqlSet = sqlSet;
+    }
+
+    @Override
+    public String columnToString(String column) {
+        return column;
+    }
+
+    @Override
+    protected UpdateWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+        return new UpdateWrapper<>(entity, sqlSet, paramNameSeq, paramNameValuePairs);
+    }
+}

+ 0 - 42
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/AbstractEntityWrapper.java

@@ -1,42 +0,0 @@
-package com.baomidou.mybatisplus.core.conditions.where;
-
-import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
-
-/**
- * @author hubin miemie HCL
- * @since 2018-05-30
- */
-public abstract class AbstractEntityWrapper<T, R, This extends AbstractEntityWrapper<T, R, This>> extends AbstractWrapper<T, R, This> {
-
-    /**
-     * 数据库表映射实体类
-     */
-    protected T entity = null;
-    /**
-     * SQL 查询字段内容,例如:id,name,age
-     */
-    protected String sqlSelect = null;
-
-    @Override
-    public T getEntity() {
-        return entity;
-    }
-
-    public This setEntity(T entity) {
-        this.entity = entity;
-        return typedThis();
-    }
-
-    public String getSqlSelect() {
-        return StringUtils.isEmpty(sqlSelect) ? null : SqlUtils.stripSqlInjection(sqlSelect);
-    }
-
-    public This setSqlSelect(String sqlSelect) {
-        if (StringUtils.isNotEmpty(sqlSelect)) {
-            this.sqlSelect = sqlSelect;
-        }
-        return typedThis();
-    }
-}

+ 88 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/EntityWrapper.java

@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2011-2014, 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>
+ * http://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.core.conditions.where;
+
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
+
+/**
+ * <p>
+ * Entity 对象封装操作类
+ * </p>
+ *
+ * @author hubin miemie HCL
+ * @Date 2018-05-25
+ */
+public class EntityWrapper<T> extends AbstractWrapper<T, String, EntityWrapper<T>> {
+
+    /**
+     * SQL 查询字段内容,例如:id,name,age
+     */
+    private String sqlSelect;
+
+
+    @Override
+    public String getSqlSelect() {
+        return StringUtils.isEmpty(sqlSelect) ? null : SqlUtils.stripSqlInjection(sqlSelect);
+    }
+
+    public EntityWrapper<T> setSqlSelect(String sqlSelect) {
+        if (StringUtils.isNotEmpty(sqlSelect)) {
+            this.sqlSelect = sqlSelect;
+        }
+        return this;
+    }
+
+    public EntityWrapper() {
+        this(null, null);
+    }
+
+    public EntityWrapper(T entity) {
+        this(entity, null);
+    }
+
+    public EntityWrapper(T entity, String sqlSelect) {
+        this.sqlSelect = sqlSelect;
+        this.entity = entity;
+        this.initNeed();
+    }
+
+    private EntityWrapper(T entity, String sqlSelect, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+        this.entity = entity;
+        this.sqlSelect = sqlSelect;
+        this.paramNameSeq = paramNameSeq;
+        this.paramNameValuePairs = paramNameValuePairs;
+    }
+
+    public LambdaEntityWrapper<T> stream() {
+        return new LambdaEntityWrapper<>(this.entity, this.sqlSelect);
+    }
+
+    @Override
+    public String columnToString(String column) {
+        return column;
+    }
+
+    @Override
+    protected EntityWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+        return new EntityWrapper<>(entity, sqlSelect, paramNameSeq, paramNameValuePairs);
+    }
+}

+ 35 - 15
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/LamEntityWrapper.java → mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/LambdaEntityWrapper.java

@@ -15,51 +15,71 @@
  */
 package com.baomidou.mybatisplus.core.conditions.where;
 
-import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
-import com.baomidou.mybatisplus.core.toolkit.support.Property;
-
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
+import com.baomidou.mybatisplus.core.toolkit.support.Property;
+
 /**
  * <p>
- * 查询条件封装
+ * Lambda 语法使用 Wrapper
  * </p>
  *
  * @author hubin miemie HCL
  * @since 2017-05-26
  */
-public class LamEntityWrapper<T> extends AbstractEntityWrapper<T, Property<T, ?>, LamEntityWrapper<T>> {
+public class LambdaEntityWrapper<T> extends AbstractWrapper<T, Property<T, ?>, LambdaEntityWrapper<T>> {
+
+    /**
+     * SQL 查询字段内容,例如:id,name,age
+     */
+    private String sqlSelect;
 
-    public LamEntityWrapper() {
-        initNeed();
+
+    public LambdaEntityWrapper() {
+        this(null, null);
     }
 
-    public LamEntityWrapper(T entity) {
-        this.entity = entity;
-        initNeed();
+    public LambdaEntityWrapper(T entity) {
+        this(entity, null);
     }
 
-    public LamEntityWrapper(T entity, String sqlSelect) {
+    public LambdaEntityWrapper(T entity, String sqlSelect) {
         this.entity = entity;
         this.sqlSelect = sqlSelect;
-        initNeed();
+        this.initNeed();
     }
 
-    private LamEntityWrapper(T entity, String sqlSelect, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+    private LambdaEntityWrapper(T entity, String sqlSelect, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
         this.entity = entity;
         this.sqlSelect = sqlSelect;
         this.paramNameSeq = paramNameSeq;
         this.paramNameValuePairs = paramNameValuePairs;
     }
 
+    @Override
+    public String getSqlSelect() {
+        return StringUtils.isEmpty(sqlSelect) ? null : SqlUtils.stripSqlInjection(sqlSelect);
+    }
+
+    public LambdaEntityWrapper<T> setSqlSelect(String sqlSelect) {
+        if (StringUtils.isNotEmpty(sqlSelect)) {
+            this.sqlSelect = sqlSelect;
+        }
+        return this;
+    }
+
     @Override
     public String columnToString(Property<T, ?> column) {
         return TableInfoHelper.toColumn(column);
     }
 
     @Override
-    protected LamEntityWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
-        return new LamEntityWrapper<>(entity, sqlSelect, paramNameSeq, paramNameValuePairs);
+    protected LambdaEntityWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
+        return new LambdaEntityWrapper<>(entity, sqlSelect, paramNameSeq, paramNameValuePairs);
     }
 }

+ 0 - 67
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/where/StrEntityWrapper.java

@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2011-2014, 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>
- * http://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.core.conditions.where;
-
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * <p>
- * Entity 对象封装操作类
- * </p>
- *
- * @author hubin miemie HCL
- * @Date 2018-05-25
- */
-public class StrEntityWrapper<T> extends AbstractEntityWrapper<T, String, StrEntityWrapper<T>> {
-
-    public StrEntityWrapper() {
-        initNeed();
-    }
-
-    public StrEntityWrapper(T entity) {
-        this.entity = entity;
-        initNeed();
-    }
-
-    public StrEntityWrapper(T entity, String sqlSelect) {
-        this.entity = entity;
-        this.sqlSelect = sqlSelect;
-        initNeed();
-    }
-
-    private StrEntityWrapper(T entity, String sqlSelect, AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
-        this.entity = entity;
-        this.sqlSelect = sqlSelect;
-        this.paramNameSeq = paramNameSeq;
-        this.paramNameValuePairs = paramNameValuePairs;
-    }
-
-    public LamEntityWrapper<T> stream() {//todo 这里有必要吗
-        return new LamEntityWrapper<>();
-    }
-
-    @Override
-    public String columnToString(String column) {
-        return column;
-    }
-
-    @Override
-    protected StrEntityWrapper<T> instance(AtomicInteger paramNameSeq, Map<String, Object> paramNameValuePairs) {
-        return new StrEntityWrapper<>(entity, sqlSelect, paramNameSeq, paramNameValuePairs);
-    }
-}

+ 0 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/SqlHelper.java

@@ -24,7 +24,6 @@ import org.apache.ibatis.session.ExecutorType;
 import org.apache.ibatis.session.SqlSession;
 import org.apache.ibatis.session.SqlSessionFactory;
 
-import com.baomidou.mybatisplus.core.conditions.where.StrEntityWrapper;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;

+ 6 - 8
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/core/test/WrapperTest.java

@@ -1,9 +1,10 @@
 package com.baomidou.mybatisplus.core.test;
 
-import com.baomidou.mybatisplus.core.conditions.where.StrEntityWrapper;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import org.junit.Test;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.where.EntityWrapper;
+
 public class WrapperTest {
 
     private void log(String message) {
@@ -12,18 +13,15 @@ public class WrapperTest {
 
     @Test
     public void test() {
-        Wrapper wrapper = new StrEntityWrapper<User>().stream().eq(User::getName, 123)
+        Wrapper wrapper = new EntityWrapper<User>().stream().eq(User::getName, 123)
+            .or(c -> c.eq(User::getRoleId, 1).eq(User::getId, 2))
             .and().eq(User::getId, 1);
         log(wrapper.getSqlSegment());
-
-        wrapper = new StrEntityWrapper<User>().eq("name", 123)
-            .and().eq("id", 1);
-        log(wrapper.getSqlSegment());
     }
 
     @Test
     public void test1() {
-        StrEntityWrapper<User> ew = new StrEntityWrapper<User>()
+        EntityWrapper<User> ew = new EntityWrapper<User>()
             .eq("xxx", 123)
             .and(i -> i.eq("andx", 65444).and().le("ande", 66666))
             .and().ne("xxx", 222);

+ 0 - 1
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserTest.java

@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import com.baomidou.mybatisplus.core.conditions.where.StrEntityWrapper;
 import com.baomidou.mybatisplus.core.pagination.Page;
 import com.baomidou.mybatisplus.test.h2.config.H2Db;
 import com.baomidou.mybatisplus.test.h2.entity.persistent.H2User;