|
|
|
|
@ -192,6 +192,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|
|
|
|
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
|
|
|
|
.eq(SysDept::getDeptName, dept.getDeptName())
|
|
|
|
|
.eq(SysDept::getParentId, dept.getParentId())
|
|
|
|
|
.eq(SysDept::getTenantId, dept.getTenantId())
|
|
|
|
|
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
|
|
|
|
|
return !exist;
|
|
|
|
|
}
|
|
|
|
|
@ -221,12 +222,16 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int insertDept(SysDept dept) {
|
|
|
|
|
if(dept.getParentId()==0L){ //新增某公司顶级部门时
|
|
|
|
|
dept.setAncestors(dept.getParentId().toString());
|
|
|
|
|
}else{
|
|
|
|
|
SysDept info = baseMapper.selectById(dept.getParentId());
|
|
|
|
|
// 如果父节点不为正常状态,则不允许新增子节点
|
|
|
|
|
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
|
|
|
|
throw new ServiceException("部门停用,不允许新增");
|
|
|
|
|
}
|
|
|
|
|
dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId());
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.insert(dept);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|