02-myBatisPlus的wrapper接口的使用

Posted 大粪中敲代码

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了02-myBatisPlus的wrapper接口的使用相关的知识,希望对你有一定的参考价值。

02-myBatisPlus的wrapper接口的使用。

1.直接先上硬菜

序号函数名说明说明/例子
1eq等于=eq("name","二狗子") ==> where name = \'二狗子\'
2ne不等于 <>ne("name","二狗子") ==> where name <> \'二狗子\'
3gt大于 >gt("age",18) ==> where age >18
4ge大于等于 >=ge(""age",18) ==> where age >=18
5lt小于 <lt("age",18") ==> where age <18
6le小于等于 <=le("age",18) ==> where age <=18
7betweenbetween 值1 and值2between("age",18,30) ==> where age between 18 and 30
8notBetweennot between 值1 and值2not between("age",18,30) ==> where age not between 18 and 30
9likelike \'%值%\'like("name","二") ==> where name like \'%二%\'
10notLikenot like \'%值%\'notLike("name","二") ==> where name not like \'%二%\'
11likeLeftlike \'%值\'likeLeft("name","二") ==> where name like \'%二\'
12likeRightlike \'值%\'likeRight("name","二") ==> where name like \'二%\'
13isNull字段 is nullisNUll(”name“) ==> where name is null
14isNotNull字段 is not nullisNotNull("name") ==> where name is not null
15in字段 in ( v0,v1,v2...)in("age",{1,2,3}) ==> where age in (1,2,3)
16notIn字段 not in(v0,v1...)notIn("age",{1,2,3}) ==> where age not in(1,2,3)
17inSql字段 in ( sql语句)inSql("id","select id form user where age > 3") ==> id in(select id form user where age > 3)
18notInSql字段 not in ( sql语句)notInSql("id","select id form user where age > 3") ==> id not in(select id form user where age > 3)
19groupBy分组:group bygroupBy("id","name") ==> group by id,name
20orderByAsc排序 :order by 正序orderByAsc("id","name") ==> order by id ASC,name ASC
21orderByDesc排序 :order by 倒序orderByDesc("id","name") ==> order by id DESC,name DESC
22orderBy排序:order byorderBy("id","name") ==> order by id ASC,name ASC
23havinghaving(sql语句)having("sum{age} > {0}",11) ==> having sum(age) >11
24or拼接 or注意事项:主动调用or表示紧接着下一个方法不是用and连接!(不调用or则用and连接)eq("id",1).or().eq("name","二狗子") ==> id = 1 or name = \'二狗子\'
25andand嵌套and(mapper.eq("id",1).ne("status",”活着“))==> id = 1 and status <> \'活着\'
26apply拼接sql注意事项:该方法可用于数据库函数。动态入参的params对应前面sqlHaving{index}部分。这样是不会有sql注入风险的,反之则会有! apply("date_format(dateColumn,\'%Y-%m-%d\') = {0}","2020-10-24") ==> date_format(dateColumn,\'%Y-%m-%d\') = \'2020-10-24\';
27last无视优化规则直接拼接到sql的最后注意事项:只能调用一次,多次调用以最后一次为准。有sql注入风险,需要谨慎使用。last("limit 1");
28exists拼接 exists(sql语句)exists("select id from user where age = 1") ==> exists(select id from user where age = 1);
29notExists拼接 not exists(sql语句)notExists("select id from user where age = 1") ==>not exists(select id from user where age = 1);
30nested正常嵌套,不带and或ornested(mapper.eq("id",1).ne("status",”活着“)) ==> (id = 1 and status <> \'活着\')

2.wrapper家族的关系






以上是关于02-myBatisPlus的wrapper接口的使用的主要内容,如果未能解决你的问题,请参考以下文章

keras开发成sklearn接口

如何键入 Reactstrap 的 Spinner 的 Wrapper 反应函数?

MybatisPlus的BaseMapper和Wrapper使用

MybatisPlus的BaseMapper和Wrapper使用

谈一谈在css中的wrapper

mybatis-plus一些通用方法