提交代码

master
胡锐 7 months ago committed by yuanye
parent 4557c16db7
commit 1b9526c6de
  1. 39
      bweb/src/main/java/com/bweb/controller/SecMenuController.java
  2. 1
      bweb/src/main/java/com/bweb/controller/SecRoleController.java
  3. 9
      service/src/main/java/com/hfkj/service/impl/SecMenuServiceImpl.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<Map<String,Object>> mapList = new ArrayList<>();
Map<String,Object> map;
// 获取全部菜单
List<SecMenu> 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<Map<String, Object>> recursioned = recursionMenu2(dataSource, menu.getId());

@ -106,6 +106,7 @@ public class SecRoleController {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询列表")

@ -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

Loading…
Cancel
Save