diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/RemoteUserService.java b/ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/RemoteUserService.java index 723e462b..5fe237e1 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/RemoteUserService.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/org/dromara/system/api/RemoteUserService.java @@ -57,14 +57,6 @@ public interface RemoteUserService { */ XcxLoginUser getUserInfoByOpenid(String openid) throws UserException; - /** - * 校验用户名称是否唯一 - * - * @param remoteUserBo 用户信息 - * @return 结果 - */ - boolean checkUserNameUnique(RemoteUserBo remoteUserBo); - /** * 注册用户信息 * diff --git a/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java index 7e203e71..ccc5f590 100644 --- a/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java +++ b/ruoyi-auth/src/main/java/org/dromara/auth/service/SysLoginService.java @@ -136,10 +136,7 @@ public class SysLoginService { remoteUserBo.setNickName(username); remoteUserBo.setPassword(BCrypt.hashpw(password)); remoteUserBo.setUserType(userType); - // 校验用户名是否唯一 - if (!remoteUserService.checkUserNameUnique(remoteUserBo)) { - throw new UserException("user.register.save.error", username); - } + boolean regFlag = remoteUserService.registerUserInfo(remoteUserBo); if (!regFlag) { throw new UserException("user.register.error"); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteUserServiceImpl.java index 412a45fc..2297a5d5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/dubbo/RemoteUserServiceImpl.java @@ -143,11 +143,6 @@ public class RemoteUserServiceImpl implements RemoteUserService { return loginUser; } - @Override - public boolean checkUserNameUnique(RemoteUserBo remoteUserBo) { - return userService.checkUserNameUnique(MapstructUtils.convert(remoteUserBo, SysUserBo.class)); - } - @Override public Boolean registerUserInfo(RemoteUserBo remoteUserBo) throws UserException, ServiceException { SysUserBo sysUserBo = MapstructUtils.convert(remoteUserBo, SysUserBo.class); @@ -155,7 +150,11 @@ public class RemoteUserServiceImpl implements RemoteUserService { if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { throw new ServiceException("当前系统没有开启注册功能"); } - if (!userService.checkUserNameUnique(sysUserBo)) { + boolean exist = userMapper.exists(new LambdaQueryWrapper() + .eq(TenantHelper.isEnable(), SysUser::getTenantId, remoteUserBo.getTenantId()) + .eq(SysUser::getUserName, sysUserBo.getUserName()) + .ne(ObjectUtil.isNotNull(sysUserBo.getUserId()), SysUser::getUserId, sysUserBo.getUserId())); + if (exist) { throw new UserException("user.register.save.error", username); } return userService.registerUser(sysUserBo, remoteUserBo.getTenantId());