zoukankan      html  css  js  c++  java
  • java8stream流特性运用实例


    List<PostSchoolResp> postList = newYearActivityMapper.getPostList(topicIdList, activity.getStartTime(), activity.getEndTime(),1);
    List<PostSchoolResp> postLists = new ArrayList<>();

      Collections.sort(postLists, Comparator.comparing(PostSchoolResp::getCreateTime).reversed());
    List<PostSchoolResp> postListFOUR = postLists.stream().limit(4).collect(Collectors.toList());
    log.info("f数量:"+postList.size());
    if (! postListFOUR.isEmpty()){
    postListFOUR.forEach(PostSchoolResps->{
    PostSchoolResps.setIcon(JPIcon);
    //删除集合中重复数据
    postList.removeIf(PostSchoolResp->PostSchoolResp.getId().equals(PostSchoolResps.getId()));
    // List<PostSchoolResp> postListNw = postList.stream().
    // filter(PostSchoolResp -> (! PostSchoolResp.getId().equals(PostSchoolResps.getId()))).collect(Collectors.toList());
    });
    }
    log.info("ff数量:"+postList.size());
    // BeanUtils.copyProperties(postListFOUR,postList);
    postListFOUR.addAll(postList);
    // List<PostSchoolResp> postListTEN = postLists.stream().limit(10).collect(Collectors.toList());
    log.info("fou数量:"+postListFOUR.size());
    List<PostSchoolResp> postListLimit = postListFOUR.stream().skip((pageNum-1)*pageSize).limit(pageSize).
    collect(Collectors.toList());
    return BaseResponse.buildSuccess("success", postListLimit);‘’

    ---------------------分页问题:
    public PageInfo<HasDeliverResp> getHasDeliveredList(HasDeliverSearchReq hasDeliverSearchReq) {
    PageHelper.startPage(hasDeliverSearchReq.getPageNum(),hasDeliverSearchReq.getPageSize());
    Page<HasDeliverResp> hasDeliveredList = tOrderLocalSpeMapperExt.getHasDeliveredList(hasDeliverSearchReq);
    int total = (int) new PageInfo<>(hasDeliveredList).getTotal();
    PageInfo<HasDeliverResp> pageInfo = new PageInfo<HasDeliverResp>(hasDeliveredList);
    pageInfo.setTotal(total);



    return pageInfo;
     
  • 相关阅读:
    servlet
    grep命令
    sort排序命令
    shell脚本面试
    查看远端的端口是否通畅3个简单实用案例!
    mail命令
    linux系统优化的方法
    shell数组
    shell函数介绍语法说明及基本例子
    循环结构的多个控制命令对比与实际案例
  • 原文地址:https://www.cnblogs.com/yangsanluo/p/15775730.html
Copyright © 2011-2022 走看看