网站空间流量是什么,公众号代运营费用,平面设计广告,开发公司取名“大家好#xff0c;我是雄雄#xff0c;欢迎关注微信公众号#xff1a;雄雄的小课堂”前言现在是2022年4月16日21:44:05#xff01;今天分享一个代码段#xff0c;个人觉得还是比较有参考性的。后端使用框架#xff1a;bladex前端使用技术#xff1a;AVue功能:自定义分… “大家好我是雄雄欢迎关注微信公众号雄雄的小课堂”前言现在是2022年4月16日21:44:05今天分享一个代码段个人觉得还是比较有参考性的。后端使用框架bladex前端使用技术AVue功能:自定义分页实现思路由于业务上涉及到了多个表进行关联查询所有直接使用框架自带的分页无法满足前端分页所以就想着自己封装一个吧现在记录记录等后面自己用到的时候回来看看也希望能帮助其他人。实现代码整体思路是这样的查询当前用户下的所有应用查询每个应用下的所有设备将查询出来的设备信息封装在分页工具类中给前端传回去分页对象比较麻烦的地方就在于计算当前页以及将当前页的信息放在集合中传出去下面是实现代码/*** 分页 设备流程表*/GetMapping(/list)ApiOperationSupport(order 2)ApiOperation(value 分页, notes 传入equipment)public RIPageEquipment list(Equipment equipment, Query query) {//获取当前用户应用Application application new Application();application.setUserId(AuthUtil.getUserId());ListApplication appList applicationService.list(Condition.getQueryWrapper(application).select(app_id));ListEquipment equipmentList new ArrayList();for(Application app : appList){QueryWrapperEquipment equipmentQueryWrapper new QueryWrapper();equipmentQueryWrapper.eq(application_id,app.getAppId());ListEquipment eList equipmentService.list(equipmentQueryWrapper);for(Equipment e : eList){equipmentList.add(e);}}//新的集合ListEquipment equipmentListNew new ArrayList();//当前页//如果是第一页0-10//第二页11-20Integer current (query.getCurrent()-1)*query.getSize();//页大小Integer pageSize query.getSize();if(equipmentList.size()pageSize){pageSize equipmentList.size();}else if(query.getCurrent()1) {if (equipmentList.size() % query.getSize() ! 0) {pageSize (pageSize * (query.getCurrent() - 1)) (equipmentList.size() % query.getSize());}else{pageSize pageSize * query.getCurrent();}}for(int i current;ipageSize;i){equipmentListNew.add(equipmentList.get(i));}IPageEquipment pages new Page();pages.setRecords(equipmentListNew);pages.setSize(query.getSize());pages.setCurrent(query.getCurrent());pages.setTotal(equipmentList.size());return R.data(pages);}