add 新增 SysSocialServiceImpl#updateByBo 更新社会化关系 ;

update 优化 SysLoginService#socialRegister 对已绑定用户进行更新 ;
reset 回滚上一提交中 SysSocialServiceImpl#selectByAuthId 会导致多种数据库不兼容 ;
feature/model
zlyx 1 year ago
parent c92c99c8da
commit bbe672208f

@ -71,18 +71,23 @@ public class SysLoginService {
*/
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(authId);
bo.setOpenId(authUserData.getUuid());
bo.setUserName(authUserData.getUsername());
bo.setNickName(authUserData.getNickname());
// 查询是否已经绑定用户
SysSocialVo vo = sysSocialService.selectByAuthId(authId);
if (ObjectUtil.isEmpty(vo)) {
// 没有绑定用户, 新增用户信息
SysSocialBo bo = BeanUtil.toBean(authUserData, SysSocialBo.class);
BeanUtil.copyProperties(authUserData.getToken(), bo);
bo.setUserId(LoginHelper.getUserId());
bo.setAuthId(authId);
bo.setOpenId(authUserData.getUuid());
bo.setUserName(authUserData.getUsername());
bo.setNickName(authUserData.getNickname());
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);
/**
*

@ -3,7 +3,6 @@ package org.dromara.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.system.domain.SysSocial;
import org.dromara.system.domain.bo.SysSocialBo;
import org.dromara.system.domain.vo.SysSocialVo;
@ -66,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;
}
/**
*
@ -92,11 +100,7 @@ public class SysSocialServiceImpl implements ISysSocialService {
*/
@Override
public SysSocialVo selectByAuthId(String authId) {
return baseMapper.selectVoOne(
new LambdaQueryWrapper<SysSocial>()
.eq(SysSocial::getAuthId, authId)
.orderByDesc(BaseEntity::getCreateTime)
.last("limit 1"));
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getAuthId, authId));
}
}

Loading…
Cancel
Save