组织同名检查

This commit is contained in:
shiziyuan9527 2020-05-22 11:00:35 +08:00
parent f415a121a5
commit e4d1046152
4 changed files with 16 additions and 0 deletions

View File

@ -48,6 +48,16 @@ public class OrganizationService {
private UserService userService; private UserService userService;
public Organization addOrganization(Organization organization) { public Organization addOrganization(Organization organization) {
if (StringUtils.isBlank(organization.getName())) {
MSException.throwException(Translator.get("organization_name_is_null"));
}
OrganizationExample organizationExample = new OrganizationExample();
organizationExample.createCriteria().andNameEqualTo(organization.getName());
if (organizationMapper.countByExample(organizationExample) > 0) {
MSException.throwException(Translator.get("organization_name_already_exists"));
}
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
organization.setId(UUID.randomUUID().toString()); organization.setId(UUID.randomUUID().toString());
organization.setCreateTime(currentTimeMillis); organization.setCreateTime(currentTimeMillis);

View File

@ -33,6 +33,8 @@ workspace_not_exists=Workspace is not exists
project_name_is_null=Project name cannot be null project_name_is_null=Project name cannot be null
project_name_already_exists=The project name already exists project_name_already_exists=The project name already exists
#organization #organization
organization_name_is_null=organization name cannot be null
organization_name_already_exists=The organization name already exists
organization_does_not_belong_to_user=The current organization does not belong to the current user organization_does_not_belong_to_user=The current organization does not belong to the current user
organization_id_is_null=Organization ID cannot be null organization_id_is_null=Organization ID cannot be null
#api #api

View File

@ -33,6 +33,8 @@ workspace_not_exists=工作空间不存在
project_name_is_null=项目名称不能为空 project_name_is_null=项目名称不能为空
project_name_already_exists=项目名称已存在 project_name_already_exists=项目名称已存在
#organization #organization
organization_name_is_null=组织名不能为空
organization_name_already_exists=组织名已存在
organization_does_not_belong_to_user=当前组织不属于当前用户 organization_does_not_belong_to_user=当前组织不属于当前用户
organization_id_is_null=组织 ID 不能为空 organization_id_is_null=组织 ID 不能为空
#api #api

View File

@ -33,6 +33,8 @@ workspace_not_exists=工作空間不存在
project_name_is_null=項目名稱不能為空 project_name_is_null=項目名稱不能為空
project_name_already_exists=項目名稱已存在 project_name_already_exists=項目名稱已存在
#organization #organization
organization_name_is_null=組織名不能為空
organization_name_already_exists=組織名已存在
organization_does_not_belong_to_user=當前組織不屬於當前用戶 organization_does_not_belong_to_user=當前組織不屬於當前用戶
organization_id_is_null=組織 ID 不能為空 organization_id_is_null=組織 ID 不能為空
#api #api