|
@@ -23,6 +23,10 @@ public class UserClientUtil {
|
|
|
* @return MAP<用户id, 用户名称>
|
|
|
*/
|
|
|
public static Map<Long, String> getUserNameMap(List<Long> userIdList) {
|
|
|
+ if (userIdList == null || userIdList.size() == 0) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
R<Map<Long, String>> r = userSearchClient.mapByUser(userIdList);
|
|
|
if (r.getCode() == ResultCode.SUCCESS.getCode()) {
|
|
|
return r.getData();
|
|
@@ -38,15 +42,10 @@ public class UserClientUtil {
|
|
|
* @return MAP<用户id, 用户名称>
|
|
|
*/
|
|
|
public static <T> Map<Long, String> getUserNameMapFunctionLong(List<T> list, Function<T, Long> mapper) {
|
|
|
-
|
|
|
- List<Long> userIdList = list.stream().map(mapper).distinct().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
-
|
|
|
- R<Map<Long, String>> r = userSearchClient.mapByUser(userIdList);
|
|
|
-
|
|
|
- if (r.getCode() != ResultCode.SUCCESS.getCode()) {
|
|
|
- return new HashMap<>();
|
|
|
- }
|
|
|
- return r.getData();
|
|
|
+ List<Long> userIdList = list.stream().map(mapper)
|
|
|
+ .distinct().filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return getUserNameMap(userIdList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -61,17 +60,12 @@ public class UserClientUtil {
|
|
|
List<List<Long>> userIdsList = list.stream().map(mapper).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> userIdList = new ArrayList<>();
|
|
|
- for (List<Long> item : userIdsList) {
|
|
|
- userIdList.addAll(item);
|
|
|
- }
|
|
|
- userIdList = userIdList.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
|
|
|
- R<Map<Long, String>> r = userSearchClient.mapByUser(userIdList);
|
|
|
+ userIdsList.forEach(userIdList::addAll);
|
|
|
|
|
|
- if (r.getCode() != ResultCode.SUCCESS.getCode()) {
|
|
|
- return new HashMap<>();
|
|
|
- }
|
|
|
- return r.getData();
|
|
|
+ userIdList = userIdList.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ return getUserNameMap(userIdList);
|
|
|
}
|
|
|
|
|
|
}
|