From 3fe4a42b195c5a7e17f3a84150d9bbc3f5e6f81c Mon Sep 17 00:00:00 2001 From: tamguo Date: Wed, 25 Jul 2018 18:56:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tamguo/modules/sys/dao/SysMenuMapper.java | 2 ++ .../sys/service/impl/SysRoleServiceImpl.java | 14 +++++++-- .../main/resources/mappers/SysMenuMapper.xml | 31 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/dao/SysMenuMapper.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/dao/SysMenuMapper.java index f2a73db..1d16364 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/dao/SysMenuMapper.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/dao/SysMenuMapper.java @@ -9,4 +9,6 @@ public interface SysMenuMapper extends SuperMapper{ List listData(SysMenuCondition condition); + List selectMenuByRoleId(String roleCode); + } diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/SysRoleServiceImpl.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/SysRoleServiceImpl.java index 3d79d25..3436d5f 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/SysRoleServiceImpl.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/service/impl/SysRoleServiceImpl.java @@ -6,6 +6,7 @@ import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -36,11 +37,15 @@ public class SysRoleServiceImpl implements ISysRoleService{ @SuppressWarnings("unchecked") @Override public Map menuTreeData(String roleCode) { - List menus = sysMenuMapper.selectList(Condition.EMPTY); + List menus = sysMenuMapper.selectList(Condition.create().eq("module_codes", "core")); + List roleMenus = sysMenuMapper.selectMenuByRoleId(roleCode); + JSONObject result = new JSONObject(); JSONObject menuInfo = transformZTree(menus); result.put("menuMap", menuInfo); + result.put("roleMenuList", roleMenus); + return result; } @@ -52,7 +57,12 @@ public class SysRoleServiceImpl implements ISysRoleService{ SysMenuEntity menu = menus.get(i); JSONObject node = new JSONObject(); - node.put("name", menu.getMenuName()); + node.put("name", menu.getMenuName() + "       "); + if(!StringUtils.isEmpty(menu.getMenuHref())) { + node.put("name", menu.getMenuName() + "     "+menu.getMenuHref()+"  "); + }else if(!StringUtils.isEmpty(menu.getPermission())) { + node.put("name", menu.getMenuName() + "     "+menu.getPermission()+"  "); + } node.put("pId", menu.getParentCode()); node.put("id", menu.getMenuCode()); node.put("title", menu.getMenuName()); diff --git a/tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml b/tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml index fdd3087..ff57858 100644 --- a/tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml +++ b/tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml @@ -31,4 +31,35 @@ FROM sys_menu m + + \ No newline at end of file