diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java index abef1551..6037e428 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java @@ -78,7 +78,7 @@ public class UserServiceImpl extends BaseServiceImpl implement if (Func.isNotEmpty(tenant)) { Integer accountNumber = tenant.getAccountNumber(); Integer tenantCount = baseMapper.selectCount(Wrappers.query().lambda().eq(User::getTenantId, tenantId)); - if (accountNumber != null && accountNumber > 0 && accountNumber < tenantCount) { + if (accountNumber != null && accountNumber > 0 && accountNumber <= tenantCount) { throw new ServiceException("当前租户已到最大账号额度!"); } } @@ -259,25 +259,20 @@ public class UserServiceImpl extends BaseServiceImpl implement @Override @Transactional(rollbackFor = Exception.class) public boolean registerGuest(User user, Long oauthId) { - R tenant = sysClient.getTenant(user.getTenantId()); - if (!tenant.isSuccess() || tenant.getData().getId() == null) { + Tenant tenant = SysCache.getTenant(user.getTenantId()); + if (tenant == null || tenant.getId() == null) { throw new ApiException("租户信息错误!"); } - int userCnt = this.count(Wrappers.query().lambda().eq(User::getTenantId, Func.toStr(user.getTenantId(), BladeConstant.ADMIN_TENANT_ID)).eq(User::getAccount, user.getAccount())); - if (userCnt > 0) { - throw new ApiException("当前系统用户名已存在!"); - } UserOauth userOauth = userOauthService.getById(oauthId); if (userOauth == null || userOauth.getId() == null) { throw new ApiException("第三方登陆信息错误!"); } user.setRealName(user.getName()); user.setAvatar(userOauth.getAvatar()); - user.setPassword(DigestUtil.encrypt(user.getPassword())); user.setRoleId(StringPool.MINUS_ONE); user.setDeptId(StringPool.MINUS_ONE); user.setPostId(StringPool.MINUS_ONE); - boolean userTemp = this.save(user); + boolean userTemp = this.submit(user); userOauth.setUserId(user.getId()); userOauth.setTenantId(user.getTenantId()); boolean oauthTemp = userOauthService.updateById(userOauth);