@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())); model.addAttribute("article", article); CmsUtils.addViewConfigAttribute(model, article.getCategory()); if (0 == article.getMsgType()) { return "modules/cms/articleForm"; } else if (1 == article.getMsgType()) { return "modules/cms/articleSingleForm"; } else if (2 == article.getMsgType()) { return "modules/cms/articleManyForm"; } return "modules/cms/articleForm"; }
@RequiresPermissions("cms:article:edit") @RequestMapping(value = "save") public String save(Article article, Model model, RedirectAttributes redirectAttributes) { if (!beanValidator(model, article)) { return form(article, model); } article.setDescription(Encodes.unescapeHtml(article.getDescription())); article.setDesJson(Encodes.unescapeXml(article.getDesJson())); 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 : ""); }