update 优化 SysLoginService#socialRegister 判断是否已经绑定用户 ;

add 新增 RemoteSocialServiceImpl#updateByBo 更新社会化关系 ;
2.X
Michelle.Chung 1 year ago
parent 83743b04b0
commit d3460a653e

@ -20,6 +20,11 @@ public interface RemoteSocialService {
*/
void insertByBo(RemoteSocialBo bo);
/**
*
*/
void updateByBo(RemoteSocialBo bo);
/**
*
*/

@ -31,6 +31,7 @@ import org.dromara.system.api.RemoteTenantService;
import org.dromara.system.api.RemoteUserService;
import org.dromara.system.api.domain.bo.RemoteSocialBo;
import org.dromara.system.api.domain.bo.RemoteUserBo;
import org.dromara.system.api.domain.vo.RemoteSocialVo;
import org.dromara.system.api.domain.vo.RemoteTenantVo;
import org.dromara.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
@ -66,14 +67,25 @@ public class SysLoginService {
* @param authUserData
*/
public void socialRegister(AuthUser authUserData) {
String authId = authUserData.getSource() + authUserData.getUuid();
// 第三方用户信息
RemoteSocialBo bo = BeanUtil.toBean(authUserData, RemoteSocialBo.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());
remoteSocialService.insertByBo(bo);
// 查询是否已经绑定用户
RemoteSocialVo vo = remoteSocialService.selectByAuthId(authId);
if (ObjectUtil.isEmpty(vo)) {
// 没有绑定用户, 新增用户信息
remoteSocialService.insertByBo(bo);
} else {
// 更新用户信息
bo.setId(vo.getId());
remoteSocialService.updateByBo(bo);
}
}
/**

@ -6,8 +6,10 @@ import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.system.api.RemoteSocialService;
import org.dromara.system.api.domain.bo.RemoteSocialBo;
import org.dromara.system.api.domain.vo.RemoteSocialVo;
import org.dromara.system.domain.SysSocial;
import org.dromara.system.domain.bo.SysSocialBo;
import org.dromara.system.domain.vo.SysSocialVo;
import org.dromara.system.mapper.SysSocialMapper;
import org.dromara.system.service.ISysSocialService;
import org.springframework.stereotype.Service;
@ -22,6 +24,7 @@ import org.springframework.stereotype.Service;
public class RemoteSocialServiceImpl implements RemoteSocialService {
private final ISysSocialService sysSocialService;
private final SysSocialMapper sysSocialMapper;
/**
* authId
@ -40,6 +43,15 @@ public class RemoteSocialServiceImpl implements RemoteSocialService {
sysSocialService.insertByBo(MapstructUtils.convert(bo, SysSocialBo.class));
}
/**
*
*/
@Override
public void updateByBo(RemoteSocialBo bo) {
SysSocial update = MapstructUtils.convert(bo, SysSocial.class);
sysSocialMapper.updateById(update);
}
/**
*
*/

Loading…
Cancel
Save