fix 组织名称重复检查
This commit is contained in:
parent
7849e771e5
commit
a12cf46b7a
|
@ -71,25 +71,17 @@ public class OrganizationService {
|
||||||
MSException.throwException(Translator.get("organization_name_is_null"));
|
MSException.throwException(Translator.get("organization_name_is_null"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = organization.getId();
|
OrganizationExample example = new OrganizationExample();
|
||||||
String name = organization.getName();
|
OrganizationExample.Criteria criteria = example.createCriteria();
|
||||||
|
criteria.andNameEqualTo(organization.getName());
|
||||||
if (StringUtils.isNotBlank(id)) {
|
if (StringUtils.isNotBlank(organization.getId())) {
|
||||||
Organization org = organizationMapper.selectByPrimaryKey(id);
|
criteria.andIdNotEqualTo(organization.getId());
|
||||||
if (!StringUtils.equals(org.getName(), name)) {
|
|
||||||
checkOrgNameRepeat(name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
checkOrgNameRepeat(name);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void checkOrgNameRepeat(String orgName) {
|
if (organizationMapper.countByExample(example) > 0) {
|
||||||
OrganizationExample organizationExample = new OrganizationExample();
|
|
||||||
organizationExample.createCriteria().andNameEqualTo(orgName);
|
|
||||||
if (organizationMapper.countByExample(organizationExample) > 0) {
|
|
||||||
MSException.throwException(Translator.get("organization_name_already_exists"));
|
MSException.throwException(Translator.get("organization_name_already_exists"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteOrganization(String organizationId) {
|
public void deleteOrganization(String organizationId) {
|
||||||
|
|
Loading…
Reference in New Issue