Resolved PageHelper.startPage (page, size), with respect to the total PageInfo attributes such as incorrect and other issues

This mainly occurs because the database is a collection of isolated logic, the number of the same total size of the display, not the total number of

        //开启分页
        PageHelper.startPage(page, limit);
        List<User> allUserList = userService.getAllUserList(name);
        //新建存储集合
        List<User> allUserListStatus = new ArrayList<>();
        //判定用户状态,status的状态,数值1为正常状态用户,数值2为禁用状态用户
        for (User user : allUserList) {
            Integer status = user.getStatus();
            if(status==1){
                if(roleId!=-1){
                    Integer roleIdUser = user.getUserRole().getRoleId();
                    if(roleId.equals(roleIdUser)){
                        allUserListStatus.add(user);
                    }
                }else{
                    allUserListStatus.add(user);
                }

            }

        }

        PageInfo<User> pageInfo = new PageInfo<>(allUserList);
        pageInfo.setList(allUserListStatus);
        return ResultUtil.ok(pageInfo);

pageInfo.setList (allUserListStatus);
This constructor is reset pojo objects pageinfo of the list property, assign only a collection of a number of size we want

Published 45 original articles · won praise 1 · views 1065

Guess you like

Origin blog.csdn.net/lqq404270201/article/details/104387876