//构建条件 QueryWrapper<ErpGroup> wrapper = new QueryWrapper<>(); // wrapper.eq("deleted","0"); String username = userAuthUtil.getUserName().get(); if(!username.equals("admin")){ Long user_id = userAuthUtil.getUserId().get(); List<ErpGroupMember> erpGroupMemberList = erpGroupMemberService.getErpGroupMemberByUserId(user_id); // Long[] id_arr = new Long[erpGroupMemberList.size()]; // for(int i=0;i<erpGroupMemberList.size();i++){ // id_arr[i]=erpGroupMemberList.get(i).getGroupId(); // } // List<Long> idList=Arrays.asList(id_arr); // List<Long> idList = new ArrayList<>(); // erpGroupMemberList .forEach(n -> idList.add(n.getGroupId())); // wrapper.in("id", idList); // queryWrapper.and(Wrapper -> Wrapper.eq(PcmArticle::getAuState, "1").or().eq(PcmArticle::getAuState, "2")); // QueryWrapper<ErpGroup> like_wrapper = new QueryWrapper<>(); // for(int i=0;i<erpGroupMemberList.size();i++){ // Long group_id = erpGroupMemberList.get(i).getGroupId(); // ErpGroup erpGroup = baseMapper.selectById(group_id); // String group_path = erpGroup.getPath(); // if(like_wrapper.isEmptyOfWhere()){ // like_wrapper.likeRight("path",erpGroup.getPath()); // }else{ // like_wrapper.or().likeRight("path",erpGroup.getPath()); // } // } // wrapper.and((Consumer<QueryWrapper<ErpGroup>>) like_wrapper); wrapper.and(wr->{ // String[] deviceIds = StringUtils.split(deviceIdArr, ","); // Arrays.stream(deviceIds).forEach(e->{ // wr.eq("id", e).or(); // }); // for(int i=0;i<erpGroupMemberList.size();i++){ //// ErpGroup erpGroup = baseMapper.selectById( erpGroupMemberList.get(i).getGroupId()); //// if(wr.isEmptyOfWhere()){ //// wr.likeRight("path",erpGroup.getPath()); //// }else{ //// wr.or().likeRight("path",erpGroup.getPath()); //// } //// } erpGroupMemberList.forEach(e->{ wr.likeRight("path",baseMapper.selectById(e.getGroupId()).getPath()).or(); }); }); } Long id = erpGroupQuery.getId(); if(id != null) wrapper.eq("id", id); if (!StringUtils.isEmpty(erpGroupQuery.getCode())){ wrapper.eq("code", erpGroupQuery.getCode()); } if (!StringUtils.isEmpty(erpGroupQuery.getName())){ wrapper.eq("name", erpGroupQuery.getName()); } Long parentId = erpGroupQuery.getParentId(); if(parentId != null) wrapper.eq("parent_id", parentId); if (!StringUtils.isEmpty(erpGroupQuery.getPath())){ wrapper.like("name", erpGroupQuery.getPath()); } if (!StringUtils.isEmpty(erpGroupQuery.getType())){ wrapper.eq("type", erpGroupQuery.getType()); } Integer groupType = erpGroupQuery.getGroupType(); if(groupType != null) wrapper.eq("group_type", groupType); if (!StringUtils.isEmpty(erpGroupQuery.getDescription())){ wrapper.eq("description", erpGroupQuery.getDescription()); } Long ownership = erpGroupQuery.getOwnership(); if(ownership != null) wrapper.eq("ownership", ownership); Boolean status = erpGroupQuery.getStatus(); if(status != null) wrapper.eq("status", status); return baseMapper.selectList(wrapper);