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