workspace name duplicate check

This commit is contained in:
Captain.B 2020-04-09 14:36:45 +08:00
parent 64c46ea715
commit 43506a265e
3 changed files with 17 additions and 2 deletions

View File

@ -230,6 +230,19 @@ public class WorkspaceService {
}
public void addWorkspaceByAdmin(Workspace workspace) {
if (StringUtils.isBlank(workspace.getName())) {
MSException.throwException(Translator.get("workspace_name_is_null"));
}
if (StringUtils.isBlank(workspace.getOrganizationId())) {
MSException.throwException(Translator.get("organization_id_is_null"));
}
WorkspaceExample example = new WorkspaceExample();
example.createCriteria()
.andOrganizationIdEqualTo(workspace.getOrganizationId())
.andNameEqualTo(workspace.getName());
if (workspaceMapper.countByExample(example) > 0) {
MSException.throwException(Translator.get("workspace_name_already_exists"));
}
workspace.setId(UUID.randomUUID().toString());
workspace.setCreateTime(System.currentTimeMillis());
workspace.setUpdateTime(System.currentTimeMillis());

View File

@ -17,5 +17,6 @@
"node_deep_limit": "The node depth does not exceed 5 layers!",
"no_nodes_message": "No node message",
"duplicate_node_ip": "Duplicate IPs",
"only_one_k8s": "Only one K8s can be added"
"only_one_k8s": "Only one K8s can be added",
"organization_id_is_null": "Organization ID cannot be null"
}

View File

@ -17,5 +17,6 @@
"node_deep_limit": "节点深度不超过5层",
"no_nodes_message": "没有节点信息",
"duplicate_node_ip": "节点 IP 重复",
"only_one_k8s": "只能添加一个 K8s"
"only_one_k8s": "只能添加一个 K8s",
"organization_id_is_null": "组织 ID 不能为空"
}