use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.
the class MenuController method updateMenu.
/**
* 重新生成系统菜单
*
* @return
*/
@ResponseBody
@RequestMapping("updateMenu.do")
public RestResult<Object> updateMenu(HttpServletRequest request) {
int appId = getAppId(request);
logger.info("将更新菜单, appId=" + appId);
RestResult<Object> result = null;
if (appId > 0) {
String[] scanPath = getScanPath(appId);
try {
MenuItem root = SearchResource.scanMenuTree(scanPath);
menuService.updateMenu(appId, root);
logger.info("更新菜单成功,菜单: " + JsonUtil.toJSONString(root));
result = new RestResult<>(ApiCode.SUCCESS, "成功");
} catch (Exception e) {
logger.error("重新生成系统菜单错误, appId=" + appId, e);
result = new RestResult<>(ApiCode.FAILURE, e.getMessage());
}
} else {
result = new RestResult<>(ApiCode.FAILURE, "appId为空");
}
return result;
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.
the class MenuController method autoClearMenuResource.
/**
* 自动清除多余菜单/资源数据
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping("autoClearMenuResource.do")
public RestResult<Object> autoClearMenuResource(HttpServletRequest request) {
int appId = getAppId(request);
logger.info("将自动清除冗余菜单/资源, appId=" + appId);
RestResult<Object> result = null;
if (appId > 0) {
String[] scanPath = getScanPath(appId);
MenuItem root = SearchResource.scanMenuTree(scanPath);
menuService.clearRedundantMenu(appId, root);
result = new RestResult<>(ApiCode.SUCCESS, "执行成功.");
} else {
result = new RestResult<>(ApiCode.FAILURE, "appId为空");
}
return result;
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.
the class MenuController method getRedundantMenuResource.
/**
* 获取多余菜单/资源数据
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping("getRedundantMenuResource.do")
public RestResult<Map<String, Object>> getRedundantMenuResource(HttpServletRequest request) {
int appId = getAppId(request);
logger.info("将获取冗余菜单/资源, appId=" + appId);
RestResult<Map<String, Object>> result = null;
if (appId > 0) {
String[] scanPath = getScanPath(appId);
MenuItem root = SearchResource.scanMenuTree(scanPath);
Map<String, Object> object = menuService.getRedundantMenu(appId, root);
result = new RestResult<>(ApiCode.SUCCESS, "执行成功.", object);
} else {
result = new RestResult<>(ApiCode.FAILURE, "appId为空");
}
return result;
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.
the class MenuServiceImpl method mapResources.
/**
* 获取类路径下类所包含的资源列表
*
* @param appId
* @param root
* @return
*/
private Map<String, Boolean> mapResources(int appId, MenuItem root) {
Map<String, Boolean> map = new HashMap<>();
List<MenuItem> children = root.getChildren();
if (children == null || children.isEmpty()) {
String key = appId + "_" + root.getUrl();
map.put(key, Boolean.TRUE);
return map;
} else {
for (MenuItem item : children) {
Map<String, Boolean> childrenMap = mapResources(appId, item);
map.putAll(childrenMap);
}
return map;
}
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuItem in project Corgi by kevinYin.
the class MenuServiceImpl method mapMenus.
/**
* 获取类路径下类所包含的菜单列表
*
* @param appId
* @param root
* @return
*/
private Map<String, Boolean> mapMenus(int appId, MenuItem root) {
Map<String, Boolean> map = new HashMap<>();
List<MenuItem> children = root.getChildren();
if (children != null && !children.isEmpty()) {
String key = appId + "_" + root.getName();
map.put(key, Boolean.TRUE);
for (MenuItem item : children) {
Map<String, Boolean> childrenMap = mapMenus(appId, item);
map.putAll(childrenMap);
}
}
return map;
}
Aggregations