Ejemplo n.º 1
0
 @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());
   }
 }
Ejemplo n.º 2
0
 /**
  * @param model 存放返回界面的model
  * @return
  */
 @RequestMapping("query")
 public String query(Model model, Resource resource, String pageNow) {
   PageView pageView = null;
   if (Common.isEmpty(pageNow)) {
     pageView = new PageView(1);
   } else {
     pageView = new PageView(Integer.parseInt(pageNow));
   }
   pageView = resourceService.query(pageView, resource);
   model.addAttribute("pageView", pageView);
   return Common.BACKGROUND_PATH + "/resource/list";
 }
Ejemplo n.º 3
0
 @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;
 }
Ejemplo n.º 4
0
 /**
  * 根据ID删除菜单
  *
  * @param model
  * @param ids
  * @return
  */
 @ResponseBody
 @RequestMapping("deleteById")
 public Map<String, Object> deleteById(Model model, String ids) {
   Map<String, Object> map = new HashMap<String, Object>();
   try {
     String id[] = ids.split(",");
     for (int i = 0, inv = id.length; i < inv; i++) {
       if (!Common.isEmpty(id[i])) {
         resourceService.delete(id[i]);
       }
     }
     map.put("flag", "true");
   } catch (Exception e) {
     map.put("flag", "false");
   }
   return map;
 }