WANG 6 年之前
父节点
当前提交
337944b0aa

+ 7 - 7
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/OrgServiceImpl.java

@@ -97,6 +97,13 @@ public class OrgServiceImpl implements OrgService {
 			throw new StatusException("B-150002", "name is null");
 		}
 
+		if (StringUtils.isNotBlank(domainName)) {
+			OrgEntity tempOrg = orgRepo.findByParentIdIsNullAndDomainName(domainName);
+			if (null != tempOrg && !tempOrg.getCode().equals(code)) {
+				throw new StatusException("B-150004", "域名被占用");
+			}
+		}
+
 		if (null == enable) {
 			enable = true;
 		}
@@ -123,13 +130,6 @@ public class OrgServiceImpl implements OrgService {
 		orgEntity.setDomainName(domainName);
 		orgEntity.setRemark(remark);
 
-		if (StringUtils.isNotBlank(domainName)) {
-			OrgEntity tempOrg = orgRepo.findByParentIdIsNullAndDomainName(domainName);
-			if (null != tempOrg && !tempOrg.getId().equals(orgEntity.getId())) {
-				throw new StatusException("B-150004", "域名被占用");
-			}
-		}
-
 		OrgEntity saved = orgRepo.save(orgEntity);
 
 		Map<DynamicEnum, String> map = checkAndGetOrgProperties(properties);