|
@@ -1,21 +1,12 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
|
import com.ruoyi.common.core.domain.TreeSelect;
|
|
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
+import com.ruoyi.common.core.text.Convert;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.system.domain.vo.MetaVo;
|
|
@@ -24,15 +15,25 @@ import com.ruoyi.system.mapper.SysMenuMapper;
|
|
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
|
|
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
|
|
import com.ruoyi.system.service.ISysMenuService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 菜单 业务层处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
*/
|
|
|
@Service
|
|
|
-public class SysMenuServiceImpl implements ISysMenuService
|
|
|
-{
|
|
|
+public class SysMenuServiceImpl implements ISysMenuService {
|
|
|
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
|
|
|
|
|
@Autowired
|
|
@@ -46,33 +47,28 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 根据用户查询系统菜单列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param userId 用户ID
|
|
|
* @return 菜单列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<SysMenu> selectMenuList(Long userId)
|
|
|
- {
|
|
|
+ public List<SysMenu> selectMenuList(Long userId) {
|
|
|
return selectMenuList(new SysMenu(), userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询系统菜单列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 菜单列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
|
|
|
- {
|
|
|
+ public List<SysMenu> selectMenuList(SysMenu menu, Long userId) {
|
|
|
List<SysMenu> menuList = null;
|
|
|
// 管理员显示所有菜单信息
|
|
|
- if (SysUser.isAdmin(userId))
|
|
|
- {
|
|
|
+ if (SysUser.isAdmin(userId)) {
|
|
|
menuList = menuMapper.selectMenuList(menu);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
menu.getParams().put("userId", userId);
|
|
|
menuList = menuMapper.selectMenuListByUserId(menu);
|
|
|
}
|
|
@@ -81,19 +77,16 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 根据用户ID查询权限
|
|
|
- *
|
|
|
+ *
|
|
|
* @param userId 用户ID
|
|
|
* @return 权限列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public Set<String> selectMenuPermsByUserId(Long userId)
|
|
|
- {
|
|
|
+ public Set<String> selectMenuPermsByUserId(Long userId) {
|
|
|
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
|
|
Set<String> permsSet = new HashSet<>();
|
|
|
- for (String perm : perms)
|
|
|
- {
|
|
|
- if (StringUtils.isNotEmpty(perm))
|
|
|
- {
|
|
|
+ for (String perm : perms) {
|
|
|
+ if (StringUtils.isNotEmpty(perm)) {
|
|
|
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
|
|
}
|
|
|
}
|
|
@@ -102,20 +95,16 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 根据用户ID查询菜单
|
|
|
- *
|
|
|
+ *
|
|
|
* @param userId 用户名称
|
|
|
* @return 菜单列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<SysMenu> selectMenuTreeByUserId(Long userId)
|
|
|
- {
|
|
|
+ public List<SysMenu> selectMenuTreeByUserId(Long userId) {
|
|
|
List<SysMenu> menus = null;
|
|
|
- if (SecurityUtils.isAdmin(userId))
|
|
|
- {
|
|
|
+ if (SecurityUtils.isAdmin(userId)) {
|
|
|
menus = menuMapper.selectMenuTreeAll();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
menus = menuMapper.selectMenuTreeByUserId(userId);
|
|
|
}
|
|
|
return getChildPerms(menus, 0);
|
|
@@ -123,29 +112,26 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 根据角色ID查询菜单树信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param roleId 角色ID
|
|
|
* @return 选中菜单列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Integer> selectMenuListByRoleId(Long roleId)
|
|
|
- {
|
|
|
+ public List<Integer> selectMenuListByRoleId(Long roleId) {
|
|
|
SysRole role = roleMapper.selectRoleById(roleId);
|
|
|
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 构建前端路由所需要的菜单
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menus 菜单列表
|
|
|
* @return 路由列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<RouterVo> buildMenus(List<SysMenu> menus)
|
|
|
- {
|
|
|
+ public List<RouterVo> buildMenus(List<SysMenu> menus) {
|
|
|
List<RouterVo> routers = new LinkedList<RouterVo>();
|
|
|
- for (SysMenu menu : menus)
|
|
|
- {
|
|
|
+ for (SysMenu menu : menus) {
|
|
|
RouterVo router = new RouterVo();
|
|
|
router.setHidden("1".equals(menu.getVisible()));
|
|
|
router.setName(getRouteName(menu));
|
|
@@ -153,14 +139,11 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
router.setComponent(getComponent(menu));
|
|
|
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
|
|
List<SysMenu> cMenus = menu.getChildren();
|
|
|
- if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
|
|
- {
|
|
|
+ if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
|
|
router.setAlwaysShow(true);
|
|
|
router.setRedirect("noRedirect");
|
|
|
router.setChildren(buildMenus(cMenus));
|
|
|
- }
|
|
|
- else if (isMenuFrame(menu))
|
|
|
- {
|
|
|
+ } else if (isMenuFrame(menu)) {
|
|
|
router.setMeta(null);
|
|
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
|
|
RouterVo children = new RouterVo();
|
|
@@ -170,14 +153,12 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
|
|
childrenList.add(children);
|
|
|
router.setChildren(childrenList);
|
|
|
- }
|
|
|
- else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
|
|
- {
|
|
|
+ } else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
|
|
|
router.setMeta(null);
|
|
|
router.setPath("/inner");
|
|
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
|
|
RouterVo children = new RouterVo();
|
|
|
- String routerPath = StringUtils.replaceEach(menu.getPath(), new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" });
|
|
|
+ String routerPath = StringUtils.replaceEach(menu.getPath(), new String[]{Constants.HTTP, Constants.HTTPS}, new String[]{"", ""});
|
|
|
children.setPath(routerPath);
|
|
|
children.setComponent(UserConstants.INNER_LINK);
|
|
|
children.setName(StringUtils.capitalize(routerPath));
|
|
@@ -192,31 +173,26 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 构建前端所需要树结构
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menus 菜单列表
|
|
|
* @return 树结构列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<SysMenu> buildMenuTree(List<SysMenu> menus)
|
|
|
- {
|
|
|
+ public List<SysMenu> buildMenuTree(List<SysMenu> menus) {
|
|
|
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
|
|
- List<Long> tempList = new ArrayList<Long>();
|
|
|
- for (SysMenu dept : menus)
|
|
|
- {
|
|
|
+ List<String> tempList = new ArrayList<>();
|
|
|
+ for (SysMenu dept : menus) {
|
|
|
tempList.add(dept.getMenuId());
|
|
|
}
|
|
|
- for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
|
|
|
- {
|
|
|
+ for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
|
|
|
SysMenu menu = (SysMenu) iterator.next();
|
|
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
|
|
- if (!tempList.contains(menu.getParentId()))
|
|
|
- {
|
|
|
+ if (!tempList.contains(menu.getParentId())) {
|
|
|
recursionFn(menus, menu);
|
|
|
returnList.add(menu);
|
|
|
}
|
|
|
}
|
|
|
- if (returnList.isEmpty())
|
|
|
- {
|
|
|
+ if (returnList.isEmpty()) {
|
|
|
returnList = menus;
|
|
|
}
|
|
|
return returnList;
|
|
@@ -224,104 +200,95 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 构建前端所需要下拉树结构
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menus 菜单列表
|
|
|
* @return 下拉树结构列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus)
|
|
|
- {
|
|
|
+ public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus) {
|
|
|
List<SysMenu> menuTrees = buildMenuTree(menus);
|
|
|
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据菜单ID查询信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menuId 菜单ID
|
|
|
* @return 菜单信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public SysMenu selectMenuById(Long menuId)
|
|
|
- {
|
|
|
+ public SysMenu selectMenuById(Long menuId) {
|
|
|
return menuMapper.selectMenuById(menuId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 是否存在菜单子节点
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menuId 菜单ID
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean hasChildByMenuId(Long menuId)
|
|
|
- {
|
|
|
+ public boolean hasChildByMenuId(Long menuId) {
|
|
|
int result = menuMapper.hasChildByMenuId(menuId);
|
|
|
return result > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询菜单使用数量
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menuId 菜单ID
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean checkMenuExistRole(Long menuId)
|
|
|
- {
|
|
|
+ public boolean checkMenuExistRole(Long menuId) {
|
|
|
int result = roleMenuMapper.checkMenuExistRole(menuId);
|
|
|
return result > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增保存菜单信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertMenu(SysMenu menu)
|
|
|
- {
|
|
|
+ public int insertMenu(SysMenu menu) {
|
|
|
return menuMapper.insertMenu(menu);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改保存菜单信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateMenu(SysMenu menu)
|
|
|
- {
|
|
|
+ public int updateMenu(SysMenu menu) {
|
|
|
return menuMapper.updateMenu(menu);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除菜单管理信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menuId 菜单ID
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteMenuById(Long menuId)
|
|
|
- {
|
|
|
+ public int deleteMenuById(Long menuId) {
|
|
|
return menuMapper.deleteMenuById(menuId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 校验菜单名称是否唯一
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public String checkMenuNameUnique(SysMenu menu)
|
|
|
- {
|
|
|
- Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
|
|
+ public String checkMenuNameUnique(SysMenu menu) {
|
|
|
+ String menuId = StringUtils.isNull(menu.getMenuId()) ? "-1" : menu.getMenuId();
|
|
|
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
|
|
- if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
|
|
|
- {
|
|
|
+ if (StringUtils.isNotNull(info) && !info.getMenuId().equals(menuId)) {
|
|
|
return UserConstants.NOT_UNIQUE;
|
|
|
}
|
|
|
return UserConstants.UNIQUE;
|
|
@@ -329,16 +296,14 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 获取路由名称
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 路由名称
|
|
|
*/
|
|
|
- public String getRouteName(SysMenu menu)
|
|
|
- {
|
|
|
+ public String getRouteName(SysMenu menu) {
|
|
|
String routerName = StringUtils.capitalize(menu.getPath());
|
|
|
// 非外链并且是一级目录(类型为目录)
|
|
|
- if (isMenuFrame(menu))
|
|
|
- {
|
|
|
+ if (isMenuFrame(menu)) {
|
|
|
routerName = StringUtils.EMPTY;
|
|
|
}
|
|
|
return routerName;
|
|
@@ -346,27 +311,23 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 获取路由地址
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 路由地址
|
|
|
*/
|
|
|
- public String getRouterPath(SysMenu menu)
|
|
|
- {
|
|
|
+ public String getRouterPath(SysMenu menu) {
|
|
|
String routerPath = menu.getPath();
|
|
|
// 内链打开外网方式
|
|
|
- if (menu.getParentId().intValue() != 0 && isInnerLink(menu))
|
|
|
- {
|
|
|
- routerPath = StringUtils.replaceEach(routerPath, new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" });
|
|
|
+ if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
|
|
+ routerPath = StringUtils.replaceEach(routerPath, new String[]{Constants.HTTP, Constants.HTTPS}, new String[]{"", ""});
|
|
|
}
|
|
|
// 非外链并且是一级目录(类型为目录)
|
|
|
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
|
|
|
- && UserConstants.NO_FRAME.equals(menu.getIsFrame()))
|
|
|
- {
|
|
|
+ && UserConstants.NO_FRAME.equals(menu.getIsFrame())) {
|
|
|
routerPath = "/" + menu.getPath();
|
|
|
}
|
|
|
// 非外链并且是一级目录(类型为菜单)
|
|
|
- else if (isMenuFrame(menu))
|
|
|
- {
|
|
|
+ else if (isMenuFrame(menu)) {
|
|
|
routerPath = "/";
|
|
|
}
|
|
|
return routerPath;
|
|
@@ -374,23 +335,17 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 获取组件信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 组件信息
|
|
|
*/
|
|
|
- public String getComponent(SysMenu menu)
|
|
|
- {
|
|
|
+ public String getComponent(SysMenu menu) {
|
|
|
String component = UserConstants.LAYOUT;
|
|
|
- if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu))
|
|
|
- {
|
|
|
+ if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) {
|
|
|
component = menu.getComponent();
|
|
|
- }
|
|
|
- else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu))
|
|
|
- {
|
|
|
+ } else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
|
|
component = UserConstants.INNER_LINK;
|
|
|
- }
|
|
|
- else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu))
|
|
|
- {
|
|
|
+ } else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) {
|
|
|
component = UserConstants.PARENT_VIEW;
|
|
|
}
|
|
|
return component;
|
|
@@ -398,54 +353,48 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 是否为菜单内部跳转
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
- public boolean isMenuFrame(SysMenu menu)
|
|
|
- {
|
|
|
+ public boolean isMenuFrame(SysMenu menu) {
|
|
|
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
|
|
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 是否为内链组件
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
- public boolean isInnerLink(SysMenu menu)
|
|
|
- {
|
|
|
+ public boolean isInnerLink(SysMenu menu) {
|
|
|
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 是否为parent_view组件
|
|
|
- *
|
|
|
+ *
|
|
|
* @param menu 菜单信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
- public boolean isParentView(SysMenu menu)
|
|
|
- {
|
|
|
+ public boolean isParentView(SysMenu menu) {
|
|
|
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据父节点的ID获取所有子节点
|
|
|
- *
|
|
|
- * @param list 分类表
|
|
|
+ *
|
|
|
+ * @param list 分类表
|
|
|
* @param parentId 传入的父节点ID
|
|
|
* @return String
|
|
|
*/
|
|
|
- public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
|
|
|
- {
|
|
|
+ public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
|
|
|
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
|
|
- for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
|
|
|
- {
|
|
|
+ for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
|
|
|
SysMenu t = (SysMenu) iterator.next();
|
|
|
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
|
|
- if (t.getParentId() == parentId)
|
|
|
- {
|
|
|
+ if (t.getParentId() == parentId) {
|
|
|
recursionFn(list, t);
|
|
|
returnList.add(t);
|
|
|
}
|
|
@@ -455,19 +404,16 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
|
|
|
/**
|
|
|
* 递归列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param list
|
|
|
* @param t
|
|
|
*/
|
|
|
- private void recursionFn(List<SysMenu> list, SysMenu t)
|
|
|
- {
|
|
|
+ private void recursionFn(List<SysMenu> list, SysMenu t) {
|
|
|
// 得到子节点列表
|
|
|
List<SysMenu> childList = getChildList(list, t);
|
|
|
t.setChildren(childList);
|
|
|
- for (SysMenu tChild : childList)
|
|
|
- {
|
|
|
- if (hasChild(list, tChild))
|
|
|
- {
|
|
|
+ for (SysMenu tChild : childList) {
|
|
|
+ if (hasChild(list, tChild)) {
|
|
|
recursionFn(list, tChild);
|
|
|
}
|
|
|
}
|
|
@@ -476,15 +422,12 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
/**
|
|
|
* 得到子节点列表
|
|
|
*/
|
|
|
- private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
|
|
|
- {
|
|
|
+ private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
|
|
|
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
|
|
Iterator<SysMenu> it = list.iterator();
|
|
|
- while (it.hasNext())
|
|
|
- {
|
|
|
+ while (it.hasNext()) {
|
|
|
SysMenu n = (SysMenu) it.next();
|
|
|
- if (n.getParentId().longValue() == t.getMenuId().longValue())
|
|
|
- {
|
|
|
+ if (Convert.toStr(n.getParentId()).equals(t.getMenuId())) {
|
|
|
tlist.add(n);
|
|
|
}
|
|
|
}
|
|
@@ -494,8 +437,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
/**
|
|
|
* 判断是否有子节点
|
|
|
*/
|
|
|
- private boolean hasChild(List<SysMenu> list, SysMenu t)
|
|
|
- {
|
|
|
+ private boolean hasChild(List<SysMenu> list, SysMenu t) {
|
|
|
return getChildList(list, t).size() > 0 ? true : false;
|
|
|
}
|
|
|
}
|