From e2b169e07ae5379e5490363e4d15320b7eb0c59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 25 Oct 2023 22:18:21 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=8E=A5=E5=8F=A3=E6=A0=A1=E9=AA=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8D=E4=B8=8D=E5=8C=BA=E5=88=86=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/web/service/SysRegisterService.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/java/org/dromara/web/service/SysRegisterService.java b/ruoyi-admin/src/main/java/org/dromara/web/service/SysRegisterService.java index 013773e5..4d4b0728 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/service/SysRegisterService.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/service/SysRegisterService.java @@ -1,6 +1,8 @@ package org.dromara.web.service; import cn.dev33.satoken.secure.BCrypt; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.dromara.common.core.constant.Constants; import org.dromara.common.core.constant.GlobalConstants; import org.dromara.common.core.domain.model.RegisterBody; @@ -14,8 +16,11 @@ import org.dromara.common.core.utils.SpringUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.log.event.LogininforEvent; import org.dromara.common.redis.utils.RedisUtils; +import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.common.web.config.properties.CaptchaProperties; +import org.dromara.system.domain.SysUser; import org.dromara.system.domain.bo.SysUserBo; +import org.dromara.system.mapper.SysUserMapper; import org.dromara.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -30,6 +35,7 @@ import org.springframework.stereotype.Service; public class SysRegisterService { private final ISysUserService userService; + private final SysUserMapper userMapper; private final CaptchaProperties captchaProperties; /** @@ -53,7 +59,11 @@ public class SysRegisterService { sysUser.setPassword(BCrypt.hashpw(password)); sysUser.setUserType(userType); - if (!userService.checkUserNameUnique(sysUser)) { + boolean exist = userMapper.exists(new LambdaQueryWrapper() + .eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId) + .eq(SysUser::getUserName, sysUser.getUserName()) + .ne(ObjectUtil.isNotNull(sysUser.getUserId()), SysUser::getUserId, sysUser.getUserId())); + if (exist) { throw new UserException("user.register.save.error", username); } boolean regFlag = userService.registerUser(sysUser, tenantId);