Java Code Examples for com.github.pagehelper.PageInfo#setPageSize()
The following examples show how to use
com.github.pagehelper.PageInfo#setPageSize() .
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 |
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: SubjectChoicesService.java From spring-microservice-exam with MIT License | 6 votes |
/** * 查询分页列表 * * @param pageInfo pageInfo * @param subjectDto subjectDto * @return PageInfo * @author tangyi * @date 2019/06/16 18:16 */ @Override public PageInfo<SubjectDto> findSubjectPage(PageInfo pageInfo, SubjectDto subjectDto) { SubjectChoices subjectChoices = new SubjectChoices(); BeanUtils.copyProperties(subjectDto, subjectChoices); // 选择题类型:单选或多选 if (subjectDto.getType() != null) subjectChoices.setChoicesType(subjectDto.getType()); PageInfo<SubjectChoices> subjectChoicesPageInfo = this.findPage(pageInfo, subjectChoices); List<SubjectDto> subjectDtos = SubjectUtil.subjectChoicesToDto(subjectChoicesPageInfo.getList(), true); PageInfo<SubjectDto> subjectDtoPageInfo = new PageInfo<>(); subjectDtoPageInfo.setList(subjectDtos); subjectDtoPageInfo.setTotal(subjectChoicesPageInfo.getTotal()); subjectDtoPageInfo.setPageSize(subjectChoicesPageInfo.getPageSize()); subjectDtoPageInfo.setPageNum(subjectChoicesPageInfo.getPageNum()); return subjectDtoPageInfo; }
Example 3
Source File: PageUtil.java From spring-microservice-exam with MIT License | 6 votes |
/** * 复制属性 * * @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 4
Source File: PageInfoHelper.java From uexam-mysql with GNU Affero General Public License v3.0 | 6 votes |
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 5
Source File: CommentService.java From Jantent with MIT License | 6 votes |
/** * 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 6
Source File: PageInfoHelper.java From dynamic-data-source-demo with Apache License 2.0 | 6 votes |
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 7
Source File: KnowledgeController.java From spring-microservice-exam with MIT License | 4 votes |
/** * 获取分页数据 * * @param pageNum pageNum * @param pageSize pageSize * @param sort sort * @param order order * @param knowledge knowledge * @return PageInfo * @author tangyi * @date 2019/1/1 15:15 */ @GetMapping("knowledgeList") @ApiOperation(value = "获取知识列表") @ApiImplicitParams({ @ApiImplicitParam(name = CommonConstant.PAGE_NUM, value = "分页页码", defaultValue = CommonConstant.PAGE_NUM_DEFAULT, dataType = "String"), @ApiImplicitParam(name = CommonConstant.PAGE_SIZE, value = "分页大小", defaultValue = CommonConstant.PAGE_SIZE_DEFAULT, dataType = "String"), @ApiImplicitParam(name = CommonConstant.SORT, value = "排序字段", defaultValue = CommonConstant.PAGE_SORT_DEFAULT, dataType = "String"), @ApiImplicitParam(name = CommonConstant.ORDER, value = "排序方向", defaultValue = CommonConstant.PAGE_ORDER_DEFAULT, dataType = "String"), @ApiImplicitParam(name = "knowledge", value = "知识信息", dataType = "Knowledge") }) public PageInfo<KnowledgeDto> knowledgeList(@RequestParam(value = CommonConstant.PAGE_NUM, required = false, defaultValue = CommonConstant.PAGE_NUM_DEFAULT) String pageNum, @RequestParam(value = CommonConstant.PAGE_SIZE, required = false, defaultValue = CommonConstant.PAGE_SIZE_DEFAULT) String pageSize, @RequestParam(value = CommonConstant.SORT, required = false, defaultValue = CommonConstant.PAGE_SORT_DEFAULT) String sort, @RequestParam(value = CommonConstant.ORDER, required = false, defaultValue = CommonConstant.PAGE_ORDER_DEFAULT) String order, Knowledge knowledge) { knowledge.setTenantCode(SysUtil.getTenantCode()); // 查询知识 PageInfo<Knowledge> knowledgePageInfo = knowledgeService.findPage(PageUtil.pageInfo(pageNum, pageSize, sort, order), knowledge); PageInfo<KnowledgeDto> knowledgeDtoPageInfo = new PageInfo<>(); List<KnowledgeDto> knowledgeDtoList = new ArrayList<>(); // 查询附件 Set<Long> attachmentIdSet = new HashSet<>(); knowledgePageInfo.getList().forEach(tempKnowledge -> attachmentIdSet.add(tempKnowledge.getAttachmentId())); // 根据附件ID查询附件 ResponseBean<List<AttachmentVo>> returnT = userServiceClient.findAttachmentById(attachmentIdSet.toArray(new Long[0])); knowledgePageInfo.getList().stream() // 转成Dto .map(tempKnowledge -> { KnowledgeDto knowledgeDto = new KnowledgeDto(); BeanUtils.copyProperties(tempKnowledge, knowledgeDto); return knowledgeDto; }) // 遍历 .forEach(tempKnowledgeDto -> { if (returnT != null && CollectionUtils.isNotEmpty(returnT.getData())) { AttachmentVo tempKnowledgeDtoAttachmentVo = returnT.getData().stream() // 根据ID过滤 .filter(tempAttachmentVo -> tempAttachmentVo.getId().equals(tempKnowledgeDto.getAttachmentId())) // 匹配第一个 .findFirst().orElse(null); // 设置附件名称、附件大小 if (tempKnowledgeDtoAttachmentVo != null) { tempKnowledgeDto.setAttachName(tempKnowledgeDtoAttachmentVo.getAttachName()); tempKnowledgeDto.setAttachSize(tempKnowledgeDtoAttachmentVo.getAttachSize()); } } knowledgeDtoList.add(tempKnowledgeDto); }); knowledgeDtoPageInfo.setList(knowledgeDtoList); knowledgeDtoPageInfo.setTotal(knowledgePageInfo.getTotal()); knowledgeDtoPageInfo.setPageNum(knowledgePageInfo.getPageNum()); knowledgeDtoPageInfo.setPageSize(knowledgePageInfo.getPageSize()); return knowledgeDtoPageInfo; }
Example 8
Source File: AnswerService.java From spring-microservice-exam with MIT License | 4 votes |
/** * 获取错题列表 * * @param pageNum pageNum * @param pageSize pageSize * @param sort sort * @param order order * @param recordId recordId * @param answer answer * @return List * @author tangyi * @date 2020/02/19 22:50 */ public PageInfo<AnswerDto> answerListInfo(String pageNum, String pageSize, String sort, String order, Long recordId, Answer answer) { List<AnswerDto> answerDtos = new ArrayList<>(); answer.setExamRecordId(recordId); PageInfo<Answer> answerPageInfo = this.findPage(PageUtil.pageInfo(pageNum, pageSize, sort, order), answer); if (CollectionUtils.isNotEmpty(answerPageInfo.getList())) { answerDtos = answerPageInfo.getList().stream().map(tempAnswer -> { AnswerDto answerDto = new AnswerDto(); BeanUtils.copyProperties(tempAnswer, answerDto); SubjectDto subjectDto = subjectService.get(tempAnswer.getSubjectId(), tempAnswer.getType()); answerDto.setSubject(subjectDto); // 判断正误 SubjectTypeEnum subjectType = SubjectTypeEnum.matchByValue(subjectDto.getType()); if (subjectType != null) { switch (subjectType) { case CHOICES: choicesHandler.judgeOptionRight(tempAnswer, subjectDto); break; case MULTIPLE_CHOICES: multipleChoicesHandler.judgeOptionRight(tempAnswer, subjectDto); break; case SHORT_ANSWER: shortAnswerHandler.judgeRight(tempAnswer, subjectDto); break; case JUDGEMENT: judgementHandler.judgeRight(tempAnswer, subjectDto); break; default: break; } } return answerDto; }).collect(Collectors.toList()); } PageInfo<AnswerDto> answerDtoPageInfo = new PageInfo<>(); answerDtoPageInfo.setList(answerDtos); answerDtoPageInfo.setTotal(answerPageInfo.getTotal()); answerDtoPageInfo.setPageNum(answerPageInfo.getPageNum()); answerDtoPageInfo.setPageSize(answerPageInfo.getPageSize()); return answerDtoPageInfo; }
Example 9
Source File: ExamRecordService.java From spring-microservice-exam with MIT License | 4 votes |
/** * 获取分页数据 * * @param pageNum pageNum * @param pageSize pageSize * @param sort sort * @param order order * @param examRecord examRecord * @return PageInfo * @author tangyi * @date 2018/11/10 21:33 */ public PageInfo<ExaminationRecordDto> examRecordList(ExaminationRecord examRecord, String pageNum, String pageSize, String sort, String order) { examRecord.setTenantCode(SysUtil.getTenantCode()); PageInfo<ExaminationRecordDto> examRecordDtoPageInfo = new PageInfo<>(); List<ExaminationRecordDto> examRecordDtoList = new ArrayList<>(); // 查询考试记录 PageInfo<ExaminationRecord> examRecordPageInfo = this.findPage( PageUtil.pageInfo(pageNum, pageSize, sort, order), examRecord); if (CollectionUtils.isNotEmpty(examRecordPageInfo.getList())) { // 查询考试信息 List<Examination> examinations = examinationService.findListById(examRecordPageInfo.getList().stream().map(ExaminationRecord::getExaminationId).distinct().toArray(Long[]::new)); examRecordPageInfo.getList().forEach(tempExamRecord -> { // 找到考试记录所属的考试信息 Examination examinationRecordExamination = examinations.stream() .filter(tempExamination -> tempExamRecord.getExaminationId().equals(tempExamination.getId())) .findFirst().orElse(null); // 转换成ExamRecordDto if (examinationRecordExamination != null) { ExaminationRecordDto examRecordDto = new ExaminationRecordDto(); BeanUtils.copyProperties(examinationRecordExamination, examRecordDto); examRecordDto.setId(tempExamRecord.getId()); examRecordDto.setStartTime(tempExamRecord.getStartTime()); examRecordDto.setEndTime(tempExamRecord.getEndTime()); examRecordDto.setScore(tempExamRecord.getScore()); examRecordDto.setUserId(tempExamRecord.getUserId()); examRecordDto.setExaminationId(tempExamRecord.getExaminationId()); // 正确题目数 examRecordDto.setCorrectNumber(tempExamRecord.getCorrectNumber()); examRecordDto.setInCorrectNumber(tempExamRecord.getInCorrectNumber()); // 提交状态 examRecordDto.setSubmitStatus(tempExamRecord.getSubmitStatus()); examRecordDtoList.add(examRecordDto); } }); this.fillExamUserInfo(examRecordDtoList, examRecordPageInfo.getList().stream().map(ExaminationRecord::getUserId).distinct().toArray(Long[]::new)); } examRecordDtoPageInfo.setTotal(examRecordPageInfo.getTotal()); examRecordDtoPageInfo.setPages(examRecordPageInfo.getPages()); examRecordDtoPageInfo.setPageSize(examRecordPageInfo.getPageSize()); examRecordDtoPageInfo.setPageNum(examRecordPageInfo.getPageNum()); examRecordDtoPageInfo.setList(examRecordDtoList); return examRecordDtoPageInfo; }
Example 10
Source File: SysUserServiceImpl.java From momo-cloud-permission with Apache License 2.0 | 4 votes |
@Override public PageInfo<SysUserListRes> sysUserList(SysUserListReq sysUserListReq) { RedisUser redisUser = this.redisUser(); PageHelper.startPage(sysUserListReq.getPageNum(), sysUserListReq.getPageSize(), "id desc"); List<SysUserListDO> pageSysUserList = userMapper.pageSysUserList(redisUser.getTenantId(), sysUserListReq.getSysUserName(), sysUserListReq.getDisabledFlag()); PageInfo<SysUserListDO> pageInfo = new PageInfo<>(pageSysUserList); List<SysUserListRes> resList = Lists.newArrayList(); List<SysUserListDO> doList = pageInfo.getList(); PageInfo<SysUserListRes> pageInfoRes = new PageInfo<>(); pageInfoRes.setPageNum(pageInfo.getPageNum()); pageInfoRes.setPageSize(pageInfo.getPageSize()); pageInfoRes.setTotal(pageInfo.getTotal()); if (CollectionUtils.isNotEmpty(doList)) { doList.forEach(sysUserListDO -> { SysUserListRes sysUserListRes = new SysUserListRes(); BeanUtils.copyProperties(sysUserListDO, sysUserListRes); //管理员按钮是否显示 List<RoleDO> roles = sysUserListDO.getRoles(); Set<Integer> rolesSet = roles.stream().map(RoleDO::getSysRoleType).collect(Collectors.toSet()); //角色的类型,0:管理员(老板),1:管理员(员工) 2其他 if (rolesSet.contains(RoleTypeEnum.superAdmin.type)) { sysUserListRes.setEditButtonShow(false); sysUserListRes.setPwdButtonShow(false); sysUserListRes.setDisabledFlagButtonShow(false); sysUserListRes.setRoleButtonShow(false); } if (rolesSet.contains(RoleTypeEnum.admin.type)) { sysUserListRes.setEditButtonShow(false); sysUserListRes.setPwdButtonShow(false); sysUserListRes.setDisabledFlagButtonShow(false); sysUserListRes.setRoleButtonShow(false); } //用户是自己登陆,则显示自己 if (sysUserListDO.getId().equals(redisUser.getBaseId())) { sysUserListRes.setEditButtonShow(true); sysUserListRes.setPwdButtonShow(true); sysUserListRes.setDisabledFlagButtonShow(true); sysUserListRes.setRoleButtonShow(true); } //超级管理员,则显示全部 if (superAdminsService.checkIsSuperAdmin(redisUser.getSysUserPhone())) { sysUserListRes.setEditButtonShow(true); sysUserListRes.setPwdButtonShow(true); sysUserListRes.setDisabledFlagButtonShow(true); sysUserListRes.setRoleButtonShow(true); } UserAccountPwdDO userAccountPwdDO = sysUserListDO.getUserAccountPwdDO(); //密码绑定 if (null != userAccountPwdDO) { sysUserListRes.setPwdBinding(true); sysUserListRes.setPwdBindingName(userAccountPwdDO.getSysUserLoginName()); sysUserListRes.setPwdBindingFlag(userAccountPwdDO.getDisabledFlag()); sysUserListRes.setPwdBindingDate(userAccountPwdDO.getCreateTime()); } //用户是自己登陆,则显示自己 if (sysUserListDO.getId().equals(redisUser.getBaseId())) { //屏蔽自己状态 按钮 sysUserListRes.setDisabledFlagButtonShow(false); } resList.add(sysUserListRes); }); pageInfoRes.setList(resList); return pageInfoRes; } return pageInfoRes; }
Example 11
Source File: SysEnterpriseServiceImpl.java From momo-cloud-permission with Apache License 2.0 | 4 votes |
@Override public SysUserListRes userList(SysEnterpriseUserReq sysEnterpriseUserReq) { UserGroupDO uuid = userGroupMapper.uuid(sysEnterpriseUserReq.getEnterpriseUuid()); if (uuid == null) { throw BizException.fail("用户所在的企业不存在"); } SysUserListRes sysUserListResFianl = new SysUserListRes(); sysUserListResFianl.setSysEnterpriseName(uuid.getUserGroupName()); RedisUser redisUser = this.redisUser(); PageHelper.startPage(sysEnterpriseUserReq.getPageNum(), sysEnterpriseUserReq.getPageSize(), "id desc"); List<SysUserListDO> pageSysUserList = userMapper.pageSysUserList(uuid.getId(), sysEnterpriseUserReq.getSysUserName(), sysEnterpriseUserReq.getDisabledFlag()); PageInfo<SysUserListDO> pageInfo = new PageInfo<>(pageSysUserList); List<SysUserListRes> resList = Lists.newArrayList(); List<SysUserListDO> doList = pageInfo.getList(); PageInfo<SysUserListRes> pageInfoRes = new PageInfo<>(); pageInfoRes.setPageNum(pageInfo.getPageNum()); pageInfoRes.setPageSize(pageInfo.getPageSize()); pageInfoRes.setTotal(pageInfo.getTotal()); if (CollectionUtils.isNotEmpty(doList)) { doList.forEach(sysUserListDO -> { SysUserListRes sysUserListRes = new SysUserListRes(); BeanUtils.copyProperties(sysUserListDO, sysUserListRes); //管理员按钮是否显示 List<RoleDO> roles = sysUserListDO.getRoles(); Set<Integer> rolesSet = roles.stream().map(RoleDO::getSysRoleType).collect(Collectors.toSet()); //角色的类型,0:管理员(老板),1:管理员(员工) 2其他 if (rolesSet.contains(RoleTypeEnum.superAdmin.type)) { sysUserListRes.setEditButtonShow(false); sysUserListRes.setPwdButtonShow(false); sysUserListRes.setDisabledFlagButtonShow(false); sysUserListRes.setRoleButtonShow(false); } if (rolesSet.contains(RoleTypeEnum.admin.type)) { sysUserListRes.setEditButtonShow(false); sysUserListRes.setPwdButtonShow(false); sysUserListRes.setDisabledFlagButtonShow(false); sysUserListRes.setRoleButtonShow(false); } //用户是自己登陆,则显示自己 if (sysUserListDO.getId().equals(redisUser.getBaseId())) { sysUserListRes.setEditButtonShow(true); sysUserListRes.setPwdButtonShow(true); sysUserListRes.setDisabledFlagButtonShow(true); sysUserListRes.setRoleButtonShow(true); } //超级管理员,则显示全部 if (superAdminsService.checkIsSuperAdmin(redisUser.getSysUserPhone())) { sysUserListRes.setEditButtonShow(true); sysUserListRes.setPwdButtonShow(true); sysUserListRes.setDisabledFlagButtonShow(true); sysUserListRes.setRoleButtonShow(true); } UserAccountPwdDO userAccountPwdDO = sysUserListDO.getUserAccountPwdDO(); //密码绑定 if (null != userAccountPwdDO) { sysUserListRes.setPwdBinding(true); sysUserListRes.setPwdBindingName(userAccountPwdDO.getSysUserLoginName()); sysUserListRes.setPwdBindingFlag(userAccountPwdDO.getDisabledFlag()); sysUserListRes.setPwdBindingDate(userAccountPwdDO.getCreateTime()); } resList.add(sysUserListRes); }); pageInfoRes.setList(resList); sysUserListResFianl.setSysUserListResPageInfo(pageInfoRes); return sysUserListResFianl; } sysUserListResFianl.setSysUserListResPageInfo(pageInfoRes); return sysUserListResFianl; }
Example 12
Source File: BlogController.java From newblog with Apache License 2.0 | 4 votes |
@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; }
Example 13
Source File: PageBuiler.java From springboot-learn with MIT License | 4 votes |
public PageInfo<?> build() { PageInfo<?> pageInfo = new PageInfo(); pageInfo.setPageNum(pageNum); pageInfo.setPageSize(pageSize); return pageInfo; }
Example 14
Source File: PageUtil.java From spring-microservice-exam with MIT License | 3 votes |
/** * 初始化pageInfo * * @param pageNum pageNum * @param pageSize pageSize * @param sort sort * @param order order * @return PageInfo * @author tangyi * @date 2019/03/28 15:36 */ public static <T> PageInfo<T> pageInfo(String pageNum, String pageSize, String sort, String order) { PageInfo<T> page = new PageInfo<>(); page.setPageNum(Integer.parseInt(pageNum)); page.setPageSize(Integer.parseInt(pageSize)); PageHelper.orderBy(orderBy(sort, order)); return page; }