若依分页功能

前端页面

        打开登入日志页面源码文件,如下图所示,其中<pagination> 组件为分页组件

     

其函数调用链getList -> list -> request[axios]

进入开发者模式,查看网络请求。

找到对应网后端源码

后端代码

startPage()

分页原理

selectLogininforList中并未使用Pagesize 和PageNum , 它应该返回所有数据,而不是分页数据。那他是如何做到筛选数据?

SysLogininforMapper.xml文件

我们可以查看日志输出。

19:31:19.251 [http-nio-8080-exec-23] DEBUG c.r.s.m.S.selectMenuTreeAll - [debug,137] - ==>  Preparing: select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0 order by m.parent_id, m.order_num
19:31:19.253 [http-nio-8080-exec-23] DEBUG c.r.s.m.S.selectMenuTreeAll - [debug,137] - ==> Parameters: 
19:31:19.258 [http-nio-8080-exec-23] DEBUG c.r.s.m.S.selectMenuTreeAll - [debug,137] - <==      Total: 33
19:31:20.512 [http-nio-8080-exec-25] DEBUG c.r.s.m.S.selectLogininforList_COUNT - [debug,137] - ==>  Preparing: SELECT count(0) FROM sys_logininfor
19:31:20.513 [http-nio-8080-exec-25] DEBUG c.r.s.m.S.selectLogininforList_COUNT - [debug,137] - ==> Parameters: 
19:31:20.514 [http-nio-8080-exec-25] DEBUG c.r.s.m.S.selectLogininforList_COUNT - [debug,137] - <==      Total: 1
19:31:20.514 [http-nio-8080-exec-25] DEBUG c.r.s.m.S.selectLogininforList - [debug,137] - ==>  Preparing: select info_id, user_name, ipaddr, login_location, browser, os, status, msg, login_time from sys_logininfor order by info_id desc LIMIT ?
19:31:20.515 [http-nio-8080-exec-25] DEBUG c.r.s.m.S.selectLogininforList - [debug,137] - ==> Parameters: 10(Integer)
19:31:20.516 [http-nio-8080-exec-25] DEBUG c.r.s.m.S.selectLogininforList - [debug,137] - <==      Total: 10

发现它执行了我们未编写的SQL语句

这里可以得到total

这里可以得到分页数据

其实 SQL 被MyBatis 拦截改变了 ,由于涉及MyBatis 源码,笔者能力不足,遍不在向下深究。

第二页数据(前端参数为pageNum=2&pageSize=10 请求对应的后端Log

Paramters :代表从第10条数据开始

Interger : 取10个条数据

  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值