public void insertDepartment(Department o) { try { if (o.getParentId() == 0) { o.setParentId(Department.rootNode); // o.setParentName(o.getDeptName()); entityDao.insert(o); } else { Department dept = this.getDepartmentId(o.getParentId()); dept.setIsLeaf("n"); entityDao.update(dept); String idPath = dept.getFullIdPath() == null ? "" : dept.getFullIdPath(); String namePath = dept.getFullNamePath() == null ? "" : dept.getFullNamePath(); // id全路径格式:/1/2/ o.setFullIdPath(idPath + dept.getId() + "/"); o.setFullNamePath(namePath + dept.getDeptName() + "/"); o.setOrgLever(Integer.valueOf((dept.getOrgLever().intValue() + 1))); // o.setParentName(dept.getDeptName()); entityDao.insert(o); } } finally { } }