From eab1b450d52782737aad6b0d1bed3e6884ec3a2f Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Mon, 13 Jun 2022 21:43:11 +0800
Subject: [PATCH] 优化代码
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
index f450caa..b2ac3f0 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
@@ -128,7 +128,7 @@
* @return 选中菜单列表
*/
@Override
- public List<Integer> selectMenuListByRoleId(Long roleId)
+ public List<Long> selectMenuListByRoleId(Long roleId)
{
SysRole role = roleMapper.selectRoleById(roleId);
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
@@ -169,16 +169,17 @@
children.setComponent(menu.getComponent());
children.setName(StringUtils.capitalize(menu.getPath()));
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
+ children.setQuery(menu.getQuery());
childrenList.add(children);
router.setChildren(childrenList);
}
else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
{
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
- router.setPath("/inner");
+ router.setPath("/");
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 = innerLinkReplaceEach(menu.getPath());
children.setPath(routerPath);
children.setComponent(UserConstants.INNER_LINK);
children.setName(StringUtils.capitalize(routerPath));
@@ -258,7 +259,7 @@
public boolean hasChildByMenuId(Long menuId)
{
int result = menuMapper.hasChildByMenuId(menuId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -271,7 +272,7 @@
public boolean checkMenuExistRole(Long menuId)
{
int result = roleMenuMapper.checkMenuExistRole(menuId);
- return result > 0 ? true : false;
+ return result > 0;
}
/**
@@ -357,7 +358,7 @@
// 内链打开外网方式
if (menu.getParentId().intValue() != 0 && isInnerLink(menu))
{
- routerPath = StringUtils.replaceEach(routerPath, new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" });
+ routerPath = innerLinkReplaceEach(routerPath);
}
// 非外链并且是一级目录(类型为目录)
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
@@ -497,6 +498,17 @@
*/
private boolean hasChild(List<SysMenu> list, SysMenu t)
{
- return getChildList(list, t).size() > 0 ? true : false;
+ return getChildList(list, t).size() > 0;
+ }
+
+ /**
+ * 内链域名特殊字符替换
+ *
+ * @return
+ */
+ public String innerLinkReplaceEach(String path)
+ {
+ return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS },
+ new String[] { "", "" });
}
}
--
Gitblit v1.9.2