示例#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
 /**
  * 获取文章列表
  *
  * @param siteId 站点编号
  * @param categoryId 分类编号
  * @param number 获取数目
  * @param param 预留参数,例: key1:'value1', key2:'value2' ... posid 推荐位(1:首页焦点图;2:栏目页文章推荐;) image
  *     文章图片(1:有图片的文章) orderBy 排序字符串
  * @return
  */
 public static List<Article> getArticleList(
     long siteId, long categoryId, int number, String param) {
   Page<Article> page = new Page<Article>(1, number, -1);
   Article article = new Article(new Category(categoryId, new Site(siteId)));
   if (StringUtils.isNotBlank(param)) {
     @SuppressWarnings({"rawtypes"})
     Map map = JsonMapper.getInstance().fromJson("{" + param + "}", Map.class);
     if (new Integer(1).equals(map.get("posid")) || new Integer(2).equals(map.get("posid"))) {
       article.setPosid(String.valueOf(map.get("posid")));
     }
     if (new Integer(1).equals(map.get("image"))) {
       article.setImage(Article.YES);
     }
     if (StringUtils.isNotBlank((String) map.get("orderBy"))) {
       page.setOrderBy((String) map.get("orderBy"));
     }
   }
   article.setDelFlag(Article.DEL_FLAG_NORMAL);
   page = articleService.find(page, article, false);
   return page.getList();
 }
示例#3
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";
 }