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

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


  public List<Map<String, Object>> treeData(String module, @RequestParam(required=false) Long extId, HttpServletResponse response) {
    response.setContentType("application/json; charset=UTF-8");
    List<Map<String, Object>> mapList = Lists.newArrayList();
    List<Category> list = categoryService.findByUser(true, module);
    for (int i=0; i<list.size(); i++){
      Category e = list.get(i);
      if (extId == null || (extId!=null && !extId.equals(e.getId()) && e.getParentIds().indexOf(","+extId+",")==-1)){
        Map<String, Object> map = Maps.newHashMap();
        map.put("id", e.getId());
        map.put("pId", e.getParent()!=null?e.getParent().getId():0);
        map.put("name", e.getName());
        map.put("module", e.getModule());
        mapList.add(map);
      }
    }
    return mapList;
  }
View Full Code Here


   * 内容列表
   */
  @RequestMapping(value = "list-{categoryId}${urlSuffix}")
  public String list(@PathVariable String categoryId, @RequestParam(required=false, defaultValue="1") Integer pageNo,
      @RequestParam(required=false, defaultValue="15") Integer pageSize, 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());
    // 2:简介类栏目,栏目第一条内容
    if("2".equals(category.getShowModes()) && "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());
      }
      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);
          model.addAttribute("page", page);
        }
        String view = "/frontList";
        if (StringUtils.isNotBlank(category.getCustomListView())){
          view = "/"+category.getCustomListView();
        }
                setTplModelAttribute(model, category);
        return "modules/cms/front/themes/"+category.getSite().getTheme()+view;
      }
      // 有子栏目:显示子栏目列表
      else{
        model.addAttribute("category", category);
        model.addAttribute("categoryList", categoryList);
        String view = "/frontListCategory";
        if (StringUtils.isNotBlank(category.getCustomListView())){
          view = "/"+category.getCustomListView();
        }
                setTplModelAttribute(model, category);
        return "modules/cms/front/themes/"+category.getSite().getTheme()+view;
      }
    }
  }
View Full Code Here

    }
    DetachedCriteria dc = articleDao.createDetachedCriteria();
    dc.createAlias("category", "category");
    dc.createAlias("category.site", "category.site");
    if (article.getCategory()!=null && StringUtils.isNotBlank(article.getCategory().getId()) && !Category.isRoot(article.getCategory().getId())){
      Category category = categoryDao.get(article.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()));
        article.setCategory(category);
      }else{
        dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
      }
    }else{
View Full Code Here

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

   */
  public static List<Category> getMainNavList(String siteId){
    @SuppressWarnings("unchecked")
    List<Category> mainNavList = (List<Category>)CacheUtils.get(CMS_CACHE, "mainNavList_"+siteId);
    if (mainNavList == null){
      Category category = new Category();
      category.setSite(new Site(siteId));
      category.setParent(new Category("1"));
      category.setInMenu(Category.SHOW);
      Page<Category> page = new Page<Category>(1, -1);
      page = categoryService.find(page, category);
      mainNavList = page.getList();
      CacheUtils.put(CMS_CACHE, "mainNavList_"+siteId, mainNavList);
    }
View Full Code Here

   * 内容列表(通过url自定义视图)
   */
  @RequestMapping(value = "listc-{categoryId}-{customView}${urlSuffix}")
  public String listCustom(@PathVariable String categoryId, @PathVariable String customView, @RequestParam(required=false, defaultValue="1") Integer pageNo,
      @RequestParam(required=false, defaultValue="15") Integer pageSize, 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());
    List<Category> categoryList = categoryService.findByParentId(category.getId(), category.getSite().getId());
    model.addAttribute("category", category);
    model.addAttribute("categoryList", categoryList);
        setTplModelAttribute(model, category);
    return "modules/cms/front/themes/"+category.getSite().getTheme()+"/frontListCategory"+customView;
  }
View Full Code Here

   * @param number 获取数目
   * @param param  预留参数,例: key1:'value1', key2:'value2' ...
   */
  public static List<Category> getCategoryList(String siteId, String parentId, int number, String param){
    Page<Category> page = new Page<Category>(1, number, -1);
    Category category = new Category();
    category.setSite(new Site(siteId));
    category.setParent(new Category(parentId));
    if (StringUtils.isNotBlank(param)){
      @SuppressWarnings({ "unused", "rawtypes" })
      Map map = JsonMapper.getInstance().fromJson("{"+param+"}", Map.class);
    }
    page = categoryService.find(page, category);
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.