MyBatis-Plus 多表联查+分页
发布日期:2021-05-09 01:08:35 浏览次数:14 分类:博客文章

本文共 1483 字,大约阅读时间需要 4 分钟。

在写东西的过程中,多表联查和分页功能必不可少。当然,crud也很重要

但是又不想写代码和xml。

通过苦苦的查找。发现MyBatis-Plus一款国产的框架。优化了许多操作

本次主要记录一下,多表联查和分页的使用。

Pom.xml        
com.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 Map
articleList(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); }
 

 

上一篇:当Thymeleaf遇到向js中传值的操作
下一篇:LayUI表单提交不走ajax原因

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年04月18日 17时56分52秒