| | |
| | | @Override |
| | | public int insertDept(SysDept dept) |
| | | { |
| | | SysDept info = deptMapper.selectDeptById(dept.getParentId()); |
| | | Long parentId = dept.getParentId(); |
| | | if (parentId == null || parentId.longValue() == 0L) |
| | | { |
| | | dept.setParentId(0L); |
| | | dept.setAncestors("0"); |
| | | return deptMapper.insertDept(dept); |
| | | } |
| | | |
| | | SysDept info = deptMapper.selectDeptById(parentId); |
| | | if (StringUtils.isNull(info)) |
| | | { |
| | | throw new ServiceException("上级部门不存在,不允许新增"); |
| | | } |
| | | // 如果父节点不为正常状态,则不允许新增子节点 |
| | | if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) |
| | | { |
| | | throw new ServiceException("部门停用,不允许新增"); |
| | | } |
| | | dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); |
| | | dept.setAncestors(info.getAncestors() + "," + parentId); |
| | | return deptMapper.insertDept(dept); |
| | | } |
| | | |