diff --git a/src/main/java/com/gxwebsoft/common/system/controller/MainController.java b/src/main/java/com/gxwebsoft/common/system/controller/MainController.java index 155c75e..9ee9e7c 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/MainController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/MainController.java @@ -673,6 +673,21 @@ public class MainController extends BaseController { if (userService.getAdminByPhone(param) != null) { throw new BusinessException("该手机号码已注册"); } + + // 验证租户名称是否重复 + if (StrUtil.isNotBlank(tenantName)) { + long existingTenantCount = tenantService.count( + new LambdaQueryWrapper() + .eq(Tenant::getTenantName, tenantName) + .eq(Tenant::getDeleted, 0) + ); + if (existingTenantCount > 0) { + throw new BusinessException("租户名称已存在,请使用其他名称"); + } + } else { + throw new BusinessException("租户名称不能为空"); + } + // 添加租户 Tenant tenant = new Tenant(); tenant.setTenantName(tenantName); @@ -823,6 +838,21 @@ public class MainController extends BaseController { if (userService.getAdminByPhone(param) != null) { throw new BusinessException("该手机号码已注册"); } + + // 验证租户名称是否重复 + if (StrUtil.isNotBlank(tenantName)) { + long existingTenantCount = tenantService.count( + new LambdaQueryWrapper() + .eq(Tenant::getTenantName, tenantName) + .eq(Tenant::getDeleted, 0) + ); + if (existingTenantCount > 0) { + throw new BusinessException("租户名称已存在,请使用其他名称"); + } + } else { + throw new BusinessException("租户名称不能为空"); + } + // 添加租户 Tenant tenant = new Tenant(); tenant.setTenantName(tenantName);