コード例 #1
0
 @RequiresPermissions("cms:category:edit")
 @RequestMapping(value = "save")
 public String save(Category category, Model model, RedirectAttributes redirectAttributes) {
   if (Global.isDemoMode()) {
     addMessage(redirectAttributes, "演示模式,不允许操作!");
     return "redirect:" + adminPath + "/cms/category/";
   }
   if (!beanValidator(model, category)) {
     return form(category, model);
   }
   categoryService.save(category);
   addMessage(redirectAttributes, "保存栏目'" + category.getName() + "'成功");
   return "redirect:" + adminPath + "/cms/category/";
 }
コード例 #2
0
 @RequiresUser
 @ResponseBody
 @RequestMapping(value = "treeData")
 public List<Map<String, Object>> treeData(
     String module, @RequestParam(required = false) String extId, HttpServletResponse response) {
   response.setContentType("application/json; charset=UTF-8");
   List<Map<String, Object>> mapList = Lists.newArrayList();
   List<Category> list = categoryService.findByUser(true, module);
   for (int i = 0; i < list.size(); i++) {
     Category e = list.get(i);
     if (extId == null
         || (extId != null
             && !extId.equals(e.getId())
             && e.getParentIds().indexOf("," + extId + ",") == -1)) {
       Map<String, Object> map = Maps.newHashMap();
       map.put("id", e.getId());
       map.put("pId", e.getParent() != null ? e.getParent().getId() : 0);
       map.put("name", e.getName());
       map.put("module", e.getModule());
       mapList.add(map);
     }
   }
   return mapList;
 }