use of com.ganster.cms.web.dto.ModelResult in project Ganster-CMS by Gangster-trio.
the class SiteController method show.
@RequestMapping("/{siteUrl}")
public String show(@PathVariable("siteUrl") String siteUrl, Model model) {
ModelResult result = webService.getSiteModel(siteUrl);
if (result == null) {
return "404";
}
// Add result to module
model.addAttribute("result", result);
Site site = (Site) result.get("site");
// If skin = null, set default skin
if (site.getSiteSkin() == null) {
site.setSiteSkin(CmsConst.DEFAULT_SKIN);
}
// Return to the site's skin view, for example : default-site
return site.getSiteSkin() + CmsConst.SITE_SKIN_SUFFIX;
}
use of com.ganster.cms.web.dto.ModelResult in project Ganster-CMS by Gangster-trio.
the class WebService method getArticleModel.
public ModelResult getArticleModel(Integer id) {
Article article = articleService.selectByPrimaryKey(id);
ModelResult result = new ModelResult();
if (article == null) {
return null;
}
// Get article's site
Site site = siteService.selectByPrimaryKey(article.getArticleSiteId());
// Get article's category
Category category = categoryService.selectByPrimaryKey(article.getArticleCategoryId());
// Get article's tags
List<Tag> tagList = tagService.selectByArticleId(id);
// Get 0 level categorise in this site (displayed above the homepage of the website)
CategoryExample categoryExample = new CategoryExample();
categoryExample.or().andCategorySiteIdEqualTo(article.getArticleSiteId()).andCategoryLevelEqualTo(0);
List<Category> categoryList = categoryService.selectByExample(categoryExample);
// Each level 0 category into category tree
List<CategoryTree> categoryTreeList = categoryList.stream().map(categoryService::toTree).collect(Collectors.toList());
result.put("category", category).put("article", article).put("tagList", tagList).put("categoryTreeList", categoryTreeList).put("site", site);
// hit add
if (article.getArticleHit() == null) {
article.setArticleHit(0);
}
article.setArticleHit(article.getArticleHit() + 1);
articleService.updateByPrimaryKeySelective(article);
return result;
}
use of com.ganster.cms.web.dto.ModelResult in project Ganster-CMS by Gangster-trio.
the class WebService method getCategoryModel.
public ModelResult getCategoryModel(Integer id) {
ModelResult result = new ModelResult();
Category category = categoryService.selectByPrimaryKey(id);
if (category == null) {
return null;
}
// ---------------------------------------default properties start----------------------------------------------//
Site site = siteService.selectByPrimaryKey(category.getCategorySiteId());
// Get 0 level categorise in this site (displayed above the homepage of the website)
CategoryExample categoryExample = new CategoryExample();
categoryExample.or().andCategorySiteIdEqualTo(category.getCategorySiteId()).andCategoryLevelEqualTo(0);
List<Category> categoryList = categoryService.selectByExample(categoryExample);
// Each level 0 category into category tree
List<CategoryTree> categoryTreeList = categoryList.stream().map(categoryService::toTree).collect(Collectors.toList());
// Get this category's article list (without BLOBs)
ArticleExample articleExample = new ArticleExample();
articleExample.or().andArticleCategoryIdEqualTo(id);
List<Article> articleList = articleService.selectByExample(articleExample);
result.put("categoryTreeList", categoryTreeList).put("articleList", articleList).put("category", category).put("site", site);
return result;
}
use of com.ganster.cms.web.dto.ModelResult in project Ganster-CMS by Gangster-trio.
the class ArticleController method show.
@RequestMapping("{id}")
public String show(@PathVariable("id") Integer id, Model model) {
ModelResult result = webService.getArticleModel(id);
if (result == null) {
return "404";
}
model.addAttribute("result", result);
Article article = (Article) result.get("article");
// If skin = null, set default skin
if (article.getArticleSkin() == null) {
article.setArticleSkin(CmsConst.DEFAULT_SKIN);
}
// Return to the site's skin view, for example : default-article
return article.getArticleSkin() + CmsConst.ARTICLE_SKIN_SUFFIX;
}
use of com.ganster.cms.web.dto.ModelResult in project Ganster-CMS by Gangster-trio.
the class CategoryController method show.
@RequestMapping("{id}")
public String show(@PathVariable("id") Integer id, Model model) {
ModelResult result = webService.getCategoryModel(id);
if (result == null) {
return "404";
}
// Add result to module
model.addAttribute("result", result);
Category category = (Category) result.get("category");
// If skin = null, set default skin
if (category.getCategorySkin() == null) {
category.setCategorySkin(CmsConst.DEFAULT_SKIN);
}
// Return to the site's skin view, for example : default-category
return category.getCategorySkin() + CmsConst.CATEGORY_SKIN_SUFFIX;
}
Aggregations