コード例 #1
0
 /** 通过编号获取文章标题 */
 @RequiresPermissions("cms:article:view")
 @ResponseBody
 @RequestMapping(value = "findByIds")
 public String findByIds(String ids) {
   List<Object[]> list = articleService.findByIds(ids);
   return JsonMapper.nonDefaultMapper().toJson(list);
 }
コード例 #2
0
 @ModelAttribute
 public Article get(@RequestParam(required = false) String id) {
   if (StringUtils.isNotBlank(id)) {
     return articleService.get(id);
   } else {
     return new Article();
   }
 }
コード例 #3
0
 @RequestMapping(value = {"listNews"})
 public String listNews(
     Article article, HttpServletRequest request, HttpServletResponse response, Model model) {
   Page<Article> page =
       articleService.findPageByMsgType(new Page<Article>(request, response), article, true);
   model.addAttribute("page", page);
   //        model.addAttribute("article", article);
   return "modules/cms/newsArticleList";
 }
コード例 #4
0
 @RequiresPermissions("cms:article:view")
 @RequestMapping(value = {"list", ""})
 public String list(
     Article article, HttpServletRequest request, HttpServletResponse response, Model model) {
   //		for (int i=0; i<10000000; i++){
   //			Article a = new Article();
   //			a.setCategory(new Category(article.getCategory().getId()));
   //			a.setTitle("测试测试测试测试测试测试测试测试"+a.getCategory().getId());
   //			a.setArticleData(new ArticleData());
   //			a.getArticleData().setContent(a.getTitle());
   //			articleService.save(a);
   //		}
   Page<Article> page =
       articleService.findPage(new Page<Article>(request, response), article, true);
   model.addAttribute("page", page);
   return "modules/cms/articleList";
 }
コード例 #5
0
 @RequiresPermissions("cms:article:edit")
 @RequestMapping(value = "delete")
 public String delete(
     Article article,
     String categoryId,
     @RequestParam(required = false) Boolean isRe,
     RedirectAttributes redirectAttributes) {
   // 如果没有审核权限,则不允许删除或发布。
   if (!UserUtils.getSubject().isPermitted("cms:article:audit")) {
     addMessage(redirectAttributes, "你没有删除或发布权限");
   }
   articleService.delete(article, isRe);
   addMessage(redirectAttributes, (isRe != null && isRe ? "发布" : "删除") + "文章成功");
   return "redirect:"
       + adminPath
       + "/cms/article/?repage&category.id="
       + (categoryId != null ? categoryId : "");
 }
コード例 #6
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);
    }

    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 : "");
  }