com.healthy.common.security.social.SocialController Maven / Gradle / Ivy
package com.healthy.common.security.social;
import com.healthy.common.security.social.support.SocialUserInfo;
import org.springframework.social.connect.Connection;
import java.util.Objects;
/**
* SocialController
*
* @author xiaomingzhang
*/
public abstract class SocialController {
/**
* 根据Connection信息构建SocialUserInfo
*
* @param connection
* @return
*/
protected SocialUserInfo buildSocialUserInfo(Connection> connection) {
SocialUserInfo userInfo = null;
if (Objects.nonNull(connection)) {
userInfo = new SocialUserInfo();
userInfo.setProviderId(connection.getKey().getProviderId());
userInfo.setProviderUserId(connection.getKey().getProviderUserId());
userInfo.setNickname(connection.getDisplayName());
userInfo.setHeadImg(connection.getImageUrl());
}
return userInfo;
}
}