Package com.thinkgem.jeesite.modules.cms.entity

Examples of com.thinkgem.jeesite.modules.cms.entity.Article


  @ModelAttribute
  public Article get(@RequestParam(required=false) String id) {
    if (StringUtils.isNotBlank(id)){
      return articleService.get(id);
    }else{
      return new Article();
    }
  }
View Full Code Here


      }
      model.addAttribute("category", category);
      model.addAttribute("categoryList", categoryList);
      // 获取文章内容
      Page<Article> page = new Page<Article>(1, 1, -1);
      Article article = new Article(category);
      page = articleService.find(page, article, false);
      if (page.getList().size()>0){
        article = page.getList().get(0);
        articleService.updateHitsAddOne(article.getId());
      }
      model.addAttribute("article", article);
            setTplModelAttribute(model, category);
            setTplModelAttribute(model, article.getViewConfig());
      return "modules/cms/front/themes/"+category.getSite().getTheme()+"/"+getTpl(article);
    }else{
      List<Category> categoryList = categoryService.findByParentId(category.getId(), category.getSite().getId());
      // 展现方式为1 、无子栏目或公共模型,显示栏目内容列表
      if("1".equals(category.getShowModes())||categoryList.size()==0){
        // 有子栏目并展现方式为1,则获取第一个子栏目;无子栏目,则获取同级分类列表。
        if(categoryList.size()>0){
          category = categoryList.get(0);
        }else{
          // 如果没有子栏目,并父节点为跟节点的,栏目列表为当前栏目。
          if (category.getParent().getId().equals("1")){
            categoryList.add(category);
          }else{
            categoryList = categoryService.findByParentId(category.getParent().getId(), category.getSite().getId());
          }
        }
        model.addAttribute("category", category);
        model.addAttribute("categoryList", categoryList);
        // 获取内容列表
        if ("article".equals(category.getModule())){
          Page<Article> page = new Page<Article>(pageNo, pageSize);
          page = articleService.find(page, new Article(category), false);
          model.addAttribute("page", page);
          // 如果第一个子栏目为简介类栏目,则获取该栏目第一篇文章
          if ("2".equals(category.getShowModes())){
            Article article = new Article(category);
            if (page.getList().size()>0){
              article = page.getList().get(0);
              articleService.updateHitsAddOne(article.getId());
            }
            model.addAttribute("article", article);
                        setTplModelAttribute(model, category);
                        setTplModelAttribute(model, article.getViewConfig());
            return "modules/cms/front/themes/"+category.getSite().getTheme()+"/"+getTpl(article);
          }
        }else if ("link".equals(category.getModule())){
          Page<Link> page = new Page<Link>(1, -1);
          page = linkService.find(page, new Link(category), false);
View Full Code Here

        categoryList.add(category);
      }else{
        categoryList = categoryService.findByParentId(category.getParent().getId(), category.getSite().getId());
      }
      // 获取文章内容
      Article article = articleService.get(contentId);
      if (article==null || !Article.DEL_FLAG_NORMAL.equals(article.getDelFlag())){
        return "error/404";
      }
      // 文章阅读次数+1
      articleService.updateHitsAddOne(contentId);
      // 获取推荐文章列表
      List<Object[]> relationList = articleService.findByIds(article.getArticleData().getRelation());
      // 将数据传递到视图
      model.addAttribute("category", article.getCategory());
      model.addAttribute("categoryList", categoryList);
      model.addAttribute("article", article);
      model.addAttribute("relationList", relationList);
            setTplModelAttribute(model, article.getCategory());
            setTplModelAttribute(model, article.getViewConfig());
      return "modules/cms/front/themes/"+category.getSite().getTheme()+"/"+getTpl(article);
    }
    return "error/404";
  }
View Full Code Here

 
  @Transactional(readOnly = false)
  public void delete(String id, Boolean isRe) {
//    articleDao.updateDelFlag(id, isRe!=null&&isRe?Article.DEL_FLAG_NORMAL:Article.DEL_FLAG_DELETE);
    // 使用下面方法,以便更新索引。
    Article article = articleDao.get(id);
    article.setDelFlag(isRe!=null&&isRe?Article.DEL_FLAG_NORMAL:Article.DEL_FLAG_DELETE);
    articleDao.save(article);
  }
View Full Code Here

   *          orderBy 排序字符串
   * @return
   */
  public static List<Article> getArticleList(String siteId, String 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();
  }
View Full Code Here

TOP

Related Classes of com.thinkgem.jeesite.modules.cms.entity.Article

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.