mybatis-plus Wrappers相关Api

1.mybatis-plus  Wrappers相关Api

获取count和list

QueryWrapper<Test111> time = Wrappers.<Test111>query().ge("time","2025-11-04 00:00:00");
long count = this.count(time);
List list = this.list(time);

2. 分页

for(int i =0;i<totalPage;i++){

  List<Test111> recourds =  this.page(new Page(i+1,5),time).getRecords();

}

3. 批量插入

this.saveBatch(list)

4. 删除

QueryWrapper<Test111> time = Wrappers.<Test111>query().ge("time","2025-11-04 00:00:00");
this.remove(time);

5. 根据ids批量更新

List<Integer> ids = records.stream().map(i->i.getId()).collect(Collectors.toList());
UpdateWrapper<Test111> update1 = Wrappers.<Test111>update();
update1.set("name","zhangsan");
update1.in("id",ids);
this.update(update1);

单表操作可以用上面的,复杂sql关联查询的,建议写sql方式

 

posted @ 2025-11-12 16:21  技术虫  阅读(4)  评论(0)    收藏  举报