瀏覽代碼

被强烈要求把名字改回去

miemie 7 年之前
父節點
當前提交
51a8b56754

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

@@ -193,7 +193,7 @@ public abstract class AbstractWrapper<T, R, This extends AbstractWrapper<T, R, T
      * AND 嵌套
      */
     @Override
-    public This andNested(boolean condition, Function<This, This> func) {
+    public This and(boolean condition, Function<This, This> func) {
         return and(condition).addNestedCondition(condition, func);
     }
 
@@ -201,7 +201,7 @@ public abstract class AbstractWrapper<T, R, This extends AbstractWrapper<T, R, T
      * OR 嵌套
      */
     @Override
-    public This orNested(boolean condition, Function<This, This> func) {
+    public This or(boolean condition, Function<This, This> func) {
         return or(condition).addNestedCondition(condition, func);
     }
 

+ 6 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Nested.java

@@ -32,26 +32,26 @@ public interface Nested<This> extends Serializable {
     /**
      * AND 嵌套
      */
-    default This andNested(Function<This, This> func) {
-        return andNested(true, func);
+    default This and(Function<This, This> func) {
+        return and(true, func);
     }
 
     /**
      * AND 嵌套
      */
-    This andNested(boolean condition, Function<This, This> func);
+    This and(boolean condition, Function<This, This> func);
 
     /**
      * OR 嵌套
      */
-    default This orNested(Function<This, This> func) {
-        return orNested(true, func);
+    default This or(Function<This, This> func) {
+        return or(true, func);
     }
 
     /**
      * OR 嵌套
      */
-    This orNested(boolean condition, Function<This, This> func);
+    This or(boolean condition, Function<This, This> func);
 
     /**
      * 正常嵌套 不带 AND 或者 OR

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

@@ -15,7 +15,7 @@ public class WrapperTest {
     @Test
     public void test() {
         Wrapper<User> wrapper = new QueryWrapper<User>().lambda().eq(User::getName, 123)
-            .orNested(c -> c.eq(User::getRoleId, 1).eq(User::getId, 2))
+            .or(c -> c.eq(User::getRoleId, 1).eq(User::getId, 2))
             .and().eq(User::getId, 1);
         log(wrapper.getSqlSegment());
 
@@ -25,7 +25,7 @@ public class WrapperTest {
     public void test1() {
         QueryWrapper<User> ew = new QueryWrapper<User>()
             .eq("xxx", 123)
-            .andNested(i -> i.eq("andx", 65444).and().le("ande", 66666))
+            .and(i -> i.eq("andx", 65444).and().le("ande", 66666))
             .and().ne("xxx", 222);
         log(ew.getSqlSegment());
         ew.getParamNameValuePairs().forEach((k, v) -> System.out.println("key = " + k + " ; value = " + v));
@@ -36,7 +36,7 @@ public class WrapperTest {
         UpdateWrapper<User> ew = new UpdateWrapper<User>()
             .set("name", "三毛").set("id", 1)
             .eq("xxx", 123)
-            .andNested(i -> i.eq("andx", 65444).and().le("ande", 66666))
+            .and(i -> i.eq("andx", 65444).and().le("ande", 66666))
             .and().ne("xxx", 222);
         log(ew.getSqlSet());
         log(ew.getSqlSegment());

+ 5 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlTestDataMapperTest.java

@@ -46,10 +46,12 @@ public class MysqlTestDataMapperTest {
     public void specialSelectList() {
         println(testDataMapper.selectList(new QueryWrapper<TestData>().lambda()
             .nested(i -> i.eq(TestData::getId, 1L))
-            .orNested(i -> i.between(TestData::getTestDouble, 1L, 2L))
-            .orNested(i -> i.eq(TestData::getTestInt, 1))
+            .or(i -> i.between(TestData::getTestDouble, 1L, 2L))
+            .or(i -> i.eq(TestData::getTestInt, 1)
+                .or().eq(TestData::getTestDate, 1)
+            )
             .and().eq(TestData::getTestBoolean, true)
-            .and().eq(TestData::getTestDate,LocalDate.of(2008, 8, 8))
+            .and().eq(TestData::getTestDate, LocalDate.of(2008, 8, 8))
             .and().between(TestData::getTestDate, LocalDate.of(2008, 1, 1),
                 LocalDate.of(2008, 12, 12))));
     }