Java Code Examples for com.github.pagehelper.PageInfo#setSize()

The following examples show how to use com.github.pagehelper.PageInfo#setSize() . 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: PageInfoHelper.java    From uexam with GNU Affero General Public License v3.0 6 votes vote down vote up
public static <T, J> PageInfo<J> copyMap(PageInfo<T> source, Function<? super T, ? extends J> mapper) {
    PageInfo<J> newPage = new PageInfo<>();
    newPage.setPageNum(source.getPageNum());
    newPage.setPageSize(source.getPageSize());
    newPage.setSize(source.getSize());
    newPage.setStartRow(source.getStartRow());
    newPage.setEndRow(source.getEndRow());
    newPage.setTotal(source.getTotal());
    newPage.setPages(source.getPages());
    newPage.setList(source.getList().stream().map(mapper).collect(Collectors.toList()));
    newPage.setPrePage(source.getPrePage());
    newPage.setNextPage(source.getNextPage());
    newPage.setIsFirstPage(source.isIsFirstPage());
    newPage.setIsLastPage(source.isIsLastPage());
    newPage.setHasPreviousPage(source.isHasPreviousPage());
    newPage.setHasNextPage(source.isHasNextPage());
    newPage.setNavigatePages(source.getNavigatePages());
    newPage.setNavigatepageNums(source.getNavigatepageNums());
    newPage.setNavigateFirstPage(source.getNavigateFirstPage());
    newPage.setNavigateLastPage(source.getNavigateLastPage());
    return newPage;
}
 
Example 2
Source File: PageUtil.java    From spring-microservice-exam with MIT License 6 votes vote down vote up
/**
 * 复制属性
 *
 * @param source source
 * @param target target
 * @author tangyi
 * @date 2019/07/03 22:26:18
 */
public static void copyProperties(PageInfo<?> source, PageInfo<?> target) {
    target.setPageNum(source.getPageNum());
    target.setPageSize(source.getPageSize());
    target.setSize(source.getSize());
    target.setStartRow(source.getStartRow());
    target.setEndRow(source.getEndRow());
    target.setPages(source.getPages());
    target.setPrePage(source.getPrePage());
    target.setNextPage(source.getNextPage());
    target.setIsFirstPage(source.isIsFirstPage());
    target.setIsLastPage(source.isIsLastPage());
    target.setHasPreviousPage(source.isHasPreviousPage());
    target.setHasNextPage(source.isHasNextPage());
    target.setNavigatePages(source.getNavigatePages());
    target.setNavigatepageNums(source.getNavigatepageNums());
    target.setNavigateFirstPage(source.getNavigateFirstPage());
    target.setNavigateLastPage(source.getNavigateLastPage());
    target.setTotal(source.getTotal());
}
 
Example 3
Source File: PageInfoHelper.java    From uexam-mysql with GNU Affero General Public License v3.0 6 votes vote down vote up
public static <T, J> PageInfo<J> copyMap(PageInfo<T> source, Function<? super T, ? extends J> mapper) {
    PageInfo<J> newPage = new PageInfo<>();
    newPage.setPageNum(source.getPageNum());
    newPage.setPageSize(source.getPageSize());
    newPage.setSize(source.getSize());
    newPage.setStartRow(source.getStartRow());
    newPage.setEndRow(source.getEndRow());
    newPage.setTotal(source.getTotal());
    newPage.setPages(source.getPages());
    newPage.setList(source.getList().stream().map(mapper).collect(Collectors.toList()));
    newPage.setPrePage(source.getPrePage());
    newPage.setNextPage(source.getNextPage());
    newPage.setIsFirstPage(source.isIsFirstPage());
    newPage.setIsLastPage(source.isIsLastPage());
    newPage.setHasPreviousPage(source.isHasPreviousPage());
    newPage.setHasNextPage(source.isHasNextPage());
    newPage.setNavigatePages(source.getNavigatePages());
    newPage.setNavigatepageNums(source.getNavigatepageNums());
    newPage.setNavigateFirstPage(source.getNavigateFirstPage());
    newPage.setNavigateLastPage(source.getNavigateLastPage());
    return newPage;
}
 
Example 4
Source File: IssueServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public PageInfo<IssueNumVO> queryIssueByOption(Long projectId, Long issueId, String issueNum, Boolean onlyActiveSprint, Boolean self, String content, PageRequest pageRequest) {
    //连表查询需要设置主表别名
    pageRequest.setSort(PageUtil.sortResetOrder(pageRequest.getSort(), "ai", new HashMap<>()));
    //pageRequest.resetOrder("ai", new HashMap<>());
    IssueNumDTO issueNumDTO = null;
    if (self) {
        issueNumDTO = issueMapper.queryIssueByIssueNumOrIssueId(projectId, issueId, issueNum);
        if (issueNumDTO != null) {
            pageRequest.setSize(pageRequest.getSize() - 1);
        }
    }
    Long activeSprintId = onlyActiveSprint ? getActiveSprintId(projectId) : null;
    PageInfo<IssueNumDTO> issueDOPage = PageHelper.startPage(pageRequest.getPage(),
            pageRequest.getSize(), PageUtil.sortToSql(pageRequest.getSort())).doSelectPageInfo(() -> issueMapper.
            queryIssueByOption(projectId, issueId, issueNum, activeSprintId, self, content));
    if (self && issueNumDTO != null) {
        issueDOPage.getList().add(0, issueNumDTO);
        issueDOPage.setSize(issueDOPage.getSize() + 1);
    }

    return PageUtil.buildPageInfoWithPageInfoList(issueDOPage, issueAssembler.issueNumDoToDto(issueDOPage.getList(), projectId));
}
 
Example 5
Source File: IssueServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public PageInfo<IssueNumVO> queryIssueByOptionForAgile(Long projectId, Long issueId, String issueNum, Boolean self, String content, PageRequest pageRequest) {
    pageRequest.setSort(PageUtil.sortResetOrder(pageRequest.getSort(), SEARCH, new HashMap<>()));
    //pageRequest.resetOrder("search", new HashMap<>());
    IssueNumDTO issueNumDTO = null;
    if (self) {
        issueNumDTO = issueMapper.queryIssueByIssueNumOrIssueId(projectId, issueId, issueNum);
        if (issueNumDTO != null) {
            pageRequest.setSize(pageRequest.getSize() - 1);
        }
    }
    PageInfo<IssueNumDTO> issueDOPage = PageHelper.startPage(pageRequest.getPage(), pageRequest.getSize(),
            PageUtil.sortToSql(pageRequest.getSort())).doSelectPageInfo(() ->
            issueMapper.queryIssueByOptionForAgile(projectId, issueId, issueNum, self, content));
    if (self && issueNumDTO != null) {
        issueDOPage.getList().add(0, issueNumDTO);
        issueDOPage.setSize(issueDOPage.getSize() + 1);
    }
    return PageUtil.buildPageInfoWithPageInfoList(issueDOPage, issueAssembler.issueNumDoToDto(issueDOPage.getList(), projectId));
}
 
Example 6
Source File: CommentService.java    From Jantent with MIT License 6 votes vote down vote up
/**
 * copy原有的分页信息,除数据
 *
 * @param ordinal
 * @param <T>
 * @return
 */
private <T> PageInfo<T> copyPageInfo(PageInfo ordinal) {
    PageInfo<T> returnBo = new PageInfo<T>();
    returnBo.setPageSize(ordinal.getPageSize());
    returnBo.setPageNum(ordinal.getPageNum());
    returnBo.setEndRow(ordinal.getEndRow());
    returnBo.setTotal(ordinal.getTotal());
    returnBo.setHasNextPage(ordinal.isHasNextPage());
    returnBo.setHasPreviousPage(ordinal.isHasPreviousPage());
    returnBo.setIsFirstPage(ordinal.isIsFirstPage());
    returnBo.setIsLastPage(ordinal.isIsLastPage());
    returnBo.setNavigateFirstPage(ordinal.getNavigateFirstPage());
    returnBo.setNavigateLastPage(ordinal.getNavigateLastPage());
    returnBo.setNavigatepageNums(ordinal.getNavigatepageNums());
    returnBo.setSize(ordinal.getSize());
    returnBo.setPrePage(ordinal.getPrePage());
    returnBo.setNextPage(ordinal.getNextPage());
    return returnBo;
}
 
Example 7
Source File: PageInfoHelper.java    From dynamic-data-source-demo with Apache License 2.0 6 votes vote down vote up
public static <T, R> PageInfo<R> mapPage(PageInfo<T> page, Function<List<T>, List<R>> function) {
    PageInfo<R> resultPage = new PageInfo<>();
    resultPage.setList(function.apply(page.getList()));
    resultPage.setSize(page.getSize());
    resultPage.setPageNum(page.getPageNum());
    resultPage.setPageSize(page.getPageSize());
    resultPage.setStartRow(page.getStartRow());
    resultPage.setEndRow(page.getEndRow());
    resultPage.setTotal(page.getTotal());
    resultPage.setHasPreviousPage(page.isHasPreviousPage());
    resultPage.setHasNextPage(page.isHasNextPage());
    resultPage.setIsFirstPage(page.isIsFirstPage());
    resultPage.setIsLastPage(page.isIsLastPage());
    resultPage.setPages(page.getPages());
    resultPage.setPrePage(page.getPrePage());
    resultPage.setNextPage(page.getNextPage());
    resultPage.setNavigatePages(page.getNavigatePages());
    resultPage.setNavigatepageNums(page.getNavigatepageNums());
    resultPage.setNavigateFirstPage(page.getNavigateFirstPage());
    resultPage.setNavigateLastPage(page.getNavigateLastPage());
    return resultPage;
}
 
Example 8
Source File: BlogController.java    From newblog with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = "/search")
public ModelAndView search(
        @RequestParam(value = "keyword", required = false) String keyword,
        @RequestParam(value = "pagenum", required = false) Integer pagenum) {
    ModelAndView modelAndView = new ModelAndView();
    try {
        if (pagenum == null) {
            pagenum = 1;
        }
        List<Blog> lists = blogService.getLuceneBlog(pagenum, keyword, 10);
        PageHelper.startPage(pagenum, 10);
        PageInfo<Blog> blogs = new PageInfo<>(lists);
        blogs.setPageSize(10);
        blogs.setSize(10);
        blogs.setPages(lists.size() / 10 == 0 ? lists.size() / 10 : lists.size() / 10 + 1);
        Integer startpage, endpage;
        if (blogs.getPages() < 6) {
            startpage = 1;
            endpage = blogs.getPages();
        } else {
            if (pagenum > 3) {
                startpage = blogs.getPageNum() - 3;
                endpage = blogs.getPageNum() + 3;
            } else {
                startpage = 1;
                endpage = blogs.getPageNum() + 4;
            }
        }
        modelAndView.addObject("startpage", startpage);
        modelAndView.addObject("endpage", endpage);
        modelAndView.addObject("blogs", blogs.getList());
        modelAndView.addObject("totalpages", blogs.getPages());
        modelAndView.addObject("pageNum", pagenum);
        modelAndView.addObject("keyword", keyword);
        modelAndView.setViewName("searchresult");
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("search" + e);
    }
    return modelAndView;
}