!407 【轻量级 PR】优化第三方认证授权绑定

Merge pull request !407 from MichelleChung/5.X
feature/model
疯狂的狮子Li 1 year ago committed by Gitee
commit 776b235cec
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -26,6 +26,7 @@ import org.dromara.common.tenant.exception.TenantException;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.bo.SysSocialBo;
import org.dromara.system.domain.vo.SysSocialVo;
import org.dromara.system.domain.vo.SysTenantVo;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.mapper.SysUserMapper;
@ -69,14 +70,25 @@ public class SysLoginService {
* @return
*/
public void socialRegister(AuthUser authUserData) {
String authId = authUserData.getSource() + authUserData.getUuid();
// 第三方用户信息
SysSocialBo bo = BeanUtil.toBean(authUserData, SysSocialBo.class);
BeanUtil.copyProperties(authUserData.getToken(), bo);
bo.setUserId(LoginHelper.getUserId());
bo.setAuthId(authUserData.getSource() + authUserData.getUuid());
bo.setAuthId(authId);
bo.setOpenId(authUserData.getUuid());
bo.setUserName(authUserData.getUsername());
bo.setNickName(authUserData.getNickname());
// 查询是否已经绑定用户
SysSocialVo vo = sysSocialService.selectByAuthId(authId);
if (ObjectUtil.isEmpty(vo)) {
// 没有绑定用户, 新增用户信息
sysSocialService.insertByBo(bo);
} else {
// 更新用户信息
bo.setId(vo.getId());
sysSocialService.updateByBo(bo);
}
}

@ -33,6 +33,10 @@ public interface ISysSocialService {
*/
Boolean insertByBo(SysSocialBo bo);
/**
*
*/
Boolean updateByBo(SysSocialBo bo);
/**
*

@ -65,6 +65,15 @@ public class SysSocialServiceImpl implements ISysSocialService {
return flag;
}
/**
*
*/
@Override
public Boolean updateByBo(SysSocialBo bo) {
SysSocial update = MapstructUtils.convert(bo, SysSocial.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
*

Loading…
Cancel
Save