فهرست منبع

调整构造条件

hubin 7 سال پیش
والد
کامیت
a5d30ab014

+ 12 - 8
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/core/test/query/Condition.java

@@ -62,6 +62,10 @@ public class Condition implements ISqlSegment {
         return this.addNestedCondition(condition, IN);
     }
 
+    public Condition notIn(String condition) {
+        return this.not().addNestedCondition(condition, IN);
+    }
+
     /**
      * LIKE '%值%'
      */
@@ -169,14 +173,6 @@ public class Condition implements ISqlSegment {
         return this.addCondition(condition, ORDER_BY);
     }
 
-    /**
-     * NOT 关键词
-     */
-    public Condition not() {
-        expression.add(NOT);
-        return this;
-    }
-
     /**
      * HAVING 关键词
      */
@@ -212,6 +208,14 @@ public class Condition implements ISqlSegment {
         return this;
     }
 
+    /**
+     * NOT 关键词
+     */
+    protected Condition not() {
+        expression.add(NOT);
+        return this;
+    }
+
     /**
      * <p>
      * 普通查询条件

+ 1 - 1
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/core/test/query/QueryTest.java

@@ -17,7 +17,7 @@ public class QueryTest {
             .where("b.age > 18", condition ->
                 condition.and("b.type = 'rabid'")
                     .or(nested -> nested.apply("name='12'").and("age=1"))
-                    .not().in("ads,2112,212")
+                    .notIn("ads,2112,212")
                     .last("LIMIT 1")
             ).sqlSegment();