|  |  |  | 
|---|
|  |  |  | package com.ruoyi.system.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import com.ruoyi.common.annotation.DataScope; | 
|---|
|  |  |  | import com.ruoyi.common.constant.UserConstants; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.ruoyi.system.mapper.SysRoleMapper; | 
|---|
|  |  |  | import com.ruoyi.system.service.ISysDeptService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 部门管理 服务实现 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class SysDeptServiceImpl implements ISysDeptService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private SysDeptMapper deptMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private SysRoleMapper roleMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return getChildList(list, t).size() > 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Long> deptIdBySub(Long deptId) { | 
|---|
|  |  |  | QueryWrapper<SysDept> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.select("dept_id").apply("string_to_array( ancestors, ',' ) @> ARRAY [ '"+deptId+"']"); | 
|---|
|  |  |  | //                in("cast(ancestors as bigint)",deptId); | 
|---|
|  |  |  | List<SysDept> list = deptMapper.selectList(queryWrapper); | 
|---|
|  |  |  | List<Long> deptList = new ArrayList<>(); | 
|---|
|  |  |  | deptList.add(deptId); | 
|---|
|  |  |  | for (int i = 0; i < list.size(); i++) { | 
|---|
|  |  |  | deptList.add(list.get(i).getDeptId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return deptList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|