From 891f71b1c2f1c0e17a4eb3653c7e23a9e468e1cf Mon Sep 17 00:00:00 2001 From: Yjoioooo <693337446@qq.com> Date: Thu, 9 Mar 2023 21:40:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E4=B8=8B=E6=B3=A8=E5=86=8C=E7=94=A8=E6=88=B7BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/SysRegisterController.java | 2 +- .../ruoyi/system/service/ISysConfigService.java | 7 +++++++ .../service/impl/SysConfigServiceImpl.java | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SysRegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SysRegisterController.java index 21abf93f..0c3ef3bf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SysRegisterController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SysRegisterController.java @@ -31,7 +31,7 @@ public class SysRegisterController extends BaseController { @SaIgnore @PostMapping("/register") public R register(@Validated @RequestBody RegisterBody user) { - if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { + if (!configService.selectRegisterEnabled(user.getTenantId())) { return R.fail("当前系统没有开启注册功能!"); } registerService.register(user); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java index 46dcbc47..5e89d157 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java @@ -33,6 +33,13 @@ public interface ISysConfigService { */ String selectConfigByKey(String configKey); + /** + * 获取注册开关 + * @param tenantId 租户id + * @return true开启,false关闭 + */ + boolean selectRegisterEnabled(String tenantId); + /** * 获取验证码开关 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index 0ae33b3d..80a68a2f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -16,6 +16,7 @@ import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.mybatis.core.page.PageQuery; import com.ruoyi.common.mybatis.core.page.TableDataInfo; import com.ruoyi.common.redis.utils.CacheUtils; +import com.ruoyi.common.tenant.helper.TenantHelper; import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.domain.bo.SysConfigBo; import com.ruoyi.system.domain.vo.SysConfigVo; @@ -77,6 +78,22 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { return StringUtils.EMPTY; } + /** + * 获取注册开关 + * @param tenantId 租户id + * @return true开启,false关闭 + */ + @Override + public boolean selectRegisterEnabled(String tenantId) { + SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper() + .eq(SysConfig::getConfigKey, "sys.account.registerUser") + .eq(TenantHelper.isEnable(),SysConfig::getTenantId, tenantId)); + if (ObjectUtil.isNull(retConfig)) { + return false; + } + return Convert.toBool(retConfig.getConfigValue()); + } + /** * 获取验证码开关 *