Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -51,7 +51,7 @@ public class AccountController {
|
||||
|
||||
@ApiOperation(value = "绑定邮箱")
|
||||
@PostMapping("/bindEmail")
|
||||
public Response<Boolean> bindEmail(@Valid @RequestBody AccountBindEmailDTO accountBindEmailDTO) {
|
||||
public Response<BindEmailVO> bindEmail(@Valid @RequestBody AccountBindEmailDTO accountBindEmailDTO) {
|
||||
return Response.success(accountService.bindEmail(accountBindEmailDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public interface AccountService extends IService<Account> {
|
||||
* @param accountBindEmailDTO
|
||||
* @return
|
||||
*/
|
||||
Boolean bindEmail(AccountBindEmailDTO accountBindEmailDTO);
|
||||
BindEmailVO bindEmail(AccountBindEmailDTO accountBindEmailDTO);
|
||||
|
||||
BindEmailVO bindEmail(String email);
|
||||
|
||||
|
||||
@@ -286,16 +286,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean bindEmail(AccountBindEmailDTO accountBindEmailDTO) {
|
||||
// Account account = baseMapper.selectById(accountBindEmailDTO.getUserId());
|
||||
public BindEmailVO bindEmail(AccountBindEmailDTO accountBindEmailDTO) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
Account account = accountMapper.selectById(userHolder.getId());
|
||||
|
||||
if (Objects.isNull(account)) {
|
||||
throw new BusinessException("userName.does.not.exist", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
// if (StringUtils.isNotBlank(account.getUserEmail())) {
|
||||
// throw new BusinessException("user.has.bound.mailbox");
|
||||
// }
|
||||
|
||||
//校验邮箱验证码
|
||||
String verifyCode = LocalCacheUtils.getVerifyCodeCache(AuthenticationOperationTypeEnum.BIND_MAILBOX.name() + "_" + accountBindEmailDTO.getUserEmail());
|
||||
if (StringUtils.isBlank(verifyCode)) {
|
||||
@@ -305,10 +303,37 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
throw new BusinessException("verification.code.error", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
//绑定
|
||||
account.setUserEmail(accountBindEmailDTO.getUserEmail());
|
||||
accountMapper.updateById(account);
|
||||
// updatePwdByUserId(accountBindEmailDTO.getUserEmail(), accountBindEmailDTO.getUserId());
|
||||
return Boolean.TRUE;
|
||||
|
||||
BindEmailVO result = new BindEmailVO();
|
||||
|
||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Account::getUserEmail, accountBindEmailDTO.getUserEmail());
|
||||
List<Account> accounts = accountMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(accounts)) {
|
||||
Account accountOld = accounts.get(0);
|
||||
|
||||
QueryWrapper<AccountExtend> accountExtendQW = new QueryWrapper<>();
|
||||
accountExtendQW.lambda().eq(AccountExtend::getAccountId, userHolder.getId());
|
||||
accountExtendQW.lambda().eq(AccountExtend::getAuthType, "Wechat");
|
||||
AccountExtend accountExtend = accountExtendMapper.selectOne(accountExtendQW);
|
||||
accountExtend.setAccountId(accountOld.getId());
|
||||
accountExtendMapper.updateById(accountExtend);
|
||||
|
||||
accountMapper.deleteById(userHolder.getId());
|
||||
|
||||
String token = LocalCacheUtils.getTokenCache(String.valueOf(accountOld.getId()));
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
//用户已登入
|
||||
result.setToken(token);
|
||||
} else {
|
||||
result.setToken(createAccountToken(accountOld));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Account accountNew = accountMapper.selectById(userHolder.getId());
|
||||
accountNew.setUserEmail(accountBindEmailDTO.getUserEmail());
|
||||
accountMapper.updateById(accountNew);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
Reference in New Issue
Block a user