diff --git a/bweb/src/main/java/com/bweb/controller/SecMenuController.java b/bweb/src/main/java/com/bweb/controller/SecMenuController.java index acac466..4d3e407 100644 --- a/bweb/src/main/java/com/bweb/controller/SecMenuController.java +++ b/bweb/src/main/java/com/bweb/controller/SecMenuController.java @@ -71,6 +71,15 @@ public class SecMenuController { } else { secMenu = new SecMenu(); } + if (secMenu.getMenuPSid() != null) { + // 查询父类菜单 + SecMenu parentMenu = secMenuService.queryDetail(secMenu.getMenuPSid()); + if (parentMenu == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + secMenu.setMenuFullUrl(secMenu.getMenuFullUrl()+"/"+secMenu.getMenuUrl()); + } + secMenu.setMenuType(body.getMenuType()); secMenu.setMenuName(body.getMenuName()); secMenu.setMenuUrl(body.getMenuUrl()); @@ -105,6 +114,24 @@ public class SecMenuController { } } + @RequestMapping(value="/delMenu",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "删除菜单") + public ResponseData delMenu(@RequestBody JSONObject body) { + try { + if (body == null || body.getLong("menuId") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + secMenuService.delete(body.getLong("menuId")); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/assignMenu",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "分配菜单") @@ -129,7 +156,7 @@ public class SecMenuController { } } - @RequestMapping(value="/queryMenuList",method = RequestMethod.GET) + @RequestMapping(value="/queryMenuList",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "查询菜单列表") public ResponseData queryMenuList() { @@ -202,15 +229,15 @@ public class SecMenuController { } } - @RequestMapping(value="/queryRoleMenuTree2",method = RequestMethod.GET) + @RequestMapping(value="/queryRoleMenuTreeCustomized",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "查询角色菜单树") - public ResponseData queryRoleMenuTree2(@RequestParam(value = "roleId" , required = false) Long roleId) { + public ResponseData queryRoleMenuTreeCustomized(@RequestParam(value = "roleId" , required = false) Long roleId) { try { - List> mapList = new ArrayList<>(); Map map; + // 获取全部菜单 List menuList = secMenuService.getAllList(); // 获取最顶层菜单 @@ -222,7 +249,7 @@ public class SecMenuController { for (SecMenu topLevelMenu : topLevelMenuList) { if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { map = new HashMap<>(); - map.put("key", topLevelMenu.getId()); + map.put("key", ""+topLevelMenu.getId()); map.put("title", topLevelMenu.getMenuName()); // 获取下级菜单 map.put("children", recursionMenu2(menuList, topLevelMenu.getId())); @@ -255,7 +282,7 @@ public class SecMenuController { for (SecMenu menu : collect) { if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { map = new HashMap<>(); - map.put("key", menu.getId()); + map.put("key", ""+menu.getId()); map.put("title", menu.getMenuName()); // 获取下级菜单 List> recursioned = recursionMenu2(dataSource, menu.getId()); diff --git a/bweb/src/main/java/com/bweb/controller/SecRoleController.java b/bweb/src/main/java/com/bweb/controller/SecRoleController.java index 5b732a3..8f1fdad 100644 --- a/bweb/src/main/java/com/bweb/controller/SecRoleController.java +++ b/bweb/src/main/java/com/bweb/controller/SecRoleController.java @@ -106,6 +106,7 @@ public class SecRoleController { return ResponseMsgUtil.exception(e); } } + @RequestMapping(value="/queryList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询列表") diff --git a/service/src/main/java/com/hfkj/service/impl/SecMenuServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/SecMenuServiceImpl.java index ab4e21c..78e8f9a 100644 --- a/service/src/main/java/com/hfkj/service/impl/SecMenuServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/SecMenuServiceImpl.java @@ -96,7 +96,14 @@ public class SecMenuServiceImpl implements SecMenuService { @Override public SecMenu queryDetail(Long menuId) { - return secMenuMapper.selectByPrimaryKey(menuId); + Object cacheObj = redisUtil.hget(CACHE_MENU, "" + menuId); + if (cacheObj != null) { + return (SecMenu) cacheObj; + } + SecMenu menu = secMenuMapper.selectByPrimaryKey(menuId); + // 更新菜单缓存 + redisUtil.hset(CACHE_MENU, ""+menu.getId(), menu); + return menu; } @Override