Mybatis-plus 分页 功能实现

功能比较简单!!!就下面几步就行


1.配置MyBatisConfiguration类

@Configuration
public class MyBatisConfiguration {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
               //构建mp拦截器对象
        MybatisPlusInterceptor plugs = new MybatisPlusInterceptor();
        //添加一个拦截器
        plugs.addInnerInterceptor(new PaginationInnerInterceptor());
        return plugs;
        }
}

2.配置controller层 service层 mapper层 

 #controller层

@RestController
@RequestMapping("/tcinfo")
public class TcinfosCtrl {
    @Resource
    private TcinfoStoreService tcinfoStoreService;
/**
 *4 塔机信息分页查询
 * @param page
 * @return
 */
@GetMapping(value ="/findTowerCrane")
public IPage<Tcinfos> find(@RequestParam(value ="page",required= false,defaultValue="1") Integer page){
    IPage<Tcinfos> result = tcinfoStoreService.findTc(page);
    return result;
}

}

# service层 接口

public interface TcinfoStoreService { 
   /**
     * 按照前端要去获取对应页上的塔吊信息数据
     * @param page 页码编号
     * @return
     */
    IPage<Tcinfos> findTc(Integer page);

}

# service层 实现类

@Service
public class TcinfoStoreServiceImpl implements TcinfoStoreService {
    @Resource
    private TCinfosMapper tCinfosMapper;
@Override
public IPage<Tcinfos> findTc(Integer page) {
    IPage<Tcinfos> ip= new Page<>(1,page);
    IPage<Tcinfos> result = tCinfosMapper.selectPage(ip, null);
    return result;
}

}

#mapper层

@Mapper
//使用mybatis-plus实现crud
public interface TCinfosMapper extends BaseMapper<Tcinfos> {
 
}

3.调用接口测试即可 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kjshuan

点个赞就好啦!!!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值