* @see com.ketayao.ketacustom.service.OrganizationService#delete(java.lang.Long)
*/
@Override
public void delete(Long id) {
if (isRoot(id)) {
throw new NotDeletedException("不允许删除根组织。");
}
Organization organization = this.get(id);
//先判断是否存在子模块,如果存在子模块,则不允许删除
if(organization.getChildren().size() > 0){
throw new NotDeletedException(organization.getName() + "组织下存在子组织,不允许删除。");
}
if (userDAO.findByOrganizationId(id).size() > 0) {
throw new NotDeletedException(organization.getName() + "组织下存在用户,不允许删除。");
}
organizationDAO.delete(organization);
}