Пример #1
0
 @RequiresPermissions("cms:article:edit")
 @RequestMapping(value = "save")
 public String save(Article article, Model model, RedirectAttributes redirectAttributes) {
   if (!beanValidator(model, article)) {
     return form(article, model);
   }
   articleService.save(article);
   addMessage(redirectAttributes, "保存文章'" + StringUtils.abbr(article.getTitle(), 50) + "'成功");
   String categoryId = article.getCategory() != null ? article.getCategory().getId() : null;
   return "redirect:"
       + adminPath
       + "/cms/article/?repage&category.id="
       + (categoryId != null ? categoryId : "");
 }
Пример #2
0
 @RequiresPermissions("cms:article:view")
 @RequestMapping(value = "form")
 public String form(Article article, Model model) {
   // 如果当前传参有子节点,则选择取消传参选择
   if (article.getCategory() != null && StringUtils.isNotBlank(article.getCategory().getId())) {
     List<Category> list =
         categoryService.findByParentId(article.getCategory().getId(), Site.getCurrentSiteId());
     if (list.size() > 0) {
       article.setCategory(null);
     } else {
       article.setCategory(categoryService.get(article.getCategory().getId()));
     }
   }
   article.setArticleData(articleDataService.get(article.getId()));
   //		if (article.getCategory()=null && StringUtils.isNotBlank(article.getCategory().getId())){
   //			Category category = categoryService.get(article.getCategory().getId());
   //		}
   model.addAttribute("contentViewList", getTplContent());
   model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
   model.addAttribute("article", article);
   CmsUtils.addViewConfigAttribute(model, article.getCategory());
   return "modules/cms/articleForm";
 }