|
|
@@ -189,12 +189,17 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertDept(SysDept dept) {
|
|
|
- SysDept info = getById(dept.getParentId());
|
|
|
- // 如果父节点不为正常状态,则不允许新增子节点
|
|
|
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
|
|
- throw new CustomException("部门停用,不允许新增");
|
|
|
+ if(dept.getParentId()>0){
|
|
|
+ SysDept info = getById(dept.getParentId());
|
|
|
+ // 如果父节点不为正常状态,则不允许新增子节点
|
|
|
+ if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
|
|
+ throw new CustomException("部门停用,不允许新增");
|
|
|
+ }
|
|
|
+ dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
|
|
+ }else{
|
|
|
+ dept.setAncestors("0");
|
|
|
}
|
|
|
- dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
|
|
+
|
|
|
return baseMapper.insert(dept);
|
|
|
}
|
|
|
|