diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 0fc61c15..d91ce874 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -384,7 +384,7 @@ public class AccountServiceImpl extends ServiceImpl impl if (Objects.isNull(authenticationOperationTypeEnum)) { throw new BusinessException("unknown.authentication.operation.type"); } - Account emailAccount = getOneByEmail(emailSendDTO.getEmail()); +// Account emailAccount = getOneByEmail(emailSendDTO.getEmail()); String randomVerifyCode = RandomsUtil.generateVerifyCode(100000L, 999999L); LocalCacheUtils.setVerifyCodeCache( emailSendDTO.getOperationType() + "_" + emailSendDTO.getEmail(), randomVerifyCode); @@ -403,6 +403,12 @@ public class AccountServiceImpl extends ServiceImpl impl SendEmailUtil.EXCEPTION_ID_TEMPLATE_ID, randomVerifyCode); break; case BIND_MAILBOX: + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(Account::getUserEmail, emailSendDTO.getEmail()); + List accounts = accountMapper.selectList(qw); + if (CollectionUtil.isNotEmpty(accounts)) { + throw new BusinessException("This email has been bound"); + } result = SendEmailUtil.send(emailSendDTO.getEmail(), null, SendEmailUtil.BIND_MAILBOX_TEMPLATE_ID, randomVerifyCode); break; @@ -2468,6 +2474,14 @@ public class AccountServiceImpl extends ServiceImpl impl String name = (String) payload.get("name"); String pictureUrl = (String) payload.get("picture"); + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(AccountExtend::getAuth, userId); + qw.lambda().eq(AccountExtend::getAuthType, "Google"); + List accountExtends = accountExtendMapper.selectList(qw); + + if (CollectionUtil.isNotEmpty(accountExtends)) { + throw new BusinessException("The Google has been bound."); + } AccountExtend accountExtendInsert = new AccountExtend(); accountExtendInsert.setAuth(userId); @@ -2512,6 +2526,15 @@ public class AccountServiceImpl extends ServiceImpl impl if (unionId == null) { throw new IllegalArgumentException("无法获取 unionid,请检查微信开发平台配置"); } + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(AccountExtend::getAuth, unionId); + qw.lambda().eq(AccountExtend::getAuthType, "WeChat"); + List accountExtends = accountExtendMapper.selectList(qw); + + if (CollectionUtil.isNotEmpty(accountExtends)) { + throw new BusinessException("The WeChat has been bound."); + } + AccountExtend accountExtendInsert = new AccountExtend(); accountExtendInsert.setAuth(unionId); accountExtendInsert.setAuthType("WeChat");