Java Code Examples for com.baomidou.mybatisplus.extension.plugins.pagination.Page#setCurrent()
The following examples show how to use
com.baomidou.mybatisplus.extension.plugins.pagination.Page#setCurrent() .
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: BaseServiceImpl.java From supplierShop with MIT License | 7 votes |
protected Page setPageParam(QueryParam queryParam, OrderItem defaultOrder) { Page page = new Page(); // 设置当前页码 page.setCurrent(queryParam.getCurrent()); // 设置页大小 page.setSize(queryParam.getSize()); /** * 如果是queryParam是OrderQueryParam,并且不为空,则使用前端排序 * 否则使用默认排序 */ if (queryParam instanceof OrderQueryParam){ OrderQueryParam orderQueryParam = (OrderQueryParam) queryParam; List<OrderItem> orderItems = orderQueryParam.getOrders(); if (CollectionUtils.isEmpty(orderItems)){ page.setOrders(Arrays.asList(defaultOrder)); }else{ page.setOrders(orderItems); } }else{ page.setOrders(Arrays.asList(defaultOrder)); } return page; }
Example 2
Source File: BlogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@Override public IPage<Blog> getBlogByTime(Long currentPage, Long pageSize) { QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); Page<Blog> page = new Page<>(); page.setCurrent(currentPage); page.setSize(pageSize); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.eq(BaseSQLConf.IS_PUBLISH, EPublish.PUBLISH); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); //因为首页并不需要显示内容,所以需要排除掉内容字段 queryWrapper.select(Blog.class, i -> !i.getProperty().equals(SQLConf.CONTENT)); IPage<Blog> pageList = blogService.page(page, queryWrapper); List<Blog> list = pageList.getRecords(); list = setBlog(list); pageList.setRecords(list); return pageList; }
Example 3
Source File: BlogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@Override public IPage<Blog> getListByBlogSortUid(String blogSortUid, Long currentPage, Long pageSize) { //分页 Page<Blog> page = new Page<>(); page.setCurrent(currentPage); page.setSize(pageSize); QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); queryWrapper.eq(BaseSQLConf.IS_PUBLISH, EPublish.PUBLISH); queryWrapper.eq(SQLConf.BLOG_SORT_UID, blogSortUid); //因为首页并不需要显示内容,所以需要排除掉内容字段 queryWrapper.select(Blog.class, i -> !i.getProperty().equals(SQLConf.CONTENT)); IPage<Blog> pageList = blogService.page(page, queryWrapper); //给博客增加标签和分类 List<Blog> list = blogService.setTagAndSortByBlogList(pageList.getRecords()); pageList.setRecords(list); return pageList; }
Example 4
Source File: AuthRestApi.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@ApiOperation(value = "获取用户反馈", notes = "获取用户反馈") @GetMapping("/getFeedbackList") public String getFeedbackList(HttpServletRequest request) { if (request.getAttribute(SysConf.USER_UID) == null) { return ResultUtil.result(SysConf.ERROR, MessageConf.INVALID_TOKEN); } String userUid = request.getAttribute(SysConf.USER_UID).toString(); QueryWrapper<Feedback> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(SQLConf.USER_UID, userUid); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); Page<Feedback> page = new Page<>(); page.setSize(20); page.setCurrent(1); IPage<Feedback> pageList = feedbackService.page(page, queryWrapper); return ResultUtil.result(SysConf.SUCCESS, pageList); }
Example 5
Source File: BlogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@Override public IPage<Blog> searchBlogByAuthor(String author, Long currentPage, Long pageSize) { QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); Page<Blog> page = new Page<>(); page.setCurrent(currentPage); page.setSize(pageSize); queryWrapper.eq(SQLConf.AUTHOR, author); queryWrapper.eq(BaseSQLConf.IS_PUBLISH, EPublish.PUBLISH); queryWrapper.eq(BaseSQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); queryWrapper.select(Blog.class, i -> !i.getProperty().equals(SysConf.CONTENT)); IPage<Blog> pageList = blogService.page(page, queryWrapper); List<Blog> list = pageList.getRecords(); list = blogService.setTagAndSortAndPictureByBlogList(list); pageList.setRecords(list); return pageList; }
Example 6
Source File: SmsRecordServiceImpl.java From hdw-dubbo with Apache License 2.0 | 6 votes |
public PageVo selectSmsRecordPageList(SmsRecordDTO smsRecordDTO) { QueryWrapper<SmsRecord> wrapper = new QueryWrapper(smsRecordDTO); wrapper.like(ObjectUtils.isNotEmpty(smsRecordDTO.getUserName()), "t3.name", smsRecordDTO.getUserName()) .ge(ObjectUtils.isNotEmpty(smsRecordDTO.getStartTime()), "t.push_time", smsRecordDTO.getStartTime()) .le(ObjectUtils.isNotEmpty(smsRecordDTO.getEndTime()), "t.push_time", smsRecordDTO.getEndTime()) .eq(ObjectUtils.isNotEmpty(smsRecordDTO.getUserId()), "t.user_id", smsRecordDTO.getUserId()); if (ObjectUtils.isNotEmpty(smsRecordDTO.getStatus())){ if(smsRecordDTO.getStatus() == "-1"){ wrapper.and(i -> i.ne("t.status", "0").ne("t.status", "3")); }else{ wrapper.eq(ObjectUtils.isNotEmpty(smsRecordDTO.getStatus()), "t.status", smsRecordDTO.getStatus()); } } wrapper.orderByDesc("t.push_time"); Page page = new Page(); // 设置当前页码 page.setCurrent(smsRecordDTO.getPage()); // 设置页大小 page.setSize(smsRecordDTO.getLimit()); IPage ipage = this.baseMapper.selectSmsRecordPageList(page, wrapper); return new PageVo(ipage); }
Example 7
Source File: TodoServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@Override public IPage<Todo> getPageList(TodoVO todoVO) { String adminUid = RequestHolder.getAdminUid(); QueryWrapper<Todo> queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(todoVO.getKeyword()) && !StringUtils.isEmpty(todoVO.getKeyword().trim())) { queryWrapper.like(SQLConf.TEXT, todoVO.getKeyword().trim()); } queryWrapper.eq(SQLConf.ADMINUID, adminUid); //按时间顺序倒排 queryWrapper.orderByDesc(SQLConf.CREATE_TIME); Page<Todo> page = new Page<>(); page.setCurrent(todoVO.getCurrentPage()); page.setSize(todoVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); IPage<Todo> pageList = todoService.page(page, queryWrapper); return pageList; }
Example 8
Source File: LinkServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@Override public IPage<Link> getPageList(LinkVO linkVO) { QueryWrapper<Link> queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(linkVO.getKeyword()) && !StringUtils.isEmpty(linkVO.getKeyword().trim())) { queryWrapper.like(SQLConf.TITLE, linkVO.getKeyword().trim()); } if (linkVO.getLinkStatus() != null) { queryWrapper.eq(SQLConf.LINK_STATUS, linkVO.getLinkStatus()); } Page<Link> page = new Page<>(); page.setCurrent(linkVO.getCurrentPage()); page.setSize(linkVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.SORT); IPage<Link> pageList = linkService.page(page, queryWrapper); return pageList; }
Example 9
Source File: TagServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public String stickTag(TagVO tagVO) { Tag tag = tagService.getById(tagVO.getUid()); //查找出最大的那一个 QueryWrapper<Tag> queryWrapper = new QueryWrapper<>(); queryWrapper.orderByDesc(SQLConf.SORT); Page<Tag> page = new Page<>(); page.setCurrent(0); page.setSize(1); IPage<Tag> pageList = tagService.page(page, queryWrapper); List<Tag> list = pageList.getRecords(); Tag maxTag = list.get(0); if (StringUtils.isEmpty(maxTag.getUid())) { return ResultUtil.result(SysConf.ERROR, MessageConf.PARAM_INCORRECT); } if (maxTag.getUid().equals(tag.getUid())) { return ResultUtil.result(SysConf.ERROR, MessageConf.THIS_TAG_IS_TOP); } Integer sortCount = maxTag.getSort() + 1; tag.setSort(sortCount); tag.setUpdateTime(new Date()); tag.updateById(); return ResultUtil.result(SysConf.SUCCESS, MessageConf.OPERATION_SUCCESS); }
Example 10
Source File: BlogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public IPage<Blog> searchBlogByTag(String tagUid, Long currentPage, Long pageSize) { Tag tag = tagService.getById(tagUid); if (tag != null) { HttpServletRequest request = RequestHolder.getRequest(); String ip = IpUtils.getIpAddr(request); //从Redis取出数据,判断该用户24小时内,是否点击过该标签 String jsonResult = redisUtil.get(RedisConf.TAG_CLICK + RedisConf.SEGMENTATION + ip + "#" + tagUid); if (StringUtils.isEmpty(jsonResult)) { //给标签点击数增加 int clickCount = tag.getClickCount() + 1; tag.setClickCount(clickCount); tag.updateById(); //将该用户点击记录存储到redis中, 24小时后过期 redisUtil.setEx(RedisConf.TAG_CLICK + RedisConf.SEGMENTATION + ip + RedisConf.WELL_NUMBER + tagUid, clickCount + "", 24, TimeUnit.HOURS); } } QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); Page<Blog> page = new Page<>(); page.setCurrent(currentPage); page.setSize(pageSize); queryWrapper.like(SQLConf.TagUid, tagUid); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.eq(BaseSQLConf.IS_PUBLISH, EPublish.PUBLISH); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); queryWrapper.select(Blog.class, i -> !i.getProperty().equals(SysConf.CONTENT)); IPage<Blog> pageList = blogService.page(page, queryWrapper); List<Blog> list = pageList.getRecords(); list = blogService.setTagAndSortAndPictureByBlogList(list); pageList.setRecords(list); return pageList; }
Example 11
Source File: ResourceSortServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public String stickResourceSort(ResourceSortVO resourceSortVO) { ResourceSort resourceSort = resourceSortService.getById(resourceSortVO.getUid()); //查找出最大的那一个 QueryWrapper<ResourceSort> queryWrapper = new QueryWrapper<>(); queryWrapper.orderByDesc(BaseSQLConf.SORT); Page<ResourceSort> page = new Page<>(); page.setCurrent(0); page.setSize(1); IPage<ResourceSort> pageList = resourceSortService.page(page, queryWrapper); List<ResourceSort> list = pageList.getRecords(); ResourceSort maxSort = list.get(0); if (StringUtils.isEmpty(maxSort.getUid())) { return ResultUtil.result(BaseSysConf.ERROR, BaseMessageConf.PARAM_INCORRECT); } if (maxSort.getUid().equals(resourceSort.getUid())) { return ResultUtil.result(BaseSysConf.ERROR, BaseMessageConf.THIS_SORT_IS_TOP); } Integer sortCount = maxSort.getSort() + 1; resourceSort.setSort(sortCount); resourceSort.setUpdateTime(new Date()); resourceSort.updateById(); return ResultUtil.result(BaseSysConf.SUCCESS, BaseMessageConf.OPERATION_SUCCESS); }
Example 12
Source File: BaseServiceImpl.java From hdw-dubbo with Apache License 2.0 | 5 votes |
public PageVo pageList(CommonDTO commonDTO) { Page page = new Page(); // 设置当前页码 page.setCurrent(commonDTO.getPage()); // 设置页大小 page.setSize(commonDTO.getLimit()); IPage iPage = this.baseMapper.pageList(page, commonDTO); return new PageVo(iPage); }
Example 13
Source File: LinkServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public List<Link> getListByPageSize(Integer pageSize) { QueryWrapper<Link> queryWrapper = new QueryWrapper<>(); Page<Link> page = new Page<>(); page.setCurrent(1); page.setSize(pageSize); queryWrapper.eq(BaseSQLConf.LINK_STATUS, ELinkStatus.PUBLISH); queryWrapper.eq(BaseSQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(BaseSQLConf.SORT); IPage<Link> pageList = linkMapper.selectPage(page, queryWrapper); return pageList.getRecords(); }
Example 14
Source File: BlogSortServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public IPage<BlogSort> getPageList(BlogSortVO blogSortVO) { QueryWrapper<BlogSort> queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(blogSortVO.getKeyword()) && !StringUtils.isEmpty(blogSortVO.getKeyword().trim())) { queryWrapper.like(SQLConf.SORT_NAME, blogSortVO.getKeyword().trim()); } Page<BlogSort> page = new Page<>(); page.setCurrent(blogSortVO.getCurrentPage()); page.setSize(blogSortVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.SORT); IPage<BlogSort> pageList = blogSortService.page(page, queryWrapper); return pageList; }
Example 15
Source File: ExceptionLogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public IPage<ExceptionLog> getPageList(ExceptionLogVO exceptionLogVO) { QueryWrapper<ExceptionLog> queryWrapper = new QueryWrapper<>(); if (!StringUtils.isEmpty(exceptionLogVO.getKeyword())) { queryWrapper.like(SQLConf.CONTENT, exceptionLogVO.getKeyword()); } if (!StringUtils.isEmpty(exceptionLogVO.getOperation())) { queryWrapper.like(SQLConf.OPERATION, exceptionLogVO.getOperation()); } if (!StringUtils.isEmpty(exceptionLogVO.getStartTime())) { String[] time = exceptionLogVO.getStartTime().split(SysConf.FILE_SEGMENTATION); if (time.length == 2) { queryWrapper.between(SQLConf.CREATE_TIME, DateUtils.str2Date(time[0]), DateUtils.str2Date(time[1])); } } Page<ExceptionLog> page = new Page<>(); page.setCurrent(exceptionLogVO.getCurrentPage()); page.setSize(exceptionLogVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); // queryWrapper.select(ExceptionLog.class, i -> !i.getProperty().equals(SQLConf.EXCEPTION_JSON)); IPage<ExceptionLog> pageList = exceptionLogService.page(page, queryWrapper); return pageList; }
Example 16
Source File: SysDictDataServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public IPage<SysDictData> getPageList(SysDictDataVO sysDictDataVO) { QueryWrapper<SysDictData> queryWrapper = new QueryWrapper<>(); // 字典类型UID if (StringUtils.isNotEmpty(sysDictDataVO.getDictTypeUid())) { queryWrapper.eq(SQLConf.DICT_TYPE_UID, sysDictDataVO.getDictTypeUid()); } // 字典标签 if (StringUtils.isNotEmpty(sysDictDataVO.getDictLabel()) && !StringUtils.isEmpty(sysDictDataVO.getDictLabel().trim())) { queryWrapper.like(SQLConf.DICT_LABEL, sysDictDataVO.getDictLabel().trim()); } Page<SysDictData> page = new Page<>(); page.setCurrent(sysDictDataVO.getCurrentPage()); page.setSize(sysDictDataVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.SORT, SQLConf.CREATE_TIME); IPage<SysDictData> pageList = sysDictDataService.page(page, queryWrapper); List<SysDictData> sysDictDataList = pageList.getRecords(); Set<String> dictTypeUidList = new HashSet<>(); sysDictDataList.forEach(item -> { dictTypeUidList.add(item.getDictTypeUid()); }); Collection<SysDictType> dictTypeList = new ArrayList<>(); if (dictTypeUidList.size() > 0) { dictTypeList = sysDictTypeService.listByIds(dictTypeUidList); } Map<String, SysDictType> dictTypeMap = new HashMap<>(); dictTypeList.forEach(item -> { dictTypeMap.put(item.getUid(), item); }); sysDictDataList.forEach(item -> { item.setSysDictType(dictTypeMap.get(item.getDictTypeUid())); }); pageList.setRecords(sysDictDataList); return pageList; }
Example 17
Source File: PluginDataServiceImpl.java From springboot-plugin-framework-parent with Apache License 2.0 | 5 votes |
@Override public List<PluginData> getByPage(Long size, Long currentPage) { Page<PluginData> page = new Page<>(); page.setSize(size); page.setCurrent(currentPage); IPage<PluginData> page1 = page(page); return page1.getRecords(); }
Example 18
Source File: SmartPageUtil.java From smart-admin with MIT License | 5 votes |
public static <T> Page<T> convert2QueryPage(PageParamDTO baseDTO) { Page<T> page = new Page<>(); List<OrderItemDTO> orders = baseDTO.getOrders(); if (orders != null && !orders.isEmpty()) { List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderItemList = orders.stream().map(e -> convertOrderItem(e)).collect(Collectors.toList()); page.setOrders(orderItemList); } page.setCurrent(baseDTO.getPageNum()); page.setSize(baseDTO.getPageSize()); if (null != baseDTO.getSearchCount()) { page.setSearchCount(baseDTO.getSearchCount()); } return page; }
Example 19
Source File: CategoryMenuServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 4 votes |
@Override public Map<String, Object> getPageList(CategoryMenuVO categoryMenuVO) { Map<String, Object> resultMap = new HashMap<>(); QueryWrapper<CategoryMenu> queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(categoryMenuVO.getKeyword()) && !StringUtils.isEmpty(categoryMenuVO.getKeyword().trim())) { queryWrapper.like(SQLConf.NAME, categoryMenuVO.getKeyword().trim()); } if (categoryMenuVO.getMenuLevel() != 0) { queryWrapper.eq(SQLConf.MENU_LEVEL, categoryMenuVO.getMenuLevel()); } Page<CategoryMenu> page = new Page<>(); page.setCurrent(categoryMenuVO.getCurrentPage()); page.setSize(categoryMenuVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.SORT); IPage<CategoryMenu> pageList = categoryMenuService.page(page, queryWrapper); List<CategoryMenu> list = pageList.getRecords(); List<String> ids = new ArrayList<>(); list.forEach(item -> { if (StringUtils.isNotEmpty(item.getParentUid())) { ids.add(item.getParentUid()); } }); if (ids.size() > 0) { Collection<CategoryMenu> parentList = categoryMenuService.listByIds(ids); Map<String, CategoryMenu> map = new HashMap<>(); parentList.forEach(item -> { map.put(item.getUid(), item); }); list.forEach(item -> { if (StringUtils.isNotEmpty(item.getParentUid())) { item.setParentCategoryMenu(map.get(item.getParentUid())); } }); resultMap.put(SysConf.OTHER_DATA, parentList); } pageList.setRecords(list); resultMap.put(SysConf.DATA, pageList); return resultMap; }
Example 20
Source File: FeedbackServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 4 votes |
@Override public IPage<Feedback> getPageList(FeedbackVO feedbackVO) { QueryWrapper<Feedback> queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(feedbackVO.getTitle())) { queryWrapper.like(SQLConf.TITLE, feedbackVO.getTitle()); } if (feedbackVO.getFeedbackStatus() != null) { queryWrapper.eq(SQLConf.FEEDBACK_STATUS, feedbackVO.getFeedbackStatus()); } Page<Feedback> page = new Page<>(); page.setCurrent(feedbackVO.getCurrentPage()); page.setSize(feedbackVO.getPageSize()); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); queryWrapper.orderByDesc(SQLConf.CREATE_TIME); IPage<Feedback> pageList = feedbackService.page(page, queryWrapper); List<Feedback> feedbackList = pageList.getRecords(); List<String> userUids = new ArrayList<>(); feedbackList.forEach(item -> { if (StringUtils.isNotEmpty(item.getUserUid())) { userUids.add(item.getUserUid()); } }); List<User> userList = userService.getUserListByIds(userUids); Map<String, User> map = new HashMap<>(); userList.forEach(item -> { item.setPassWord(""); map.put(item.getUid(), item); }); feedbackList.forEach(item -> { if (StringUtils.isNotEmpty(item.getUserUid())) { item.setUser(map.get(item.getUserUid())); } }); pageList.setRecords(feedbackList); return pageList; }