|
@@ -211,14 +211,22 @@ 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 ServiceException("部门停用,不允许新增");
|
|
|
+
|
|
|
+ if(dept.getParentId()==0L){
|
|
|
+ dept.setAncestors( "0," + dept.getParentId());
|
|
|
+ return deptMapper.insertDept(dept);
|
|
|
+ }else{
|
|
|
+ SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
|
|
+ // 如果父节点不为正常状态,则不允许新增子节点
|
|
|
+
|
|
|
+ if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
|
|
|
+ {
|
|
|
+ throw new ServiceException("部门停用,不允许新增");
|
|
|
+ }
|
|
|
+ dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
|
|
+ return deptMapper.insertDept(dept);
|
|
|
}
|
|
|
- dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
|
|
- return deptMapper.insertDept(dept);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|