
MyBatis-Plus 多表联查+分页
发布日期:2021-05-09 01:08:35
浏览次数:14
分类:博客文章
本文共 1483 字,大约阅读时间需要 4 分钟。
在写东西的过程中,多表联查和分页功能必不可少。当然,crud也很重要
但是又不想写代码和xml。
通过苦苦的查找。发现MyBatis-Plus一款国产的框架。优化了许多操作
本次主要记录一下,多表联查和分页的使用。
Pom.xmlcom.baomidou mybatis-plus-boot-starter 3.0.7.1
//Spring boot方式 @EnableTransactionManagement@Configuration@MapperScan("com.baomidou.cloud.service.*.mapper*")public class MybatisPlusConfig { /** * 分页插件 */ @Bean public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); }}
操作完以上步骤(实体 mapper controller 等已建好)
@ResponseBody@GetMapping("/artList") public MaparticleList(int page,int limit,Article article){ Page pageArt=new Page (page,limit); Page page1 = articleMapper.findAllAndPage(pageArt); //自定义方法,多表// QueryWrapper diseaseQueryWrapperw = new QueryWrapper (article); // IPage page1 = articleService.page(pageArt,diseaseQueryWrapperw); //自带的分页查询。只能单表// List list = articleService.list(); int total = (int)page1.getTotal(); return TableMap.ResultJson(0,total,"ok",page1.getRecords()); //layui table 解析返回格式}
mapper Xml
mapper接口
public interface ArticleMapper extends BaseMapper{ Page findAllAndPage( Page page); }
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年04月18日 17时56分52秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
[网站公告]11月26日00:00-04:00阿里云RDS升级
2021-05-09
[网站公告]又拍云API故障造成图片无法上传(已恢复)
2021-05-09
上周热点回顾(12.16-12.22)
2021-05-09
云计算之路-阿里云上:“黑色30秒”走了,“黑色1秒”来了,真相也许大白了
2021-05-09
云计算之路-阿里云上:奇怪的CPU 100%问题
2021-05-09
云计算之路-阿里云上:2014年6月12日12点IIS请求到达量突降
2021-05-09
上周热点回顾(6.9-6.15)
2021-05-09
上周热点回顾(6.16-6.22)
2021-05-09
上周热点回顾(10.20-10.26)
2021-05-09
上周热点回顾(2.16-2.22)
2021-05-09
上周热点回顾(3.2-3.8)
2021-05-09
.NET跨平台之旅:借助ASP.NET 5 Beta5的新特性显示CLR与操作系统信息
2021-05-09
上周热点回顾(7.27-8.2)
2021-05-09
上周热点回顾(9.28-10.4)
2021-05-09
上周热点回顾(5.2-5.8)
2021-05-09
上周热点回顾(5.9-5.15)
2021-05-09
.NET跨平台之旅:将示例站点升级至 .NET Core 1.1 Preview 1
2021-05-09
上周热点回顾(1.16-1.22)
2021-05-09
上周热点回顾(1.23-1.29)
2021-05-09
上周热点回顾(3.20-3.26)
2021-05-09