@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"; }
@ModelAttribute public Article get(@RequestParam(required = false) String id) { if (StringUtils.isNotBlank(id)) { return articleService.get(id); } else { return new Article(); } }