Java Code Examples for com.github.pagehelper.Page#getResult()

The following examples show how to use com.github.pagehelper.Page#getResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewMenuServiceImpl.java    From nimrod with MIT License 6 votes vote down vote up
@Override
public Pagination<ViewMenuEntity> pageAllByViewMenuCategoryId(Integer page, Integer rows, Long viewMenuCategoryId, Long roleId) {
    Pagination<ViewMenuEntity> pagination = new Pagination<>();
    PageHelper.startPage(page, rows);
    Page<ViewMenuEntity> viewMenuEntityPage = viewMenuMapper.pageAllByViewMenuCategoryId(viewMenuCategoryId);
    List<ViewMenuEntity> viewMenuEntityListResult = new ArrayList<>();
    List<ViewMenuEntity> viewMenuEntityList = viewMenuEntityPage.getResult();
    Integer isOrNotIs = Integer.valueOf((String) dictionaryService.get("IS_OR_NOT", "IS"));
    Integer isOrNotNot = Integer.valueOf((String) dictionaryService.get("IS_OR_NOT", "NOT"));
    if (!viewMenuEntityList.isEmpty()) {
        for (ViewMenuEntity viewMenuEntity : viewMenuEntityList) {
            if (roleId != null) {
                if (roleViewMenuMapper.getOneByRoleIdAndViewMenuId(roleId, viewMenuEntity.getId()) != null) {
                    viewMenuEntity.setIsGranted(isOrNotIs);
                } else {
                    viewMenuEntity.setIsGranted(isOrNotNot);
                }
            }
            viewMenuEntityListResult.add(viewMenuEntity);
        }
    }
    pagination.setRows(viewMenuEntityListResult);
    pagination.setTotal(viewMenuEntityPage.getTotal());
    return pagination;
}
 
Example 2
Source File: UserServiceImpl.java    From nimrod with MIT License 6 votes vote down vote up
@Override
public Pagination<UserEntity> pageAll(Integer page, Integer rows, String sorterField, String sorterOrder, UserEntity userEntity, String gmtCreatedStart, String gmtCreatedEnd, String gmtDeletedStart, String gmtDeletedEnd) {
    if (sorterField != null && !"".equals(sorterField) && sorterOrder != null && !"".equals(sorterOrder)) {
        sorterField = StringUtil.camelToUnderline(sorterField);
        String orderBy = sorterField + " " + sorterOrder;
        PageHelper.startPage(page, rows, orderBy);
    } else {
        PageHelper.startPage(page, rows);
    }
    Page<UserEntity> userEntityPage = userMapper.pageAll(userEntity, gmtCreatedStart, gmtCreatedEnd, gmtDeletedStart, gmtDeletedEnd);
    Pagination<UserEntity> pagination = new Pagination<>();
    List<UserEntity> userEntityList = new ArrayList<>();
    List<UserEntity> tempUserEntityList = userEntityPage.getResult();
    if (tempUserEntityList != null) {
        for (UserEntity userEntity2 : tempUserEntityList) {
            userEntity2.setPassword(null);
            userEntity2.setDepartment(departmentService.listAllByDepartmentId(userEntity2.getDepartmentId()));
            userEntityList.add(userEntity2);
        }
    }
    pagination.setRows(userEntityList);
    pagination.setTotal(userEntityPage.getTotal());
    return pagination;
}
 
Example 3
Source File: UserServiceImpl.java    From nimrod with MIT License 6 votes vote down vote up
@Override
public Pagination<UserEntity> pageAllByDepartmentId(Long departmentId, Integer page, Integer rows) {
    Pagination<UserEntity> pagination = new Pagination<>();
    PageHelper.startPage(page, rows);
    Page<UserEntity> tempUserEntityPage = userMapper.pageAllByDepartmentId(departmentId);
    List<UserEntity> userEntityList = new ArrayList<>();
    if (tempUserEntityPage != null) {
        for (UserEntity userEntity : tempUserEntityPage.getResult()) {
            userEntity.setPassword(null);
            userEntityList.add(userEntity);
        }
        pagination.setRows(userEntityList);
        pagination.setTotal(tempUserEntityPage.getTotal());
    }
    return pagination;
}
 
Example 4
Source File: ViewPageComponentServiceImpl.java    From nimrod with MIT License 6 votes vote down vote up
@Override
public Pagination<ViewPageComponentEntity> pageAllByViewPageId(Integer page, Integer rows, Long viewPageId, Long roleId) {
    Pagination<ViewPageComponentEntity> pagination = new Pagination<>();
    PageHelper.startPage(page, rows);
    Page<ViewPageComponentEntity> viewPageComponentEntityPage = viewPageComponentMapper.pageAllByViewPageId(viewPageId);
    List<ViewPageComponentEntity> viewPageComponentEntityList = viewPageComponentEntityPage.getResult();
    List<ViewPageComponentEntity> viewPageComponentEntityListResult = new ArrayList<>();
    Integer isOrNotIs = Integer.valueOf((String) dictionaryService.get("IS_OR_NOT", "IS"));
    Integer isOrNotNot = Integer.valueOf((String) dictionaryService.get("IS_OR_NOT", "NOT"));
    if (!viewPageComponentEntityList.isEmpty()) {
        for (ViewPageComponentEntity viewPageComponentEntity : viewPageComponentEntityList) {

            if (roleAuthorityMapper.getOneByRoleIdAndAuthority(roleId, viewPageComponentEntity.getAuthority()) != null) {
                viewPageComponentEntity.setIsGranted(isOrNotIs);
            } else {
                viewPageComponentEntity.setIsGranted(isOrNotNot);
            }
            viewPageComponentEntityListResult.add(viewPageComponentEntity);
        }
    }
    pagination.setRows(viewPageComponentEntityListResult);
    pagination.setTotal(viewPageComponentEntityPage.getTotal());
    return pagination;
}
 
Example 5
Source File: OperationLogServiceImpl.java    From nimrod with MIT License 6 votes vote down vote up
@Override
public Pagination<OperationLogEntity> pageAll(Integer page, Integer rows) {
    Pagination<OperationLogEntity> pagination = new Pagination<>();
    PageHelper.startPage(page, rows);
    Page<OperationLogEntity> operationLogEntityPage = operationLogMapper.pageAll();
    List<OperationLogEntity> operationLogEntityList = operationLogEntityPage.getResult();
    List<OperationLogEntity> operationLogEntityListResult = new ArrayList<>(1);
    for (OperationLogEntity operationLogEntity : operationLogEntityPage) {
        UserEntity userEntity = userService.getOne(operationLogEntity.getUserId());
        if (userEntity != null) {
            operationLogEntity.setUsername(userEntity.getUsername());
        }
        operationLogEntityListResult.add(operationLogEntity);
    }
    pagination.setRows(operationLogEntityListResult);
    pagination.setTotal(operationLogEntityPage.getTotal());
    return pagination;
}
 
Example 6
Source File: FileServiceImpl.java    From nimrod with MIT License 6 votes vote down vote up
@Override
public Pagination<FileEntity> pageAll(Integer page, Integer rows) {
    Pagination<FileEntity> pagination = new Pagination<>();
    PageHelper.startPage(page, rows);
    Page<FileEntity> fileEntityPage = fileMapper.pageAll();
    List<FileEntity> fileEntityList = fileEntityPage.getResult();
    List<FileEntity> fileEntityListResult = new ArrayList<>();
    for (FileEntity fileEntity : fileEntityList) {
        if (fileEntity.getUserId() != null) {
            UserEntity userEntity = userService.getOneByIdNoPassword(fileEntity.getUserId());
            if (userEntity != null) {
                fileEntity.setUsername(userEntity.getUsername());
            }
        }
        fileEntityListResult.add(fileEntity);
    }
    pagination.setRows(fileEntityListResult);
    pagination.setTotal(fileEntityPage.getTotal());
    return pagination;
}
 
Example 7
Source File: FileServiceImpl.java    From nimrod with MIT License 6 votes vote down vote up
@Override
public Pagination<FileEntity> pageAllImage(Integer page, Integer rows, Long userId) {
    Pagination<FileEntity> pagination = new Pagination<>();
    PageHelper.startPage(page, rows);
    Page<FileEntity> fileEntityPage;
    if (userId != null) {
        fileEntityPage = fileMapper.pageAllImageByUserId(userId);
    } else {
        fileEntityPage = fileMapper.pageAllImage();
    }
    List<FileEntity> fileEntityList = fileEntityPage.getResult();
    List<FileEntity> fileEntityListResult = new ArrayList<>();
    for (FileEntity fileEntity : fileEntityList) {
        if (fileEntity.getUserId() != null) {
            UserEntity userEntity = userService.getOneByIdNoPassword(fileEntity.getUserId());
            if (userEntity != null) {
                fileEntity.setUsername(userEntity.getUsername());
            }
        }
        fileEntityListResult.add(fileEntity);
    }
    pagination.setRows(fileEntityListResult);
    pagination.setTotal(fileEntityPage.getTotal());
    return pagination;
}
 
Example 8
Source File: RolesRepositoryImplTest.java    From pulsar-manager with Apache License 2.0 6 votes vote down vote up
@Test
public void findMultiIdTest() {
    RoleInfoEntity roleInfoEntity = new RoleInfoEntity();
    initRole(roleInfoEntity);

    long roleId = rolesRepository.save(roleInfoEntity);
    List<Long> roleIdList = new ArrayList<>();
    roleIdList.add(roleId);
    roleIdList.add(roleInfoEntity.getRoleId());
    Page<RoleInfoEntity> roleInfoEntities = rolesRepository.findRolesMultiId(1, 2, roleIdList);
    roleInfoEntities.count(true);
    for (RoleInfoEntity infoEntity : roleInfoEntities.getResult()) {
        validateRole(infoEntity);
        rolesRepository.delete(infoEntity.getRoleName(), infoEntity.getRoleSource());
    }
}
 
Example 9
Source File: CustomerServiceImpl.java    From ssm-Online_Examination with Apache License 2.0 5 votes vote down vote up
/**
 * 分页查询-条件查询方法
 *
 * @param customer 查询条件
 * @param pageCode 当前页
 * @param pageSize 每页的记录数
 * @return
 */
public PageBean findByPage(Customer customer, int pageCode, int pageSize) {
    //使用Mybatis分页插件
    PageHelper.startPage(pageCode, pageSize);

    //调用分页查询方法,其实就是查询所有数据,mybatis自动帮我们进行分页计算
    Page<Customer> page = customerMapper.findByPage(customer);

    return new PageBean(pageCode, (int)Math.ceil((double)(page.getTotal() / (double)pageSize)), (int)page.getTotal(), pageSize, page.getResult());
}
 
Example 10
Source File: ViewPageServiceImpl.java    From nimrod with MIT License 5 votes vote down vote up
@Override
    public Pagination<ViewPageEntity> pageAllByViewPageCategoryId(Integer page, Integer rows, Long viewPageCategoryId, Long roleId) {
        Pagination<ViewPageEntity> pagination = new Pagination<>();
        //        if(sorterField != null && !"".equals(sorterField) && sorterOrder != null && !"".equals(sorterOrder)) {
//            sorterField = StringUtil.camelToUnderline(sorterField);
//            String orderBy = sorterField + " " + sorterOrder;
//            PageHelper.startPage(page, rows, orderBy);
//        } else {
        PageHelper.startPage(page, rows);
//        }
        Page<ViewPageEntity> viewPageEntityPage = viewPageMapper.pageAllByViewPageCategoryId(viewPageCategoryId);
        List<ViewPageEntity> viewPageEntityList = viewPageEntityPage.getResult();
        List<ViewPageEntity> viewPageEntityListResult = new ArrayList<>();
        Integer isOrNotIs = Integer.valueOf((String) dictionaryService.get("IS_OR_NOT", "IS"));
        Integer isOrNotNot = Integer.valueOf((String) dictionaryService.get("IS_OR_NOT", "NOT"));
        if (!viewPageEntityList.isEmpty()) {
            for (ViewPageEntity viewPageEntity : viewPageEntityList) {
                if (roleAuthorityMapper.getOneByRoleIdAndAuthority(roleId, viewPageEntity.getAuthority()) != null) {
                    viewPageEntity.setIsGranted(isOrNotIs);
                } else {
                    viewPageEntity.setIsGranted(isOrNotNot);
                }
                viewPageEntityListResult.add(viewPageEntity);
            }
        }
        pagination.setRows(viewPageEntityListResult);
        pagination.setTotal(viewPageEntityPage.getTotal());
        return pagination;
    }
 
Example 11
Source File: NamespacesServiceImpl.java    From pulsar-manager with Apache License 2.0 5 votes vote down vote up
public Map<String, Object> getNamespaceStats(
        String tenant,
        String namespace,
        String env) {
    Map<String, Object> namespaceStatsMap = Maps.newHashMap();
    Optional<TopicStatsEntity> topicStatsEntity = topicsStatsRepository.findMaxTime();
    if (topicStatsEntity.isPresent()) {
        double msgRateIn = 0;
        double msgThroughputIn = 0;
        double msgRateOut = 0;
        double msgThroughputOut = 0;
        TopicStatsEntity topicStats = topicStatsEntity.get();
        Page<TopicStatsEntity> topicCountPage = topicsStatsRepository.findByNamespace(
                1, 1, env, tenant, namespace, topicStats.getTime_stamp());
        topicCountPage.count(true);
        Page<TopicStatsEntity> topicStatsEntities = topicsStatsRepository.findByNamespace(
                1, (int) topicCountPage.getTotal(), env, tenant, namespace, topicStats.getTime_stamp());
        for (TopicStatsEntity statsEntity : topicStatsEntities.getResult()) {
            msgRateIn += statsEntity.getMsgRateIn();
            msgRateOut += statsEntity.getMsgRateOut();
            msgThroughputIn += statsEntity.getMsgThroughputIn();
            msgThroughputOut += statsEntity.getMsgThroughputOut();
        }
        namespaceStatsMap.put("inMsg", msgRateIn);
        namespaceStatsMap.put("outMsg", msgRateOut);
        namespaceStatsMap.put("msgThroughputIn", msgThroughputIn);
        namespaceStatsMap.put("msgThroughputOut", msgThroughputOut);
    }
    return namespaceStatsMap;
}
 
Example 12
Source File: PageResultWrapper.java    From magic-starter with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * 构造分页对象
 *
 * @param pageData 当前页数据
 * @param <T>泛型
 * @return 分页对象
 */
public static <T> PageResult<T> wrapper(Page<T> pageData) {
	return new PageResult<>(pageData.getPageNum(), pageData.getPageSize(), pageData.getPages(), pageData.getTotal(), pageData.getResult());
}