分页显示结束,从第一页开始分页

@ApiOperation("感兴趣的人 翻页")
@RequestMapping(value = "/getUserList", method = RequestMethod.GET)
public ResultPageVo> getUserList(PageParam pageParam) {

    UserLoginInfo currUserLoginInfo = getCurrUserLoginInfo();
    PageInfo pageInfo = homeService.getUserList(pageParam, currUserLoginInfo);

    // 分页显示完了,又从第一页开始循环显示
    if (CollUtil.isEmpty(pageInfo.getList())){
        int pages = pageInfo.getPages();
        //如果传过来的页码超过总数 从第一页显示 取余加1
        if (pageParam.getPageNum() > pages){
            int pageNum = (pageParam.getPageNum() % pages) + 1;
            if (pageNum <= 0) {
                pageNum = 1;
            }

            pageParam.setPageNum(pageNum);
            List userVoList = homeService.getUserList(pageParam, currUserLoginInfo).getList();
            return ResultPageVo.success(userVoList);
        }
    }

 

你可能感兴趣的:(Java)