QueryWrapper的一些常用的方法
比较全的常用方法
函数名 | 说明 | 例子 |
---|---|---|
allEq(Map<R, V> params) | 全部 =(或个别 isNull) | allEq(params,true) |
eq | real_name = ‘阿大’ | eq(“real_name”,“阿大”) |
ne | 不等于 <> | ne(“real_name”,“阿大”) |
gt | age > 21 | gt(“age”,21) |
ge | age>= 22 | ge(“age”,22) |
lt | age< 22 | lt(“age”,22) |
le | age <= 221 | le(“age”,21") |
between | age between 0 and 21 | between(“age”,0,21) |
notBetween | age not between 0 and 21 | notBetween(“age”,0,21) |
like | real_name like ‘% 王 %’ | like(“real_name”,“王”) |
notLike | real_name not like ‘% 王 %’ | notLike(“real_name”,“王”) |
likeLeft | real_name like ‘% 王’ | likeLeft(“real_name”,“王”) |
likeRight | real_name like ‘王 %’ | likeRight(“real_name”,“王”) |
isNull | gender is null | isNull(“gender”) |
isNotNull | gender is not null | isNotNull(“gender”) |
in | name in (1,2,3) | in(“name ”,{1,2,3}) |
notIn | age not in (1,2,3) | notIn(“nick_name”,lists) |
inSql | id in (select id from table where id < 3) | inSql(“id”,“‘select id from table where id < 3’”) |
notInSql | id not in (select id from table where id < 3) | notInSql(“id”,“‘select id from table where id < 3’”) |
groupBy | 分组 group by id,name | groupBy(“id”,“name”) |
orderByAsc | 小到大排序 order by id ASC,name ASC | orderByAsc(“id ”,“name”) |
orderByDesc | 大到小排序 order by id DESC,name DESC | orderByDesc(“id ”,“name”) |
orderBy | order by id ASC,name ASC | orderBy(true,true,“id ”,“name”) |
having | having sum(age) > 10 | having(“sum(age) > 10”) |
or | id = 1 or name = ‘老王’ | eq(“id”,“1”).or() eq(“name ”,“老王”) |
and | and (name = ‘李白’ and status <> ‘活着’) | and(i->i.eq(“name ”,“李白”).ne(“status”,“活着”)) |
nested | (name = ‘李白’ and status <> ‘活着’) | nested(i->i.eq(“age”,21).eq(“status ”,“活着”)) |
apply | name = 李白 | apply(“name= ‘李白’) |
last | 最后添加多个以最后的为准,有 sql 注入风险 | last(“limit 1”) |
exists | 拼接 EXISTS (sql 语句) | exists(“select id from table where age = 1”) |
notExists | 拼接 NOT EXISTS (sql 语句) | notExists(“select id from table where age = 1”) |