|
@@ -66,6 +66,16 @@ public class SocialAccountServiceImpl implements SocialAccountService {
|
|
|
return socialAccountsMapper.selectByExample(example);
|
|
|
}
|
|
|
|
|
|
+ public SocialAccounts selectByMemberIdAndProvider(String userId, Integer provider){
|
|
|
+ SocialAccountsExample example = new SocialAccountsExample();
|
|
|
+ example.createCriteria().andMemberIdEqualTo(userId).andProviderEqualTo(provider);
|
|
|
+ List<SocialAccounts> list = socialAccountsMapper.selectByExample(example);
|
|
|
+ if(!CollectionUtils.isEmpty(list)){
|
|
|
+ return list.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void deleteByMemberId(String memberId) {
|
|
|
SocialAccountsExample example = new SocialAccountsExample();
|
|
@@ -149,30 +159,12 @@ public class SocialAccountServiceImpl implements SocialAccountService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String unbindSocialAccount(Members currentUser, BindAccountParam param, SocialAccountVo accountVo) {
|
|
|
- String accountId = "";
|
|
|
- String accessToken = param.getAccessToken();
|
|
|
- String openid = param.getOpenid();
|
|
|
- String provider = param.getProvider();
|
|
|
+ public void unbindSocialAccount(Members currentUser, String provider, SocialAccountVo accountVo) {
|
|
|
accountVo.setProvider(provider);
|
|
|
SocialAccountsExample example = new SocialAccountsExample();
|
|
|
- if(ProviderEnum.TENCENT.getName().equals(provider)){
|
|
|
- Tencent userInfo = TencentUtils.getUserInfo(accessToken);
|
|
|
- String unionId = userInfo.getUnionId();
|
|
|
- accountId = unionId;
|
|
|
- SocialAccounts socialAccount = selectByAccountId(accountId);
|
|
|
- BeanUtils.copyProperties(socialAccount,accountVo);
|
|
|
- example.createCriteria().andAccountIdEqualTo(unionId);
|
|
|
- socialAccountsMapper.deleteByExample(example);
|
|
|
- } else {
|
|
|
- Wechat userInfo = WechatUtils.getUserInfo(openid, accessToken);
|
|
|
- String unionId = userInfo.getUnionId();
|
|
|
- accountId = unionId;
|
|
|
- SocialAccounts socialAccount = selectByAccountId(unionId);
|
|
|
- BeanUtils.copyProperties(socialAccount,accountVo);
|
|
|
- example.createCriteria().andAccountIdEqualTo(unionId);
|
|
|
- socialAccountsMapper.deleteByExample(example);
|
|
|
- }
|
|
|
- return accountId;
|
|
|
+ SocialAccounts socialAccount = selectByMemberIdAndProvider(currentUser.getId(), ProviderEnum.getCodeByName(provider));
|
|
|
+ BeanUtils.copyProperties(socialAccount,accountVo);
|
|
|
+ example.createCriteria().andAccountIdEqualTo(socialAccount.getAccountId());
|
|
|
+ socialAccountsMapper.deleteByExample(example);
|
|
|
}
|
|
|
}
|