zoukankan      html  css  js  c++  java
  • 分页插件

    分页插件
    <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
    <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.10</version>
    </dependency>

    mapper接口
    /**
    * 查询菜单列表
    * @param param
    * @return
    */
    List<SysMenu> getAllMenuList(SysMenuParam param);

    mapper对应的xml文件
    <select id="getAllMenuList" parameterType="com.example.model.po.request.sys.SysMenuParam"
    resultType="com.example.model.po.base.mbg.SysMenu">
    SELECT
    MenuId,MenuCode,MenuIcon,MenuName,ParentCode,MenuFullCode,MenuFullName,Sort,EnableFlag,ViewId,DeleteFlag,CreateDate,CreateUser,UpdateDate,UpdateUser,Source
    FROM SYS_Menu WHERE 1=1 and DeleteFlag=0
    </select>

    测试类
    @Test
    public void getListByPage(){
    SysMenuParam sysMenuParam=new SysMenuParam();
    sysMenuParam.setPageNum(2);
    sysMenuParam.setPageSize(10);
    //第一个参数:页数,第二个参数:每页的行数。应该是页面传过来的参数,这里面我的写固定值测试。
    PageHelper.startPage(sysMenuParam.getPageNum(),sysMenuParam.getPageSize());
    //PageHelper.startPage(1,10);
    //查询集合
    List<SysMenu> menuList = sysMenuMapperCustom.getAllMenuList(sysMenuParam);
    System.out.println("分页集合数量:"+menuList.size());
    menuList.forEach(info ->{
    System.out.println(info);
    });
    }


    service 层 方法
    /**
    * 根据条件获取所有角色列表
    * 分页
    * @param param
    * @return
    */
    public PageInfo getAllRoleApply(ApplyViewRoleParam param){
    PageHelper.startPage(param.getPageNum(), param.getPageSize());
    List<ApplyViewRoleVO> list = applyViewRoleMapperCustom.getAllRoleApply(param);
    return new PageInfo(list);
    }

    controller 层
    @ApiOperation(value = "分页获取申请列表",notes = "分页获取申请列表<p>必填参数</p> pageNum、pageSize")
    @RequestMapping(value = "/getViewRoleListByKeyWord",method = RequestMethod.POST)
    public JsonResult getViewRoleListByKeyWord(@RequestBody ApplyViewRoleParam param){
    if(!checkPage(param)){
    return JsonResult.error(ErrorCodeEnum.PAGE_PARAM_ERROR.getCode(),ErrorCodeEnum.PAGE_PARAM_ERROR.getMsg());
    }
    if (StringUtils.isBlank(param.getApplyViewId())){
    return JsonResult.error(ErrorCodeEnum.PARAM_IS_NULL.getCode(),ErrorCodeEnum.PARAM_IS_NULL.getMsg());
    }
    return JsonResult.getResult(applyViewRoleService.getAllRoleApply(param));
    }
  • 相关阅读:
    【BZOJ4275】[ONTAK2015]Badania naukowe DP
    【BZOJ4295】[PA2015]Hazard 乱搞
    【BZOJ4297】[PA2015]Rozstaw szyn 树形DP
    Windows服务安装异常:System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志。不可 访问的日志: Security
    直关的sql 联级更新语句
    c#经典俄罗斯方块 vs2012开发
    转 SSIS处理导入数据时, 存在的更新, 不存在的插入
    WM (Constants)
    数据仓库的模型设计
    BI (商业智能)
  • 原文地址:https://www.cnblogs.com/ming-blogs/p/10784425.html
Copyright © 2011-2022 走看看