• lambdaQueryWrapper常用方法


    函数名

    说明

    例子

    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,20) ------> age between 18 and 20

    notBetween

    NOT BETWEEN 值1 AND 值2

    notBetween(“age”,18,20) ------> age not between 18 and 20

    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”,{18,20,30}) ------> age in (18,20,30)

    notIn

    字段 NOT IN (v0,v1,…)

    notIn(“age”,18,20,30) ------> age not in (18,20,30)

    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

    排序:ORDERBY 字段,… ASC

    orderByAsc(“id”,“name”) ------> order by id ASC,name ASC

    orderByDesc

    排序:ORDERBY 字段,… DESC

    orderByDesc(“id”,“name”) ------> order by id DESC,name DESC

    orderBy

    排序:ORDERBY 字段,…

    orderBy(“id”,“name”) ------> order by id DESC,name DESC

    having

    HAVING (slq语句)

    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(“age”,20) ------> and (name = ‘张三’ and age <> 20)

    apply

    拼接sql

    注意事项:该方法可用于数据库函数 动态入参的params对应前面sqlHaving内部的{index}部分,这样是不会有sql注入风险的,反之会有!apply(“date_format(dateColumn,‘%Y-%m-%d’) = {0}”,“2022-02-08”) ------> date_format(dateColum, ‘%Y-%m-%d’) = ‘2022-02-08’

    last

    无视优化规则直接拼接到sql的最后

    注意事项:只能调用一次,多次调用以最后一次为准,有sql注入的风险,请谨慎使用 last(“limt 2”)

    exists

    拼接EXISTS (sql语句)

    exists(“select id from table where age = 20”) ------> exists (select id from table where age = 20)

    notExists

    拼接NOT EXISTS (sql语句)

    notExists(“select id from table where age = 20”) ------> not exists (select id from table where age = 20)

    nested

    正常嵌套 不带AND 或者 OR

    nested(i -> i.eq(“name”,“张三”).ne(“age”,20)) ------> nested(name = ‘张三’ and age <> 20)

  • 相关阅读:
    全波形反演的深度学习方法: 符号表
    【推荐系统】推荐系统基础算法-基于协同的推荐算法
    美团后端开发一面(40min)
    离子液体1-丁基-3-甲基咪唑六氟磷酸盐(BMI)改性氧化石墨烯(GO)文献摘要
    C++比Python快50倍?如何让C++和Python优势互补?(BoostPython)
    C++学习一--从C到C++
    keepalived的简单使用
    主动成为行业发展的一份子,正在成为一种潮流和趋势
    React 入门:组件化编码流程(一)拆分组件
    PlainUML(二)时序图
  • 原文地址:https://blog.csdn.net/m0_67265464/article/details/126034440