@Override
public void saveOrUpdate(Organization organization) {
if (organization.getId() == null) {
Organization parentOrganization = organizationDAO.findOne(organization.getParent().getId());
if (parentOrganization == null) {
throw new NotExistedException("id=" + organization.getParent().getId() + "父组织不存在!");
}
if (organizationDAO.getByName(organization.getName()) != null) {
throw new NotExistedException(organization.getName() + "已存在!");
}
}
organizationDAO.save(organization);
}