修改上级部门(选择项排除本身和下级)

This commit is contained in:
RuoYi
2020-05-15 15:30:08 +08:00
parent dc6fe4c985
commit 59e2d4a2df
5 changed files with 62 additions and 4 deletions

View File

@ -28,6 +28,14 @@ public interface ISysDeptService
*/
public List<Ztree> selectDeptTree(SysDept dept);
/**
* 查询部门管理树(排除下级)
*
* @param dept 部门信息
* @return 所有部门信息
*/
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept);
/**
* 根据角色ID查询菜单
*

View File

@ -1,7 +1,9 @@
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -54,6 +56,32 @@ public class SysDeptServiceImpl implements ISysDeptService
return ztrees;
}
/**
* 查询部门管理树(排除下级)
*
* @param deptId 部门ID
* @return 所有部门信息
*/
@Override
@DataScope(deptAlias = "d")
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept)
{
Long deptId = dept.getDeptId();
List<SysDept> deptList = deptMapper.selectDeptList(dept);
Iterator<SysDept> it = deptList.iterator();
while (it.hasNext())
{
SysDept d = (SysDept) it.next();
if (d.getDeptId().intValue() == deptId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
{
it.remove();
}
}
List<Ztree> ztrees = initZtree(deptList);
return ztrees;
}
/**
* 根据角色ID查询部门数据权限
*