diff --git a/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/mapper/XhpcTenantMapper.java b/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/mapper/XhpcTenantMapper.java
index eb2a8e38..33660193 100644
--- a/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/mapper/XhpcTenantMapper.java
+++ b/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/mapper/XhpcTenantMapper.java
@@ -23,6 +23,10 @@ public interface XhpcTenantMapper {
XhpcTenantDomain selectByPrimaryKey(String tenantId);
+ XhpcTenantDomain selectByName(String tenantName);
+
+ XhpcTenantDomain selectByPkOrName(String tenantId, String tenantName);
+
int updateByPrimaryKeySelective(XhpcTenantDomain record);
int updateByPrimaryKey(XhpcTenantDomain record);
diff --git a/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/service/impl/XhpcTenantServiceImpl.java b/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/service/impl/XhpcTenantServiceImpl.java
index 4a5a6bd5..b5429f44 100644
--- a/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/service/impl/XhpcTenantServiceImpl.java
+++ b/xhpc-modules/xhpc-tenant/src/main/java/com/xhpc/tenant/service/impl/XhpcTenantServiceImpl.java
@@ -46,9 +46,9 @@ public class XhpcTenantServiceImpl implements XhpcTenantService {
throw new CustomException("必填字段为空");
}
- XhpcTenantDomain tenantDomain = tenantMapper.selectByPrimaryKey(domain.getTenantId());
+ XhpcTenantDomain tenantDomain = tenantMapper.selectByPkOrName(domain.getTenantId(), domain.getTenantName());
if(tenantDomain != null){
- throw new CustomException("租户ID已存在");
+ throw new CustomException("租户ID或名称已存在");
}
return tenantMapper.insertSelective(domain) > 0;
diff --git a/xhpc-modules/xhpc-tenant/src/main/resources/mapper/XhpcTenantMapper.xml b/xhpc-modules/xhpc-tenant/src/main/resources/mapper/XhpcTenantMapper.xml
index abe4f23c..27d8b22e 100644
--- a/xhpc-modules/xhpc-tenant/src/main/resources/mapper/XhpcTenantMapper.xml
+++ b/xhpc-modules/xhpc-tenant/src/main/resources/mapper/XhpcTenantMapper.xml
@@ -58,6 +58,21 @@
from xhpc_tenant
where tenant_id = #{tenantId,jdbcType=VARCHAR}
+
+
+
+
+
delete from xhpc_tenant
where tenant_id = #{tenantId,jdbcType=VARCHAR}