| | |
| | | import com.highdatas.mdm.mapper.SysMenuMapper; |
| | | import com.highdatas.mdm.service.ISysMenuService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService { |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | |
| | | @Override |
| | | public LinkedHashSet<String> getByParentId(LinkedHashSet<String> parentIdSet) { |
| | | if (parentIdSet.size() == 0) { |
| | | return null; |
| | | } |
| | | LinkedHashSet<String> subSet = new LinkedHashSet<>(); |
| | | for (String s : parentIdSet) { |
| | | SysMenu sysMenu = menuService.selectById(s); |
| | | String parentId = sysMenu.getParentId(); |
| | | if (StringUtils.isEmpty(parentId)) { |
| | | continue; |
| | | } |
| | | subSet.add(parentId); |
| | | } |
| | | LinkedHashSet<String> byParentId = getByParentId(subSet); |
| | | if (byParentId != null) { |
| | | parentIdSet.addAll(byParentId); |
| | | } |
| | | |
| | | return parentIdSet; |
| | | } |
| | | } |