Java Code Examples for com.baomidou.mybatisplus.core.metadata.IPage#getRecords()
The following examples show how to use
com.baomidou.mybatisplus.core.metadata.IPage#getRecords() .
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: OrderServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * * @param type 1-积分 2-余额 * @param userId * @param page * @param limit * @return */ @Override public List<StorePointsMoneyLog> pointsMoneyLogs(int type, int userId, int page, int limit) { QueryWrapper<StorePointsMoneyLog> wrapper = new QueryWrapper<>(); wrapper.eq("user_id",userId).orderByDesc("create_time"); if(type == 1){ wrapper.gt("points_number",0); }else{ wrapper.gt("money_number",0); } Page<StorePointsMoneyLog> pageModel = new Page<>(page, limit); IPage<StorePointsMoneyLog> pageList = storePointsMoneyLogMapper.selectPage(pageModel,wrapper); List<StorePointsMoneyLog> list = pageList.getRecords(); return list; }
Example 2
Source File: GoodsServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 购物车列表 * @param pageVO * @param userId * @return */ @Override public List<CartDTO> cartList(PageVO pageVO,int userId) { QueryWrapper<StoreCart> cartQueryWrapper = new QueryWrapper<>(); cartQueryWrapper.eq("user_id",userId).groupBy("goods_id"); Page<StoreCart> pageModel = new Page<>(pageVO.getPage(), pageVO.getLimit()); IPage<StoreCart> storeCarts = storeCartMapper .selectPage(pageModel,cartQueryWrapper); List<StoreCart> storeCartList = storeCarts.getRecords(); List<CartDTO> carts = new ArrayList<>(); for (StoreCart storeCart : storeCartList) { CartDTO cartDTO = new CartDTO(); StoreGoods storeGoods = getById(storeCart.getGoodsId()); cartDTO.setGoodsId(storeCart.getGoodsId()); cartDTO.setGoodsName(storeGoods.getGoodsName()); cartDTO.setGoodsSn(storeGoods.getGoodsSn()); cartDTO.setGoodsLogo(storeGoods.getGoodsLogo()); QueryWrapper<StoreCart> wrapper = new QueryWrapper<>(); wrapper.eq("user_id",userId).eq("goods_id",storeCart.getGoodsId()); cartDTO.setSpecList(cartMapper.toDto(storeCartMapper.selectList(wrapper))); carts.add(cartDTO); } return carts; }
Example 3
Source File: BlogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 6 votes |
@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: 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 5
Source File: SysBaseApiImpl.java From jeecg-boot with Apache License 2.0 | 6 votes |
@Override public JSONObject queryAllUser(String[] userIds,int pageNo,int pageSize) { JSONObject json = new JSONObject(); QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status",1).eq("del_flag",0); List<ComboModel> list = new ArrayList<ComboModel>(); Page<SysUser> page = new Page<SysUser>(pageNo, pageSize); IPage<SysUser> pageList = userMapper.selectPage(page, queryWrapper); for(SysUser user : pageList.getRecords()){ ComboModel model = new ComboModel(); model.setUsername(user.getUsername()); model.setTitle(user.getRealname()); model.setId(user.getId()); model.setEmail(user.getEmail()); if(oConvertUtils.isNotEmpty(userIds)){ for(int i = 0; i<userIds.length;i++){ if(userIds[i].equals(user.getId())){ model.setChecked(true); } } } list.add(model); } json.put("list",list); json.put("total",pageList.getTotal()); return json; }
Example 6
Source File: BlogServiceImpl.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Override public List<Blog> getBlogListByTop(Integer top) { QueryWrapper<Blog> queryWrapper = new QueryWrapper<>(); queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE); Page<Blog> page = new Page<>(); page.setCurrent(1); page.setSize(top); queryWrapper.eq(SQLConf.IS_PUBLISH, EPublish.PUBLISH); queryWrapper.orderByDesc(SQLConf.SORT); IPage<Blog> pageList = blogService.page(page, queryWrapper); List<Blog> list = pageList.getRecords(); list = blogService.setTagAndSortAndPictureByBlogList(list); return list; }
Example 7
Source File: OrderServiceImpl.java From poseidon with Apache License 2.0 | 5 votes |
@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 8
Source File: ProductServiceImpl.java From mall4j with GNU Affero General Public License v3.0 | 5 votes |
@Override public IPage<SearchProdDto> getSearchProdDtoPageByProdName(Page page, String prodName, Integer sort, Integer orderBy) { IPage<SearchProdDto> searchProdDtoPage = productMapper.getSearchProdDtoPageByProdName(page, prodName, sort, orderBy); for (SearchProdDto searchProdDto : searchProdDtoPage.getRecords()) { //计算出好评率 if (searchProdDto.getPraiseNumber() == 0 || searchProdDto.getProdCommNumber() == 0) { searchProdDto.setPositiveRating(0.0); } else { searchProdDto.setPositiveRating(Arith.mul(Arith.div(searchProdDto.getPraiseNumber(), searchProdDto.getProdCommNumber()), 100)); } } return searchProdDtoPage; }
Example 9
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 10
Source File: LoginLogServiceImpl.java From FEBS-Cloud with Apache License 2.0 | 5 votes |
@Override public List<LoginLog> findUserLastSevenLoginLogs(String username) { LoginLog loginLog = new LoginLog(); loginLog.setUsername(username); QueryRequest request = new QueryRequest(); request.setPageNum(1); // 近7日记录 request.setPageSize(7); IPage<LoginLog> loginLogs = this.findLoginLogs(loginLog, request); return loginLogs.getRecords(); }
Example 11
Source File: UserServiceImpl.java From permission with MIT License | 5 votes |
/** * 加载用户角色 * @param page */ private void findUserRoles(IPage page) { List<?> content = page.getRecords(); for(Object object:content) { SysUser sysUser = (SysUser) object; List<SysUserRole> userRoles = findUserRoles(sysUser.getId()); sysUser.setUserRoles(userRoles); sysUser.setRoleNames(getRoleNames(userRoles)); SysDept dept = deptMapper.selectById(sysUser.getDeptId()); if (dept != null) { sysUser.setDeptName(dept.getName()); } } }
Example 12
Source File: MyBatisAccessor.java From jstarcraft-core with Apache License 2.0 | 5 votes |
@Override public <K extends Comparable, T extends IdentityObject<K>> void iterateIntersection(StorageIterator<T> iterator, Class<T> clazz, Map<String, Object> condition, StoragePagination pagination) { MyBatisMetadata metadata = metadatas.get(clazz); BaseMapper mapper = template.getMapper(metadata.getMapperClass()); QueryWrapper<?> query = new QueryWrapper<>(); for (Entry<String, Object> term : condition.entrySet()) { query.and((wrapper) -> { return wrapper.eq(metadata.getColumnName(term.getKey()), term.getValue()); }); } IPage<T> page = mapper.selectPage(new Page(pagination.getPage(), pagination.getSize()), query); for (T object : page.getRecords()) { iterator.iterate(object); } }
Example 13
Source File: SpringbootmybatisplusApplicationTests.java From code with Apache License 2.0 | 5 votes |
@Test public void testselectPage() { Page<User> page = new Page<>(1, 2); IPage<User> userIPage = this.userMapper.selectPage(page, null); System.out.println("总条数 ------> " + userIPage.getTotal()); System.out.println("当前页数 ------> " + userIPage.getCurrent()); System.out.println("当前每页显示数 ------> " + userIPage.getSize()); List<User> records = userIPage.getRecords(); for (User user : records) { System.out.println(user); } }
Example 14
Source File: CommentRestApi.java From mogu_blog_v2 with Apache License 2.0 | 4 votes |
/** * 获取用户点赞信息 * * @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 15
Source File: Paging.java From spring-boot-plus with Apache License 2.0 | 4 votes |
public Paging(IPage<T> page) { this.total = page.getTotal(); this.records = page.getRecords(); this.pageIndex = page.getCurrent(); this.pageSize = page.getSize(); }
Example 16
Source File: Paging.java From yshopmall with Apache License 2.0 | 4 votes |
public Paging(IPage page) { this.total = page.getTotal(); this.records = page.getRecords(); }
Example 17
Source File: PageVo.java From hdw-dubbo with Apache License 2.0 | 4 votes |
/** * 分页 */ public PageVo(IPage page) { this.list = page.getRecords(); this.totalCount = new Long(page.getTotal()).intValue(); }
Example 18
Source File: SysUserController.java From jeecg-boot with Apache License 2.0 | 4 votes |
/** * 根据 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 19
Source File: OrderServiceImpl.java From supplierShop with MIT License | 4 votes |
/** * 订单列表 * @param status * @param userId * @param page * @param limit * @return */ @Override public List<OrderDTO> orderList(int status, int userId, int page,int limit) { QueryWrapper<StoreOrder> wrapper = new QueryWrapper<>(); wrapper.eq("deleted",0).eq("user_id",userId); // 0-全部 1-待付款 2-待发货 3-待收货 4-待评价 switch (status){ case 1: wrapper.eq("pay_status",0); break; case 2: wrapper.eq("pay_status",1).eq("shipping_status",0).eq("order_status",0); break; case 3: wrapper.eq("shipping_status",1); break; case 4: wrapper.eq("order_status",1); break; } Page<StoreOrder> pageModel = new Page<>(page, limit); IPage<StoreOrder> pageList = baseMapper.selectPage(pageModel,wrapper); List<StoreOrder> list = pageList.getRecords(); List<OrderDTO> orderDTOList = new ArrayList<>(); for (StoreOrder storeOrder : list) { QueryWrapper<StoreOrderGoods> wrapperGoods = new QueryWrapper<>(); wrapperGoods.eq("order_id",storeOrder.getOrderId()).groupBy("goods_id"); List<StoreOrderGoods> storeGoods = storeOrderGoodsMapper.selectList(wrapperGoods); List<StoreOrderGoods> newStoreGoods = new ArrayList<>(); for (StoreOrderGoods storeGood : storeGoods) { QueryWrapper<StoreOrderGoods> wrapper2 = new QueryWrapper<>(); wrapper2.eq("order_id",storeOrder.getOrderId()).eq("goods_id",storeGood.getGoodsId()); storeGood.setSpecList(orderGoodsMapper.toDto(storeOrderGoodsMapper.selectList(wrapper2))); newStoreGoods.add(storeGood); } OrderDTO orderDTO = orderMapper.toDto(storeOrder); orderDTO.setGoodsList(newStoreGoods); //处理订单状态 orderDTO.setStatus(OrderUtil.orderStatus(storeOrder.getPayStatus(), storeOrder.getShippingStatus(),storeOrder.getOrderStatus())); orderDTOList.add(orderDTO); } return orderDTOList; }
Example 20
Source File: PageResultWrapper.java From magic-starter with GNU Lesser General Public License v3.0 | 2 votes |
/** * 构造分页对象 * * @param pageData 当前页数据 * @param <T>泛型 * @return 分页对象 */ public static <T> PageResult<T> wrapper(IPage<T> pageData) { return new PageResult<>((int) pageData.getCurrent(), (int) pageData.getSize(), (int) pageData.getPages(), pageData.getTotal(), pageData.getRecords()); }