Commit f82147af f82147af6645adfad53c9e1e3836eb192e3364ef by xianghan

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

1 parent 347e9461
...@@ -28,13 +28,13 @@ public class UserAppBuilder { ...@@ -28,13 +28,13 @@ public class UserAppBuilder {
28 userApp.setTags(resource.getTags()); 28 userApp.setTags(resource.getTags());
29 userApp.setLastActiveTime(TimestampUtil.now()); 29 userApp.setLastActiveTime(TimestampUtil.now());
30 userApp.setEmail(resource.getEmail()); 30 userApp.setEmail(resource.getEmail());
31 userApp.setType(Objects.isNull(resource.getType()) ? resource.getType() : -1); 31 userApp.setType(Objects.isNull(resource.getType()) ? -1 : resource.getType());
32 userApp.setNickname(StringUtils.isNotBlank(resource.getNickname()) ? resource.getNickname() : resource.getUsername()); 32 userApp.setNickname(StringUtils.isNotBlank(resource.getNickname()) ? resource.getNickname() : resource.getUsername());
33 userApp.setHeadimgurl(resource.getHeadimgurl()); 33 userApp.setHeadimgurl(resource.getHeadimgurl());
34 userApp.setPassword(resource.getPassword()); 34 userApp.setPassword(resource.getPassword());
35 userApp.setCellphone(StringUtils.isNotBlank(resource.getCellphone()) ? resource.getCellphone() : resource.getUsername()); 35 userApp.setCellphone(StringUtils.isNotBlank(resource.getCellphone()) ? resource.getCellphone() : resource.getUsername());
36 userApp.setBirthday(StringUtils.isNotBlank(resource.getBirthday()) ? resource.getBirthday() : "1900-01-01"); 36 userApp.setBirthday(StringUtils.isNotBlank(resource.getBirthday()) ? resource.getBirthday() : null);
37 userApp.setGender(Objects.nonNull(resource.getGender()) ? resource.getGender() : 0); 37 userApp.setGender(Objects.nonNull(resource.getGender()) ? resource.getGender() : -1);
38 userApp.setStatus(UserAppStatusConstant.VALID_STATUS); 38 userApp.setStatus(UserAppStatusConstant.VALID_STATUS);
39 userApp.setCreateTime(null); 39 userApp.setCreateTime(null);
40 userApp.setUpdateTime(null); 40 userApp.setUpdateTime(null);
......
...@@ -211,8 +211,7 @@ public class UserOperationController { ...@@ -211,8 +211,7 @@ public class UserOperationController {
211 return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号类型不得为空"); 211 return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号类型不得为空");
212 } 212 }
213 213
214 boolean result = this.userOperationService.appBindThirdAccount(resources); 214 return this.userOperationService.appBindThirdAccount(resources);
215 return ResultInfo.success(result);
216 } 215 }
217 216
218 @Log 217 @Log
......
...@@ -76,6 +76,7 @@ public interface UserOperationService { ...@@ -76,6 +76,7 @@ public interface UserOperationService {
76 */ 76 */
77 boolean subscribe(SubscribeBean resources); 77 boolean subscribe(SubscribeBean resources);
78 78
79
79 /** 80 /**
80 * 微信公众号取关 81 * 微信公众号取关
81 * @param resources 82 * @param resources
...@@ -193,7 +194,7 @@ public interface UserOperationService { ...@@ -193,7 +194,7 @@ public interface UserOperationService {
193 * @param resources 194 * @param resources
194 * @return 195 * @return
195 */ 196 */
196 boolean appBindThirdAccount(UserAppBind resources); 197 ResultInfo appBindThirdAccount(UserAppBind resources);
197 198
198 /** 199 /**
199 * 200 *
......
...@@ -181,7 +181,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -181,7 +181,7 @@ public class UserOperationServiceImpl implements UserOperationService {
181 181
182 @Override 182 @Override
183 @Transactional(rollbackFor = Exception.class) 183 @Transactional(rollbackFor = Exception.class)
184 public boolean appBindThirdAccount(UserAppBind resources) { 184 public ResultInfo appBindThirdAccount(UserAppBind resources) {
185 String username = resources.getUsername(); 185 String username = resources.getUsername();
186 String headImgUrl = resources.getHeadimgurl(); 186 String headImgUrl = resources.getHeadimgurl();
187 String nickname = resources.getNickname(); 187 String nickname = resources.getNickname();
...@@ -189,7 +189,31 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -189,7 +189,31 @@ public class UserOperationServiceImpl implements UserOperationService {
189 UserAppDTO userAppDTO = this.userAppService.findByUsername(username); 189 UserAppDTO userAppDTO = this.userAppService.findByUsername(username);
190 log.info("通过app账号查询app信息是否存在,[appBindThirdAccount#{}]", userAppDTO); 190 log.info("通过app账号查询app信息是否存在,[appBindThirdAccount#{}]", userAppDTO);
191 if (Objects.isNull(userAppDTO.getId())) { 191 if (Objects.isNull(userAppDTO.getId())) {
192 return false; 192 return ResultInfo.failure("绑定第三方账号失败,app账号不存在[appBindThirdAccount#{}]");
193 }
194
195 String account = resources.getAccount();
196 Integer accountType = resources.getAccountType();
197 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
198 if (Objects.nonNull(userAppBindDTO.getId()) && userAppBindDTO.getStatus() == 1 && Objects.nonNull(userAppBindDTO.getUserAppId())) {
199 Integer bindAccountType = userAppBindDTO.getAccountType();
200 String accountStr = "";
201 switch (bindAccountType) {
202 case 3:
203 accountStr = "微信";
204 break;
205 case 4:
206 accountStr = "QQ";
207 break;
208 case 5:
209 accountStr = "微博";
210 break;
211 case 6:
212 accountStr = "苹果账号";
213 break;
214
215 }
216 return ResultInfo.failure("绑定失败,当前"+accountStr+"已经绑定了其他手机号");
193 } 217 }
194 218
195 if (Objects.isNull(userAppDTO.getHeadimgurl())) { 219 if (Objects.isNull(userAppDTO.getHeadimgurl())) {
...@@ -211,9 +235,6 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -211,9 +235,6 @@ public class UserOperationServiceImpl implements UserOperationService {
211 } 235 }
212 } 236 }
213 237
214 String account = resources.getAccount();
215 Integer accountType = resources.getAccountType();
216 UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
217 if (Objects.nonNull(userAppBindDTO.getId())) { 238 if (Objects.nonNull(userAppBindDTO.getId())) {
218 resources.setUserAppId(userAppDTO.getId()); 239 resources.setUserAppId(userAppDTO.getId());
219 boolean result = this.userAppBindService.updateValidStatusAndUserAppIdAndNickname(resources); 240 boolean result = this.userAppBindService.updateValidStatusAndUserAppIdAndNickname(resources);
...@@ -224,7 +245,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -224,7 +245,7 @@ public class UserOperationServiceImpl implements UserOperationService {
224 userAppDTO1.setHeadimgurl(headImgUrl); 245 userAppDTO1.setHeadimgurl(headImgUrl);
225 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(userAppDTO1); 246 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(userAppDTO1);
226 } 247 }
227 return result; 248 return ResultInfo.failure("绑定第三方账号失败,app账号不存在[appBindThirdAccount#{}]");
228 } else { 249 } else {
229 resources.setUserAppId(userAppDTO.getId()); 250 resources.setUserAppId(userAppDTO.getId());
230 resources.setStatus(1); 251 resources.setStatus(1);
...@@ -235,7 +256,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -235,7 +256,7 @@ public class UserOperationServiceImpl implements UserOperationService {
235 BeanUtils.copyProperties(resources, userAppDTO1); 256 BeanUtils.copyProperties(resources, userAppDTO1);
236 userAppDTO1.setUsername(username); 257 userAppDTO1.setUsername(username);
237 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncCreateUserAppBindThirdAccount(userAppDTO1); 258 ((UserOperationServiceImpl) AopContext.currentProxy()).asyncCreateUserAppBindThirdAccount(userAppDTO1);
238 return true; 259 return ResultInfo.success("操作成功");
239 } 260 }
240 } 261 }
241 262
......
1 package com.topdraw.test.business.process.rest; 1 package com.topdraw.test.business.process.rest;
2 2
3 import com.alibaba.fastjson.JSON;
3 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.BaseTest; 5 import com.topdraw.BaseTest;
5 import com.topdraw.business.module.user.app.domain.UserApp; 6 import com.topdraw.business.module.user.app.domain.UserApp;
6 import com.topdraw.business.module.user.iptv.domain.UserTv; 7 import com.topdraw.business.module.user.iptv.domain.UserTv;
7 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 8 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
8 import com.topdraw.business.process.domian.weixin.BindBean; 9 import com.topdraw.business.process.domian.weixin.BindBean;
10 import com.topdraw.business.process.domian.weixin.SubscribeBean;
9 import com.topdraw.business.process.domian.weixin.TvUnBindBean; 11 import com.topdraw.business.process.domian.weixin.TvUnBindBean;
10 import com.topdraw.business.process.domian.weixin.WeixinUnBindBean; 12 import com.topdraw.business.process.domian.weixin.WeixinUnBindBean;
11 import com.topdraw.business.process.rest.UserOperationController; 13 import com.topdraw.business.process.rest.UserOperationController;
...@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.util.Base64Utils; 17 import org.springframework.util.Base64Utils;
16 18
17 import java.sql.Timestamp; 19 import java.sql.Timestamp;
20 import java.util.HashMap;
18 21
19 public class UserOperationControllerTest extends BaseTest { 22 public class UserOperationControllerTest extends BaseTest {
20 23
......