use of com.ctrip.framework.apollo.portal.enricher.adapter.UserInfoEnrichedAdapter 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);
}
}
}
use of com.ctrip.framework.apollo.portal.enricher.adapter.UserInfoEnrichedAdapter in project apollo by ctripcorp.
the class AdditionalUserInfoEnrichServiceImpl method adapt.
private <T> List<UserInfoEnrichedAdapter> adapt(List<? extends T> dtoList, Function<? super T, ? extends UserInfoEnrichedAdapter> mapper) {
List<UserInfoEnrichedAdapter> adapterList = new ArrayList<>(dtoList.size());
for (T dto : dtoList) {
if (dto == null) {
continue;
}
UserInfoEnrichedAdapter enrichedAdapter = mapper.apply(dto);
adapterList.add(enrichedAdapter);
}
return adapterList;
}
Aggregations