use of com.ctrip.framework.apollo.portal.enricher.AdditionalUserInfoEnricher in project apollo by ctripcorp.
the class AdditionalUserInfoEnrichServiceImpl method enrichAdditionalUserInfo.
@Override
public <T> void enrichAdditionalUserInfo(List<? extends T> list, Function<? super T, ? extends UserInfoEnrichedAdapter> mapper) {
if (CollectionUtils.isEmpty(list)) {
return;
}
if (CollectionUtils.isEmpty(this.enricherList)) {
return;
}
List<UserInfoEnrichedAdapter> adapterList = this.adapt(list, mapper);
if (CollectionUtils.isEmpty(adapterList)) {
return;
}
Set<String> userIdSet = this.extractOperatorId(adapterList);
if (CollectionUtils.isEmpty(userIdSet)) {
return;
}
List<UserInfo> userInfoList = this.userService.findByUserIds(new ArrayList<>(userIdSet));
if (CollectionUtils.isEmpty(userInfoList)) {
return;
}
Map<String, UserInfo> userInfoMap = userInfoList.stream().collect(Collectors.toMap(UserInfo::getUserId, Function.identity()));
for (UserInfoEnrichedAdapter adapter : adapterList) {
for (AdditionalUserInfoEnricher enricher : this.enricherList) {
enricher.enrichAdditionalUserInfo(adapter, userInfoMap);
}
}
}
Aggregations