Java Code Examples for com.baomidou.mybatisplus.core.metadata.IPage#setRecords()

The following examples show how to use com.baomidou.mybatisplus.core.metadata.IPage#setRecords() . 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: OauthClientDetailsServiceImpl.java    From FEBS-Cloud with Apache License 2.0 8 votes vote down vote up
@Override
public IPage<OauthClientDetails> findOauthClientDetails(QueryRequest request, OauthClientDetails oauthClientDetails) {
    LambdaQueryWrapper<OauthClientDetails> queryWrapper = new LambdaQueryWrapper<>();
    if (StringUtils.isNotBlank(oauthClientDetails.getClientId())) {
        queryWrapper.eq(OauthClientDetails::getClientId, oauthClientDetails.getClientId());
    }
    Page<OauthClientDetails> page = new Page<>(request.getPageNum(), request.getPageSize());
    IPage<OauthClientDetails> result = this.page(page, queryWrapper);

    List<OauthClientDetails> records = new ArrayList<>();
    result.getRecords().forEach(o -> {
        o.setOriginSecret(null);
        o.setClientSecret(null);
        records.add(o);
    });
    result.setRecords(records);
    return result;
}
 
Example 2
Source File: BlogServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 6 votes vote down vote up
@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 vote down vote up
@Override
public IPage<Blog> getSameBlogByTagUid(String tagUid) {
    QueryWrapper<Blog> queryWrapper = new QueryWrapper<>();
    Page<Blog> page = new Page<>();
    page.setCurrent(1);
    page.setSize(10);
    queryWrapper.like(SQLConf.TAG_UID, tagUid);
    queryWrapper.orderByDesc(SQLConf.CREATE_TIME);
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.eq(SQLConf.IS_PUBLISH, EPublish.PUBLISH);
    IPage<Blog> pageList = blogService.page(page, queryWrapper);
    List<Blog> list = pageList.getRecords();
    list = blogService.setTagAndSortByBlogList(list);
    pageList.setRecords(list);
    return pageList;
}
 
Example 4
Source File: SysUserServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<SysUserSysDepartModel> queryUserByOrgCode(String orgCode, SysUser userParams, IPage page) {
	List<SysUserSysDepartModel> list = baseMapper.getUserByOrgCode(page, orgCode, userParams);
	Integer total = baseMapper.getUserByOrgCodeTotal(orgCode, userParams);

	IPage<SysUserSysDepartModel> result = new Page<>(page.getCurrent(), page.getSize(), total);
	result.setRecords(list);

	return result;
}
 
Example 5
Source File: ProcessEngineService.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 查询流程定义列表
 *
 * @return
 */
public IPage<ProcessDefinition> findProcessDefinition(String key, int firstResult, int maxResults) {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    // 只查询最新版本
    query.latestVersion();
    if (StringUtils.isNotBlank(key)) {
        String processKey = "%" + key + "%";
        query.processDefinitionKeyLike(processKey);
    }
    List<ProcessDefinition> list = query.listPage(firstResult, maxResults);
    IPage page = new Page();
    page.setRecords(list);
    page.setTotal(query.count());
    return page;
}
 
Example 6
Source File: SysDictDataServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: BlogServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: OrderServiceImpl.java    From poseidon with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<OrderDto> getPageByBuyerId(Long buyerId, Integer status, long current,
		long size) {
	Page page = new Page(current, size);
	IPage<OrderDto> orderDtoIPage = orderMapper.selectPageByBuyerId(page, buyerId,
			status);
	List<OrderDto> records = orderDtoIPage.getRecords();
	records.forEach(orderDto -> {
		List<OrderItemDto> orderDetails = convertService.convertOrderItem(
				orderItemMapper.selectByOrderId(orderDto.getOrderId()));
		orderDto.setOrderItemDtoList(orderDetails);
	});
	return orderDtoIPage.setRecords(records);
}
 
Example 9
Source File: TaskController.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 获取任务列表
 *
 * @return
 */
@ApiOperation(value = "获取任务列表", notes = "获取任务列表")
@GetMapping(value = "/job")
public ResultBody<IPage<TaskInfo>> getJobList(@RequestParam(required = false) Map map) {
    List<TaskInfo> list = schedulerService.getJobList();
    IPage page = new Page();
    page.setRecords(list);
    page.setTotal(list.size());
    return ResultBody.ok().data(page);
}
 
Example 10
Source File: DeptServiceImpl.java    From SpringBlade with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<DeptVO> selectDeptPage(IPage<DeptVO> page, DeptVO dept) {
	return page.setRecords(baseMapper.selectDeptPage(page, dept));
}
 
Example 11
Source File: NoticeServiceImpl.java    From SpringBlade with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<Notice> selectNoticePage(IPage<Notice> page, Notice notice) {
	return page.setRecords(baseMapper.selectNoticePage(page, notice));
}
 
Example 12
Source File: UserServiceImpl.java    From SpringBlade with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<User> selectUserPage(IPage<User> page, User user) {
	return page.setRecords(baseMapper.selectUserPage(page, user));
}
 
Example 13
Source File: SysUserController.java    From teaching with Apache License 2.0 4 votes vote down vote up
/**
 * 根据 orgCode 查询用户,包括子部门下的用户
 * 针对通讯录模块做的接口,将多个部门的用户合并成一条记录,并转成对前端友好的格式
 */
@GetMapping("/queryByOrgCodeForAddressList")
public Result<?> queryByOrgCodeForAddressList(
        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "orgCode",required = false) String orgCode,
        SysUser userParams
) {
    IPage page = new Page(pageNo, pageSize);
    IPage<SysUserSysDepartModel> pageList = sysUserService.queryUserByOrgCode(orgCode, userParams, page);
    List<SysUserSysDepartModel> list = pageList.getRecords();

    // 记录所有出现过的 user, key = userId
    Map<String, JSONObject> hasUser = new HashMap<>(list.size());

    JSONArray resultJson = new JSONArray(list.size());

    for (SysUserSysDepartModel item : list) {
        String userId = item.getSysUser().getId();
        // userId
        JSONObject getModel = hasUser.get(userId);
        // 之前已存在过该用户,直接合并数据
        if (getModel != null) {
            String departName = getModel.get("departName").toString();
            getModel.put("departName", (departName + " | " + item.getSysDepart().getDepartName()));
        } else {
            // 将用户对象转换为json格式,并将部门信息合并到 json 中
            JSONObject json = JSON.parseObject(JSON.toJSONString(item.getSysUser()));
            json.remove("id");
            json.put("userId", userId);
            json.put("departId", item.getSysDepart().getId());
            json.put("departName", item.getSysDepart().getDepartName());

            resultJson.add(json);
            hasUser.put(userId, json);
        }
    }

    IPage<JSONObject> result = new Page<>(pageNo, pageSize, pageList.getTotal());
    result.setRecords(resultJson.toJavaList(JSONObject.class));
    return Result.ok(result);
}
 
Example 14
Source File: TenantServiceImpl.java    From SpringBlade with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<Tenant> selectTenantPage(IPage<Tenant> page, Tenant tenant) {
	return page.setRecords(baseMapper.selectTenantPage(page, tenant));
}
 
Example 15
Source File: NoticeServiceImpl.java    From SpringBlade with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<Notice> selectNoticePage(IPage<Notice> page, Notice notice) {
	return page.setRecords(baseMapper.selectNoticePage(page, notice));
}
 
Example 16
Source File: DictServiceImpl.java    From SpringBlade with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<DictVO> selectDictPage(IPage<DictVO> page, DictVO dict) {
	return page.setRecords(baseMapper.selectDictPage(page, dict));
}
 
Example 17
Source File: SysUserController.java    From jeecg-boot with Apache License 2.0 4 votes vote down vote up
/**
     * 根据 orgCode 查询用户,包括子部门下的用户
     * 针对通讯录模块做的接口,将多个部门的用户合并成一条记录,并转成对前端友好的格式
     */
    @GetMapping("/queryByOrgCodeForAddressList")
    public Result<?> queryByOrgCodeForAddressList(
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(name = "orgCode",required = false) String orgCode,
            SysUser userParams
    ) {
        IPage page = new Page(pageNo, pageSize);
        IPage<SysUserSysDepartModel> pageList = sysUserService.queryUserByOrgCode(orgCode, userParams, page);
        List<SysUserSysDepartModel> list = pageList.getRecords();

        // 记录所有出现过的 user, key = userId
        Map<String, JSONObject> hasUser = new HashMap<>(list.size());

        JSONArray resultJson = new JSONArray(list.size());

        for (SysUserSysDepartModel item : list) {
            String userId = item.getId();
            // userId
            JSONObject getModel = hasUser.get(userId);
            // 之前已存在过该用户,直接合并数据
            if (getModel != null) {
                String departName = getModel.get("departName").toString();
                getModel.put("departName", (departName + " | " + item.getDepartName()));
            } else {
                // 将用户对象转换为json格式,并将部门信息合并到 json 中
                JSONObject json = JSON.parseObject(JSON.toJSONString(item));
                json.remove("id");
                json.put("userId", userId);
                json.put("departId", item.getDepartId());
                json.put("departName", item.getDepartName());
//                json.put("avatar", item.getSysUser().getAvatar());
                resultJson.add(json);
                hasUser.put(userId, json);
            }
        }

        IPage<JSONObject> result = new Page<>(pageNo, pageSize, pageList.getTotal());
        result.setRecords(resultJson.toJavaList(JSONObject.class));
        return Result.ok(result);
    }
 
Example 18
Source File: CategoryMenuServiceImpl.java    From mogu_blog_v2 with Apache License 2.0 4 votes vote down vote up
@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 19
Source File: CommentRestApi.java    From mogu_blog_v2 with Apache License 2.0 4 votes vote down vote up
/**
 * 获取用户点赞信息
 *
 * @return
 */
@ApiOperation(value = "获取用户点赞信息", notes = "增加评论")
@PostMapping("/getPraiseListByUser")
public String getPraiseListByUser(@ApiParam(name = "currentPage", value = "当前页数", required = false) @RequestParam(name = "currentPage", required = false, defaultValue = "1") Long currentPage,
                                  @ApiParam(name = "pageSize", value = "每页显示数目", required = false) @RequestParam(name = "pageSize", required = false, defaultValue = "10") Long pageSize) {
    HttpServletRequest request = RequestHolder.getRequest();
    if (request.getAttribute(SysConf.USER_UID) == null || request.getAttribute(SysConf.TOKEN) == null) {
        return ResultUtil.result(SysConf.ERROR, MessageConf.INVALID_TOKEN);
    }
    String userUid = request.getAttribute(SysConf.USER_UID).toString();

    QueryWrapper<Comment> queryWrappe = new QueryWrapper<>();
    queryWrappe.eq(SQLConf.USER_UID, userUid);
    queryWrappe.eq(SQLConf.TYPE, ECommentType.PRAISE);
    queryWrappe.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrappe.orderByDesc(SQLConf.CREATE_TIME);
    Page<Comment> page = new Page<>();
    page.setCurrent(currentPage);
    page.setSize(pageSize);
    IPage<Comment> pageList = commentService.page(page, queryWrappe);
    List<Comment> praiseList = pageList.getRecords();

    List<String> blogUids = new ArrayList<>();
    praiseList.forEach(item -> {
        blogUids.add(item.getBlogUid());
    });
    Map<String, Blog> blogMap = new HashMap<>();
    if (blogUids.size() > 0) {
        Collection<Blog> blogList = blogService.listByIds(blogUids);
        blogList.forEach(blog -> {
            // 并不需要content内容
            blog.setContent("");
            blogMap.put(blog.getUid(), blog);
        });
    }

    praiseList.forEach(item -> {
        if (blogMap.get(item.getBlogUid()) != null) {
            item.setBlog(blogMap.get(item.getBlogUid()));
        }
    });

    pageList.setRecords(praiseList);

    return ResultUtil.result(SysConf.SUCCESS, pageList);
}
 
Example 20
Source File: PostServiceImpl.java    From SpringBlade with Apache License 2.0 4 votes vote down vote up
@Override
public IPage<PostVO> selectPostPage(IPage<PostVO> page, PostVO post) {
	return page.setRecords(baseMapper.selectPostPage(page, post));
}