陈昶聿
7 天以前 74d740bb065e5806748b1ab8ca95d20984c7eace
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -3,6 +3,10 @@
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.lang.tree.TreeUtil;
import com.ruoyi.common.core.domain.entity.SysUserDept;
import com.ruoyi.common.utils.TreeUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -315,4 +319,14 @@
    private boolean hasChild(List<SysDept> list, SysDept t) {
        return getChildList(list, t).size() > 0;
    }
    public List<SysDept> selectLeafSysDeptListBySysUserDept(SysUserDept sysUserDept){
        List<SysDept> list =  deptMapper.selectSysDeptListBySysUserDept(sysUserDept);
        if(CollectionUtils.isNotEmpty(list)){
            List<SysDept> tree = TreeUtils.buildDeptTree(list);
            list = TreeUtils.getLeafDepts(tree);
        }
        return list;
    }
}