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

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


  /**
   * 显示内容
   */
  @RequestMapping(value = "view-{categoryId}-{contentId}${urlSuffix}")
  public String view(@PathVariable String categoryId, @PathVariable String contentId, Model model) {
    Category category = categoryService.get(categoryId);
    if (category==null){
      Site site = CmsUtils.getSite(Site.defaultSiteId());
      model.addAttribute("site", site);
      return "error/404";
    }
    model.addAttribute("site", category.getSite());
    if ("article".equals(category.getModule())){
      // 如果没有子栏目,并父节点为跟节点的,栏目列表为当前栏目。
      List<Category> categoryList = Lists.newArrayList();
      if (category.getParent().getId().equals("1")){
        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


   *          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")));
View Full Code Here

   * @param param  预留参数,例: key1:'value1', key2:'value2' ...
   * @return
   */
  public static List<Link> getLinkList(String siteId, String categoryId, int number, String param){
    Page<Link> page = new Page<Link>(1, number, -1);
    Link link = new Link(new Category(categoryId, new Site(siteId)));
    if (StringUtils.isNotBlank(param)){
      @SuppressWarnings({ "unused", "rawtypes" })
      Map map = JsonMapper.getInstance().fromJson("{"+param+"}", Map.class);
    }
    link.setDelFlag(Link.DEL_FLAG_NORMAL);
View Full Code Here

  }

    private String getTpl(Article article){
        if(StringUtils.isBlank(article.getCustomContentView())){
            String view = null;
            Category c = article.getCategory();
            boolean goon = true;
            do{
                if(StringUtils.isNotBlank(c.getCustomContentView())){
                    view = c.getCustomContentView();
                    goon = false;
                }else if(c.getParent() == null || c.getParent().isRoot()){
                    goon = false;
                }else{
                    c = c.getParent();
                }
            }while(goon);
            return StringUtils.isBlank(view) ? Article.DEFAULT_TEMPLATE : view;
        }else{
            return article.getCustomContentView();
View Full Code Here

        }
    }

    private void setTplModelAttribute(Model model, Category category){
        List<Category> categoryList = Lists.newArrayList();
        Category c = category;
        boolean goon = true;
        do{
            if(c.getParent() == null || c.getParent().isRoot()){
                goon = false;
            }
            categoryList.add(c);
            c = c.getParent();
        }while(goon);
        Collections.reverse(categoryList);
        for(Category ca : categoryList){
            setTplModelAttribute(model, ca.getViewConfig());
        }
View Full Code Here

    CmsUtils.removeCache("mainNavList_"+category.getSite().getId());
  }
 
  @Transactional(readOnly = false)
  public void delete(String id) {
    Category category = get(id);
    if (category!=null){
      categoryDao.deleteById(id, "%,"+id+",%");
      UserUtils.removeCache(CACHE_CATEGORY_LIST);
      CmsUtils.removeCache("mainNavList_"+category.getSite().getId());
    }
  }
View Full Code Here

    }
    DetachedCriteria dc = linkDao.createDetachedCriteria();
    dc.createAlias("category", "category");
    dc.createAlias("category.site", "category.site");
    if (link.getCategory()!=null && StringUtils.isNotBlank(link.getCategory().getId()) && !Category.isRoot(link.getCategory().getId())){
      Category category = categoryDao.get(link.getCategory().getId());
      if (category!=null){
        dc.add(Restrictions.or(
            Restrictions.eq("category.id", category.getId()),
            Restrictions.like("category.parentIds", "%,"+category.getId()+",%")));
        dc.add(Restrictions.eq("category.site.id", category.getSite().getId()));
        link.setCategory(category);
      }else{
        dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
      }
    }else{
View Full Code Here

    if (!SecurityUtils.getSubject().isPermitted("cms:link:audit")){
      link.setDelFlag(Link.DEL_FLAG_AUDIT);
    }
    // 如果栏目不需要审核,则将该内容设为发布状态
    if (link.getCategory()!=null&&StringUtils.isNotBlank(link.getCategory().getId())){
      Category category = categoryDao.get(link.getCategory().getId());
      if (!Article.YES.equals(category.getIsAudit())){
        link.setDelFlag(Article.DEL_FLAG_NORMAL);
      }
    }
    linkDao.clear();
    linkDao.save(link);
View Full Code Here

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

  @RequiresPermissions("cms:category:view")
  @RequestMapping(value = "form")
  public String form(Category category, Model model) {
    if (category.getParent()==null||category.getParent().getId()==null){
      category.setParent(new Category("1"));
    }
    category.setParent(categoryService.get(category.getParent().getId()));
    if (category.getOffice()==null||category.getOffice().getId()==null){
      category.setOffice(category.getParent().getOffice());
    }
View Full Code Here

TOP

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

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.