|
@@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert;
|
|
import cn.newfeifan.mall.framework.common.exception.ServiceException;
|
|
import cn.newfeifan.mall.framework.common.exception.ServiceException;
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
import cn.newfeifan.mall.framework.common.util.json.JsonUtils;
|
|
import cn.newfeifan.mall.framework.common.util.json.JsonUtils;
|
|
|
|
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
import cn.newfeifan.mall.module.system.api.social.dto.SocialUserBindReqDTO;
|
|
import cn.newfeifan.mall.module.system.api.social.dto.SocialUserBindReqDTO;
|
|
import cn.newfeifan.mall.module.system.api.social.dto.SocialUserRespDTO;
|
|
import cn.newfeifan.mall.module.system.api.social.dto.SocialUserRespDTO;
|
|
import cn.newfeifan.mall.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO;
|
|
import cn.newfeifan.mall.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO;
|
|
@@ -74,7 +75,7 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
Assert.notNull(socialUser, "社交用户不能为空");
|
|
Assert.notNull(socialUser, "社交用户不能为空");
|
|
|
|
|
|
// 社交用户可能之前绑定过别的用户,需要进行解绑
|
|
// 社交用户可能之前绑定过别的用户,需要进行解绑
|
|
- socialUserBindMapper.deleteByUserTypeAndSocialUserId(reqDTO.getUserType(), socialUser.getId());
|
|
|
|
|
|
+// socialUserBindMapper.deleteByUserTypeAndSocialUserId(reqDTO.getUserType(), socialUser.getId());
|
|
|
|
|
|
// 用户可能之前已经绑定过该社交类型,需要进行解绑
|
|
// 用户可能之前已经绑定过该社交类型,需要进行解绑
|
|
socialUserBindMapper.deleteByUserTypeAndUserIdAndSocialType(reqDTO.getUserType(), reqDTO.getUserId(),
|
|
socialUserBindMapper.deleteByUserTypeAndUserIdAndSocialType(reqDTO.getUserType(), reqDTO.getUserId(),
|
|
@@ -110,7 +111,7 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
// 获得社交用户
|
|
// 获得社交用户
|
|
SocialUserDO socialUser = socialUserMapper.selectById(socialUserBind.getSocialUserId());
|
|
SocialUserDO socialUser = socialUserMapper.selectById(socialUserBind.getSocialUserId());
|
|
Assert.notNull(socialUser, "社交用户不能为空");
|
|
Assert.notNull(socialUser, "社交用户不能为空");
|
|
- return new SocialUserRespDTO(socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
|
|
|
|
|
|
+ return new SocialUserRespDTO(socialUser.getId(),socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
|
|
socialUserBind.getUserId(),null);
|
|
socialUserBind.getUserId(),null);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -123,7 +124,7 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
// 获得绑定用户
|
|
// 获得绑定用户
|
|
SocialUserBindDO socialUserBind = socialUserBindMapper.selectByUserTypeAndSocialUserId(userType,
|
|
SocialUserBindDO socialUserBind = socialUserBindMapper.selectByUserTypeAndSocialUserId(userType,
|
|
socialUser.getId());
|
|
socialUser.getId());
|
|
- return new SocialUserRespDTO(socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
|
|
|
|
|
|
+ return new SocialUserRespDTO(socialUser.getId(),socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
|
|
socialUserBind != null ? socialUserBind.getUserId() : null,null);
|
|
socialUserBind != null ? socialUserBind.getUserId() : null,null);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -137,7 +138,7 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
List<SocialUserBindDO> socialUserBindDOS = socialUserBindMapper.selectsByUserTypeAndSocialUserId(userType,
|
|
List<SocialUserBindDO> socialUserBindDOS = socialUserBindMapper.selectsByUserTypeAndSocialUserId(userType,
|
|
socialUser.getId());
|
|
socialUser.getId());
|
|
List<Long> userIds = socialUserBindDOS.stream().map(SocialUserBindDO::getUserId).collect(Collectors.toList());
|
|
List<Long> userIds = socialUserBindDOS.stream().map(SocialUserBindDO::getUserId).collect(Collectors.toList());
|
|
- return new SocialUserRespDTO(socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
|
|
|
|
|
|
+ return new SocialUserRespDTO(socialUser.getId(),socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
|
|
null,userIds);
|
|
null,userIds);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -175,9 +176,9 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
}
|
|
}
|
|
Assert.notNull(authUser, "三方用户不能为空");
|
|
Assert.notNull(authUser, "三方用户不能为空");
|
|
|
|
|
|
- // 保存到 DB 中
|
|
|
|
|
|
+ // =====保存到 DB 中=====
|
|
socialUser = socialUserMapper.selectByTypeAndOpenid(socialType, authUser.getUuid());
|
|
socialUser = socialUserMapper.selectByTypeAndOpenid(socialType, authUser.getUuid());
|
|
- if (isFirst && socialUser == null) {
|
|
|
|
|
|
+ if ((isFirst && socialUser == null) || (!isFirst && !isRegister)) {
|
|
//首次登录就将code缓存到redis中
|
|
//首次登录就将code缓存到redis中
|
|
stringRedisTemplate.opsForValue().set("auth_user:" + code, JsonUtils.toJsonString(authUser) , 60 * 10 , TimeUnit.SECONDS);
|
|
stringRedisTemplate.opsForValue().set("auth_user:" + code, JsonUtils.toJsonString(authUser) , 60 * 10 , TimeUnit.SECONDS);
|
|
throw exception(AUTH_LOGIN_USER_IS_FIRST);
|
|
throw exception(AUTH_LOGIN_USER_IS_FIRST);
|
|
@@ -210,7 +211,8 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
}
|
|
}
|
|
String json = stringRedisTemplate.opsForValue().get("auth_user:" + code);
|
|
String json = stringRedisTemplate.opsForValue().get("auth_user:" + code);
|
|
if (json != null) {
|
|
if (json != null) {
|
|
- // 假设存在一个方法从JSON字符串中安全地解析AuthUser对象
|
|
|
|
|
|
+ stringRedisTemplate.delete("auth_user:" + code);
|
|
|
|
+ // 从JSON字符串中安全地解析AuthUser对象
|
|
return JSONObject.parseObject(json,AuthUser.class);
|
|
return JSONObject.parseObject(json,AuthUser.class);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -241,4 +243,9 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
return socialUserBindMapper.selectOne(SocialUserBindDO::getSocialUserId,socialUserDO.getId(),SocialUserBindDO::getUserId,userId) != null;
|
|
return socialUserBindMapper.selectOne(SocialUserBindDO::getSocialUserId,socialUserDO.getId(),SocialUserBindDO::getUserId,userId) != null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean wxBindIsMax(Long socialUserId) {
|
|
|
|
+ return socialUserBindMapper.selectCount(new LambdaQueryWrapperX<SocialUserBindDO>().eq(SocialUserBindDO::getSocialUserId,socialUserId)) >= 10;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|