mybatis-plus中and和or的使用

时间:2025-03-09 11:17:18

1、a and b形式

直接使用追加形式,比如连续的eq

2、a or b形式

使用or()来连接两个操作,使用的是Join接口中的or,比如eq(Test::getA, 1).or().eq(Test::getB, 2)

3、a or (b and c)形式

使用or(Consumer<Wrapper> consumer)形式,使用的是Nested接口中的or。比如eq(Test::getA, 1).or(w -> (Test::getB, 2).eq(Test::getC, 3)

4、(a and b) or (c and d)形式

使用and(Consumer<Wrapper> consumer).or(Consumer<Wrapper> consumer)形式,比如and(wp -> (Test::getA, 1).eq(Test::getB,2)).or(wp -> (Test::getC, 3).eq(Test::getD, 4)

5、a or (b and ( c or d))

使用and(()).or(wp -> (....).and(wp -> ().or().())