eq:

​ 说明:等于=

​ 例:

eq("name","老王")--------> name = '老王'
ne:

​ 说明:不等于

​ 例:

ne("name","老王")--------> name <> '老王'
gt:

​ 说明:大于>

​ 例:

gt("age",18)--------> age > 18
ge:

​ 说明:大于等于>=

​ 例:

ge("age",18)--------> age >= 18
lt:

​ 说明:小于<

​ 例:

lt("age",18)--------> age < 18
le:

​ 说明:小于等于<=

​ 例:

le("age",18)--------> age <= 18
between:

​ 说明:BETWEEN 值1 AND 值2

​ 例:

between("age",18,30)--------> age between 18 and 30
notBetween:

​ 说明:NOT BETWEEN 值1 AND 值2

​ 例:

notBetween("age",18,30)--------> age not between 18 and 30
like:

​ 说明:LIKE ‘%值%’

​ 例:

like("name","王")--------> name like '%王%'
notLike:

​ 说明:NOT LIKE ‘%值%’

​ 例:

notLike("name","王")--------> name not like '%王%'
likeLeft:

​ 说明:LIKE ‘%值’

​ 例:

likeLeft("name","王")--------> name like '%王'
likeRight:

​ 说明:LIKE ‘值%’

​ 例:

likeRight("name","王")--------> name like '王%'
isNull:

​ 说明:字段 IS NULL

​ 例:

isNull("name")--------> name is null
isNotNull:

​ 说明:字段 IS NOT NULL

​ 例:

isNotNull("name")--------> name is not null
in:

​ 说明:字段 IN (v0, v1, …)

​ 例:

in("age",{1,2,3})--------> age in (1,2,3)
notIn:

​ 说明:字段 NOT IN (v0, v1, …)

​ 例:

notIN("age",{1,2,3})--------> age not in (1,2,3)
inSql:

​ 说明:字段 IN ( SQL语句 )

​ 例:

inSql("id","select id from table where id < 3")--------> id in (select id from table where id < 3)
notInSql:

​ 说明:字段 NOT IN ( SQL语句 )

​ 例:

notInSql("id","select id from table where id < 3")--------> id not in (select id from table where id < 3)
groupBy:

​ 说明:分组 GROUP BY 字段, …

​ 例:

groupBy("id","name")--------> group by id,name
orderByAsc:

​ 说明:排序 ORDER BY 字段,… ASC

​ 例:

orderByAsc("id","name")--------> order by id ASC,name ASC
orderByDesc:

​ 说明:排序 ORDER BY 字段,… DESC

​ 例:

orderByDesc("id","name")--------> order by id DESC,name DESC
orderBy:

​ 说明:排序 ORDER BY 字段,…

​ 例:

orderBy("id","name")--------> order by id ASC,name ASC
having:

​ 说明:HAVING ( SQL语句 )

​ 例:

having("sum(age) > {0}",11)--------> having sum(age) > 11
or:

​ 说明:拼接 OR

​ 注意事项:主动调用 OR 表示紧接着下一个方法不是用 AND 连接!(不调用 OR 则默认使用 AND 连接)

​ 例:

eq.("id",1).or().eq("name","老王")--> id = 1 or name = '老王'
and:

​ 说明:AND 嵌套

​ 例:

and(i -> i.eq("name","老王").ne("status",1))--------> and (name = '老王' and status <> 1)
apply:

​ 说明:拼接 SQL

​ 注意事项:该方法可用于数据库函数,动态入参的 params 对应前面 sqlHaving 内部的 {index} 部分,这样是不会有 SQL 注入风险的,反之会有!

​ 例:

apply("date_format(dateColumn,'%Y-%m-%d') = {0}","2021-08-08")--------> date_format(dateColumn,'%Y-%m-%d') = '2021-08-08'
last:

​ 说明:无视优化规则直接拼接到 SQL 的最后

​ 注意事项:只能调用一次,多次调用以最后一次为准,有 SQL 注入的风险,请谨慎使用

​ 例:

last("limit 1")
exists:

​ 说明:拼接 EXISTS ( SQL 语句 )

​ 例:

exists("select id from table where age = 1")--------> exists (select id from table where age = 1)
notExists:

​ 说明:拼接 NOT EXISTS ( SQL 语句 )

​ 例:

notExists("select id from table where age = 1")--------> not exists (select id from table where age = 1)
nested:

​ 说明:正常嵌套 不带 AND 或者 OR

​ 例:

nested(i -> i.eq("name","老王").ne("status",1))--------> (name = '老王' and status <> 1)