|
@@ -198,13 +198,19 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
|
@Override
|
|
|
public int insertDept(SysDept dept)
|
|
|
{
|
|
|
- SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
|
|
- // 如果父节点不为正常状态,则不允许新增子节点
|
|
|
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
|
|
|
- {
|
|
|
- throw new CustomException("部门停用,不允许新增");
|
|
|
+ SysDept parent = deptMapper.selectDeptById(dept.getParentId());
|
|
|
+ String ancestors = "0";
|
|
|
+ // 新增部门时,未选择上级部门处理
|
|
|
+ if (parent != null) {
|
|
|
+ // 如果父节点不为正常状态,则不允许新增子节点
|
|
|
+ if (!UserConstants.DEPT_NORMAL.equals(parent.getStatus()))
|
|
|
+ {
|
|
|
+ throw new CustomException("部门停用,不允许新增");
|
|
|
+ }
|
|
|
+ ancestors = parent.getAncestors() + "," + dept.getParentId();
|
|
|
}
|
|
|
- dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
|
|
+
|
|
|
+ dept.setAncestors(ancestors);
|
|
|
return deptMapper.insertDept(dept);
|
|
|
}
|
|
|
|