Search in sources :

Example 1 with AdditionalUserInfoEnricher

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);
        }
    }
}
Also used : UserInfo(com.ctrip.framework.apollo.portal.entity.bo.UserInfo) AdditionalUserInfoEnricher(com.ctrip.framework.apollo.portal.enricher.AdditionalUserInfoEnricher) UserInfoEnrichedAdapter(com.ctrip.framework.apollo.portal.enricher.adapter.UserInfoEnrichedAdapter)

Aggregations

AdditionalUserInfoEnricher (com.ctrip.framework.apollo.portal.enricher.AdditionalUserInfoEnricher)1 UserInfoEnrichedAdapter (com.ctrip.framework.apollo.portal.enricher.adapter.UserInfoEnrichedAdapter)1 UserInfo (com.ctrip.framework.apollo.portal.entity.bo.UserInfo)1