|
@@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
|
|
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler;
|
|
|
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler;
|
|
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -97,6 +98,9 @@ public class TenantServiceImpl implements TenantService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long createTenant(TenantCreateReqVO createReqVO) {
|
|
|
+ // 校验租户名称是否重复
|
|
|
+ validTenantName(createReqVO.getName(), null);
|
|
|
+
|
|
|
// 校验套餐被禁用
|
|
|
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId());
|
|
|
|
|
@@ -139,6 +143,10 @@ public class TenantServiceImpl implements TenantService {
|
|
|
public void updateTenant(TenantUpdateReqVO updateReqVO) {
|
|
|
// 校验存在
|
|
|
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
|
|
+
|
|
|
+ // 校验租户名称是否重复
|
|
|
+ validTenantName(updateReqVO.getName(), updateReqVO.getId());
|
|
|
+
|
|
|
// 校验套餐被禁用
|
|
|
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
|
|
|
|
|
@@ -151,6 +159,12 @@ public class TenantServiceImpl implements TenantService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected void validTenantName(String tenantName, Long id) {
|
|
|
+ if (tenantMapper.selectCountByName(tenantName, id) > 0) {
|
|
|
+ throw exception(TENANT_NAME_DUPLICATE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) {
|