Zakariyya / blog

https://zakariyya.github.io/blog/
6 stars 1 forks source link

把查到的数据,根据getValue()过滤,筛选出getValue()为null的值,然后以 getId(),组装成List #157

Open Zakariyya opened 1 year ago

Zakariyya commented 1 year ago

功能: 把查到的数据,根据getValue()过滤,筛选出getValue()为null的值,然后以 getId(),组装成List


    List<MaterialAttribute> findByPid = this.list(new MaterialAttribute().setParentId(oneById.getId()).queryWrapper());
    List<MaterialAttribute> filterList = new ArrayList();
    List<Long> idList = new ArrayList();
    findByPid.forEach(x->{
      if(StringUtils.isEmpty(x.getValue())){
        filterList.add(x);
      }
    });
    filterList.forEach(x->{
      idList.add(x.getId());
    });
//    return idList;
//----------------------------------------------------------------------------------------------------------------------------------------
    List<Long> collect = ((List<MaterialAttribute>) this.list(new MaterialAttribute().setParentId(oneById.getId()).queryWrapper())).stream()
      .filter(x -> StringUtil.isEmpty(x.getValue())).collect(Collectors.toList()).stream().map(MaterialAttribute::getId).collect(Collectors.toList());
//    return collect;