use of com.zyd.blog.business.entity.Article in project OneBlog by zhangyd-c.
the class BizArticleServiceImpl method getPrevAndNextArticles.
/**
* 获取上一篇和下一篇
*
* @return
*/
@Override
public Map<String, Article> getPrevAndNextArticles(Date insertTime) {
insertTime = null == insertTime ? new Date() : insertTime;
List<BizArticle> entityList = bizArticleMapper.getPrevAndNextArticles(insertTime);
if (CollectionUtils.isEmpty(entityList)) {
return null;
}
Map<String, Article> resultMap = new HashMap<>();
for (BizArticle entity : entityList) {
if (entity.getCreateTime().getTime() < insertTime.getTime()) {
resultMap.put("prev", new Article(entity));
} else {
resultMap.put("next", new Article(entity));
}
}
return resultMap;
}
use of com.zyd.blog.business.entity.Article in project OneBlog by zhangyd-c.
the class BizArticleServiceImpl method listAll.
@Override
public List<Article> listAll() {
List<BizArticle> entityList = bizArticleMapper.selectAll();
if (CollectionUtils.isEmpty(entityList)) {
return null;
}
List<Article> list = new ArrayList<>();
for (BizArticle entity : entityList) {
list.add(new Article(entity));
}
return list;
}
use of com.zyd.blog.business.entity.Article in project OneBlog by zhangyd-c.
the class RenderController method edit.
@RequiresPermissions("article:publish")
@BussinessLog(value = "进入修改文章页[id={1}]")
@GetMapping("/article/update/{id}")
public ModelAndView edit(@PathVariable("id") Long id, Model model) {
model.addAttribute("id", id);
Article article = articleService.getByPrimaryKey(id);
if (!Arrays.asList("we", "md", "tiny").contains(article.getEditorType())) {
throw new ZhydException("文章异常,未知的编辑器类型");
}
return ResultUtil.view("article/publish-" + article.getEditorType());
}
use of com.zyd.blog.business.entity.Article in project OneBlog by zhangyd-c.
the class RenderController method article.
/**
* 文章详情
*
* @param model
* @param articleId
* @return
*/
@GetMapping("/article/{articleId}")
@BussinessLog(value = "进入文章[{2}]详情页", platform = PlatformEnum.WEB)
public ModelAndView article(Model model, @PathVariable("articleId") Long articleId) {
Article article = bizArticleService.getByPrimaryKey(articleId);
if (article == null || ArticleStatusEnum.UNPUBLISHED.getCode() == article.getStatusEnum().getCode()) {
return ResultUtil.forward("/error/404");
}
if (article.getPrivate()) {
article.setPassword(null);
article.setContent(null);
article.setContentMd(null);
}
if (article.getRequiredAuth()) {
User sessionUser = SessionUtil.getUser();
if (null != sessionUser) {
article.setRequiredAuth(false);
}
}
model.addAttribute("article", article);
// 上一篇下一篇
model.addAttribute("other", bizArticleService.getPrevAndNextArticles(article.getCreateTime()));
// 相关文章
model.addAttribute("relatedList", bizArticleService.listRelatedArticle(SIDEBAR_ARTICLE_SIZE, article));
model.addAttribute("articleDetail", true);
return ResultUtil.view("article");
}
Aggregations