@ResponseBody @RequestMapping("queryAll") public List<Resource> queryAll(HttpServletRequest request) { if (PropertiesUtils.findPropertiesKey("rootName") .equals(Common.findAuthenticatedUsername())) { // 根据账号拥有所有权限 return resourceService.queryAll(new Resource()); } else { return resourceService.queryAll(new Resource()); } }
@ResponseBody @RequestMapping("resources") public Map<String, Object> resources(Resource resource, HttpServletRequest request) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); List<Resource> rs; if (PropertiesUtils.findPropertiesKey("rootName").equals(Common.findAuthenticatedUsername())) { rs = resourceService.queryAll(resource); } else { rs = resourceService.findAccountResources(Common.findUserSessionId(request)); } List<TreeObject> treeObjects = new ArrayList<TreeObject>(); for (Resource res : rs) { // 转换为树对象 TreeObject t = new TreeObject(); PropertyUtils.copyProperties(t, res); treeObjects.add(t); } List<TreeObject> ns = TreeUtil.getChildResources(treeObjects, 0); BeanUtil.sort(ns, "id", false); map.put("resourceTree", ns); return map; }