Commit f82147af f82147af6645adfad53c9e1e3836eb192e3364ef by xianghan

1.绑定第三方账号时不允许绑定多个app账号

1 parent 347e9461
......@@ -28,13 +28,13 @@ public class UserAppBuilder {
userApp.setTags(resource.getTags());
userApp.setLastActiveTime(TimestampUtil.now());
userApp.setEmail(resource.getEmail());
userApp.setType(Objects.isNull(resource.getType()) ? resource.getType() : -1);
userApp.setType(Objects.isNull(resource.getType()) ? -1 : resource.getType());
userApp.setNickname(StringUtils.isNotBlank(resource.getNickname()) ? resource.getNickname() : resource.getUsername());
userApp.setHeadimgurl(resource.getHeadimgurl());
userApp.setPassword(resource.getPassword());
userApp.setCellphone(StringUtils.isNotBlank(resource.getCellphone()) ? resource.getCellphone() : resource.getUsername());
userApp.setBirthday(StringUtils.isNotBlank(resource.getBirthday()) ? resource.getBirthday() : "1900-01-01");
userApp.setGender(Objects.nonNull(resource.getGender()) ? resource.getGender() : 0);
userApp.setBirthday(StringUtils.isNotBlank(resource.getBirthday()) ? resource.getBirthday() : null);
userApp.setGender(Objects.nonNull(resource.getGender()) ? resource.getGender() : -1);
userApp.setStatus(UserAppStatusConstant.VALID_STATUS);
userApp.setCreateTime(null);
userApp.setUpdateTime(null);
......
......@@ -211,8 +211,7 @@ public class UserOperationController {
return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号类型不得为空");
}
boolean result = this.userOperationService.appBindThirdAccount(resources);
return ResultInfo.success(result);
return this.userOperationService.appBindThirdAccount(resources);
}
@Log
......
......@@ -76,6 +76,7 @@ public interface UserOperationService {
*/
boolean subscribe(SubscribeBean resources);
/**
* 微信公众号取关
* @param resources
......@@ -193,7 +194,7 @@ public interface UserOperationService {
* @param resources
* @return
*/
boolean appBindThirdAccount(UserAppBind resources);
ResultInfo appBindThirdAccount(UserAppBind resources);
/**
*
......
......@@ -181,7 +181,7 @@ public class UserOperationServiceImpl implements UserOperationService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean appBindThirdAccount(UserAppBind resources) {
public ResultInfo appBindThirdAccount(UserAppBind resources) {
String username = resources.getUsername();
String headImgUrl = resources.getHeadimgurl();
String nickname = resources.getNickname();
......@@ -189,7 +189,31 @@ public class UserOperationServiceImpl implements UserOperationService {
UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
log.info("通过app账号查询app信息是否存在,[appBindThirdAccount#{}]", userAppDTO);
if (Objects.isNull(userAppDTO.getId())) {
return false;
return ResultInfo.failure("绑定第三方账号失败,app账号不存在[appBindThirdAccount#{}]");
}
String account = resources.getAccount();
Integer accountType = resources.getAccountType();
UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
if (Objects.nonNull(userAppBindDTO.getId()) && userAppBindDTO.getStatus() == 1 && Objects.nonNull(userAppBindDTO.getUserAppId())) {
Integer bindAccountType = userAppBindDTO.getAccountType();
String accountStr = "";
switch (bindAccountType) {
case 3:
accountStr = "微信";
break;
case 4:
accountStr = "QQ";
break;
case 5:
accountStr = "微博";
break;
case 6:
accountStr = "苹果账号";
break;
}
return ResultInfo.failure("绑定失败,当前"+accountStr+"已经绑定了其他手机号");
}
if (Objects.isNull(userAppDTO.getHeadimgurl())) {
......@@ -211,9 +235,6 @@ public class UserOperationServiceImpl implements UserOperationService {
}
}
String account = resources.getAccount();
Integer accountType = resources.getAccountType();
UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
if (Objects.nonNull(userAppBindDTO.getId())) {
resources.setUserAppId(userAppDTO.getId());
boolean result = this.userAppBindService.updateValidStatusAndUserAppIdAndNickname(resources);
......@@ -224,7 +245,7 @@ public class UserOperationServiceImpl implements UserOperationService {
userAppDTO1.setHeadimgurl(headImgUrl);
((UserOperationServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(userAppDTO1);
}
return result;
return ResultInfo.failure("绑定第三方账号失败,app账号不存在[appBindThirdAccount#{}]");
} else {
resources.setUserAppId(userAppDTO.getId());
resources.setStatus(1);
......@@ -235,7 +256,7 @@ public class UserOperationServiceImpl implements UserOperationService {
BeanUtils.copyProperties(resources, userAppDTO1);
userAppDTO1.setUsername(username);
((UserOperationServiceImpl) AopContext.currentProxy()).asyncCreateUserAppBindThirdAccount(userAppDTO1);
return true;
return ResultInfo.success("操作成功");
}
}
......
package com.topdraw.test.business.process.rest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.BaseTest;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.process.domian.weixin.BindBean;
import com.topdraw.business.process.domian.weixin.SubscribeBean;
import com.topdraw.business.process.domian.weixin.TvUnBindBean;
import com.topdraw.business.process.domian.weixin.WeixinUnBindBean;
import com.topdraw.business.process.rest.UserOperationController;
......@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Base64Utils;
import java.sql.Timestamp;
import java.util.HashMap;
public class UserOperationControllerTest extends BaseTest {
......