我的项目 使用MP 核心库版本是2.0.8 并且单表查询已经搭建好了前提下。
![5d010e8c125839190e20b6f1cc42f77e.png](https://img-blog.csdnimg.cn/img_convert/5d010e8c125839190e20b6f1cc42f77e.png)
部分主要结构
Mapper中:
![9574ab5dbd362f6a5d62f764a0b25ca0.png](https://img-blog.csdnimg.cn/img_convert/9574ab5dbd362f6a5d62f764a0b25ca0.png)
selectBusinessAndGoodsNameListPage是演示多表联合查询的方法需要注意的是 Pagination page 是必须传入的这个对象是在com.baomidou.mybatisplus.plugins.pagination.Pagination这个包。另外注意page 的一些参数你需要传入 不然会报错。
service中:
![7e7f91225e0ba1f1db619518a72deb8a.png](https://img-blog.csdnimg.cn/img_convert/7e7f91225e0ba1f1db619518a72deb8a.png)
这个地方的selectBusinessAndGoodsNameListPage不是Mapper的selectBusinessAndGoodsNameListPage。
serviceImp中:
![31713e2eb7aa5934f50ede80eb78110b.png](https://img-blog.csdnimg.cn/img_convert/31713e2eb7aa5934f50ede80eb78110b.png)
service中的selectBusinessAndGoodsNameListPage具体实现在这个服务实现类中实现。注意baseMapper.selectBusinessAndGoodsNameListPage(page,queryCondition)其实就是调用了Mapper的selectBusinessAndGoodsNameListPage,所以在Controller中调用这个服务类的这个方法 本质就是调用了Mapper.对于必须传入Pagination page我想是mybatis-plus 的拦截器拦截使用了page的参数拼接在sql上了。
最后是xml:
![8a20604973432e2f5f71d63c7344a1dd.png](https://img-blog.csdnimg.cn/img_convert/8a20604973432e2f5f71d63c7344a1dd.png)
xml其实就是这个selectBusinessAndGoodsNameListPage的sql啦,那QueryCondition是我自己定义的查询参数哈哈。
Controller:
/** * 多表查询 分页 test */ @Autowired private BusinessGoodsIndexBannerMapper businessGoodsIndexBannerMapper; @RequestMapping(value = "test