|
@@ -25,6 +25,7 @@ import com.ozs.common.utils.spring.SpringUtils;
|
|
|
import com.ozs.system.mapper.SysDeptMapper;
|
|
|
import com.ozs.system.mapper.SysRoleMapper;
|
|
|
import com.ozs.system.service.ISysDeptService;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
/**
|
|
|
* 部门管理 服务实现
|
|
@@ -215,9 +216,12 @@ public class SysDeptServiceImpl extends JoinServiceImpl<SysDeptMapper, SysDept>
|
|
|
@Override
|
|
|
public int insertDept(SysDept dept) {
|
|
|
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
|
|
- // 如果父节点不为正常状态,则不允许新增子节点
|
|
|
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
|
|
- throw new ServiceException("部门停用,不允许新增");
|
|
|
+ //最高层parentId为0
|
|
|
+ if (!ObjectUtils.isEmpty(info)) {
|
|
|
+ // 如果父节点不为正常状态,则不允许新增子节点
|
|
|
+ if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
|
|
+ throw new ServiceException("部门停用,不允许新增");
|
|
|
+ }
|
|
|
}
|
|
|
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
|
|
return deptMapper.insertDept(dept);
|