SpringBoot整合MybatisPlus基本的增删改查,保姆级教程( 四 )

10|3实现分页接口package com.didiplus.modules.sys.service.impl;import com.baomidou.mybatisplus.core.metadata.IPage;import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;import com.didiplus.common.web.domain.PageDomain;import com.didiplus.modules.sys.domain.SysDictType;import com.didiplus.modules.sys.mapper.SysDictTypeMapper;import com.didiplus.modules.sys.service.SysDictTypeService;import org.springframework.stereotype.Service;import javax.annotation.Resource;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/4/29 * Desc: */@Servicepublic class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {@ResourceSysDictTypeMapper sysDictTypeMapper;@Overridepublic IPage<SysDictType> page(PageDomain pageDomain) {IPage<SysDictType> page = new Page<>(pageDomain.getPage(),pageDomain.getLimit());return sysDictTypeMapper.selectPage(page,null);}}10|4控制层调用@RestController@Api(tags = "数据字典")@RequestMapping("/api/sys/dictType")public class SysDictTypeController {@AutowiredSysDictTypeService sysDictTypeService;@ApiOperation("字典分页查询")@GetMappingpublic IPage list(@RequestBody PageDomain pageDomain){return sysDictTypeService.page(pageDomain);}}

PageDomain定义了分页接收的两个参数
PageDomain类
package com.didiplus.common.web.domain;import lombok.Data;/** * Author: didiplus * Email: 972479352@qq.com * CreateTime: 2022/5/4 * Desc: 分 页 参 数 封 装 */@Datapublic class PageDomain {/*** 当前页*/privateInteger page;/*** 每页数量*/privateInteger limit;}10|5体验效果
SpringBoot整合MybatisPlus基本的增删改查,保姆级教程

文章插图
 




推荐阅读