From c99eb98001e22f671ce514268231edcd27fc73ef Mon Sep 17 00:00:00 2001
From: 稚屿 <1491182878@qq.com>
Date: Wed, 09 Feb 2022 09:10:50 +0800
Subject: [PATCH] 代码优化
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 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 af97f14..ece0159 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());
@@ -179,7 +179,7 @@
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 = innerLinkReplaceEach(menu.getPath());
children.setPath(routerPath);
children.setComponent(UserConstants.INNER_LINK);
children.setName(StringUtils.capitalize(routerPath));
@@ -358,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())
@@ -498,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