|
|
@ -6,6 +6,7 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
|
|
|
import com.baomidou.lock.annotation.Lock4j;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import me.zhyd.oauth.model.AuthUser;
|
|
|
|
import me.zhyd.oauth.model.AuthUser;
|
|
|
@ -73,18 +74,23 @@ public class SysLoginService {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param authUserData 授权响应实体
|
|
|
|
* @param authUserData 授权响应实体
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Lock4j
|
|
|
|
public void socialRegister(AuthUser authUserData) {
|
|
|
|
public void socialRegister(AuthUser authUserData) {
|
|
|
|
String authId = authUserData.getSource() + authUserData.getUuid();
|
|
|
|
String authId = authUserData.getSource() + authUserData.getUuid();
|
|
|
|
// 第三方用户信息
|
|
|
|
// 第三方用户信息
|
|
|
|
RemoteSocialBo bo = BeanUtil.toBean(authUserData, RemoteSocialBo.class);
|
|
|
|
RemoteSocialBo bo = BeanUtil.toBean(authUserData, RemoteSocialBo.class);
|
|
|
|
BeanUtil.copyProperties(authUserData.getToken(), bo);
|
|
|
|
BeanUtil.copyProperties(authUserData.getToken(), bo);
|
|
|
|
bo.setUserId(LoginHelper.getUserId());
|
|
|
|
Long userId = LoginHelper.getUserId();
|
|
|
|
|
|
|
|
bo.setUserId(userId);
|
|
|
|
bo.setAuthId(authId);
|
|
|
|
bo.setAuthId(authId);
|
|
|
|
bo.setOpenId(authUserData.getUuid());
|
|
|
|
bo.setOpenId(authUserData.getUuid());
|
|
|
|
bo.setUserName(authUserData.getUsername());
|
|
|
|
bo.setUserName(authUserData.getUsername());
|
|
|
|
bo.setNickName(authUserData.getNickname());
|
|
|
|
bo.setNickName(authUserData.getNickname());
|
|
|
|
// 查询是否已经绑定用户
|
|
|
|
// 查询是否已经绑定用户
|
|
|
|
List<RemoteSocialVo> list = remoteSocialService.selectByAuthId(authId);
|
|
|
|
RemoteSocialBo params = new RemoteSocialBo();
|
|
|
|
|
|
|
|
params.setUserId(userId);
|
|
|
|
|
|
|
|
params.setSource(bo.getSource());
|
|
|
|
|
|
|
|
List<RemoteSocialVo> list = remoteSocialService.queryList(params);
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
// 没有绑定用户, 新增用户信息
|
|
|
|
// 没有绑定用户, 新增用户信息
|
|
|
|
remoteSocialService.insertByBo(bo);
|
|
|
|
remoteSocialService.insertByBo(bo);
|
|
|
@ -92,6 +98,8 @@ public class SysLoginService {
|
|
|
|
// 更新用户信息
|
|
|
|
// 更新用户信息
|
|
|
|
bo.setId(list.get(0).getId());
|
|
|
|
bo.setId(list.get(0).getId());
|
|
|
|
remoteSocialService.updateByBo(bo);
|
|
|
|
remoteSocialService.updateByBo(bo);
|
|
|
|
|
|
|
|
// 如果要绑定的平台账号已经被绑定过了 是否抛异常自行决断
|
|
|
|
|
|
|
|
// throw new ServiceException("此平台账号已经被绑定!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|