|
|
@ -1,13 +1,17 @@ |
|
|
package com.hxhq.system.service.impl; |
|
|
package com.hxhq.system.service.impl; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.Iterator; |
|
|
import java.util.Iterator; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil; |
|
|
|
|
|
import com.hxhq.business.enums.dept.DeptTypeEnum; |
|
|
import com.hxhq.system.domain.vo.TreeSelect; |
|
|
import com.hxhq.system.domain.vo.TreeSelect; |
|
|
import com.hxhq.system.mapper.SysDeptMapper; |
|
|
import com.hxhq.system.mapper.SysDeptMapper; |
|
|
import com.hxhq.system.mapper.SysRoleMapper; |
|
|
import com.hxhq.system.mapper.SysRoleMapper; |
|
|
|
|
|
import org.apache.commons.lang3.ArrayUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.hxhq.common.core.constant.UserConstants; |
|
|
import com.hxhq.common.core.constant.UserConstants; |
|
|
@ -294,6 +298,34 @@ public class SysDeptServiceImpl implements ISysDeptService |
|
|
return deptMapper.deleteDeptById(deptId); |
|
|
return deptMapper.deleteDeptById(deptId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<SysDept> getSuperiorAndSubordinate(Long deptId) { |
|
|
|
|
|
List<SysDept> result = new ArrayList<>(); |
|
|
|
|
|
SysDept sysDept = deptMapper.selectDeptById(deptId); |
|
|
|
|
|
if(sysDept.getType() == DeptTypeEnum.dept.getValue()) { |
|
|
|
|
|
// 当前组织如果是部门,则不需要寻找上级 |
|
|
|
|
|
result.add(sysDept); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 若当前组织不是部门类型,则需要寻找上级的部门 |
|
|
|
|
|
String ancestors = sysDept.getAncestors(); |
|
|
|
|
|
String[] parentIdList = ancestors.split(","); |
|
|
|
|
|
List<SysDept> parentDeptList = deptMapper.selectDeptByIdList(Arrays.stream(parentIdList) |
|
|
|
|
|
.map(Long::parseLong) |
|
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
|
for (SysDept dept : parentDeptList) { |
|
|
|
|
|
if(dept.getType() == DeptTypeEnum.dept.getValue()) { |
|
|
|
|
|
result.add(dept); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询所有子部门 |
|
|
|
|
|
List<SysDept> childrenDeptList = deptMapper.selectChildrenDeptById(deptId); |
|
|
|
|
|
result.addAll(childrenDeptList); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 递归列表 |
|
|
* 递归列表 |
|
|
*/ |
|
|
*/ |
|
|
|