List<Friends> result = new ArrayList< >();
result = friendsRepository.queryFollow(userId,status);
if(result == null || result.size() ==0){
return result;
}else {
// result先去重
List<Friends> unique = result.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Friends::getToUserId))), ArrayList::new)
);
List<Long> userIdList = result.stream().map(Friends -> Friends.getToUserId()).collect(Collectors.toList());
//批量查询
List<User> userList = UserUtil.getUserList(userIdList);
List<Friends> list = new ArrayList<Friends>();
final Map<Long, Friends> friendMap = result.stream().collect(Collectors.toMap(Friends::getToUserId, Function.identity()));
list = userList.stream().map(h -> {
Friends friend = friendMap.get(h.getUserId());
friend.setToNickname(h.getNickname());
friend.setUserType(h.getUserType());
friend.setLang(h.getLang());
friend.setTelephone(h.getTelephone());
friend.setAreacode(h.getAreaCode());
friend.setSignature( truncate(h.getSignature(),30) );
friend.setAccid(h.getAccid());
friend.setAvatarUrl(h.getAvatarUrl());
return friend;
}).collect(Collectors.toList());
return list;
}