use of com.zyd.blog.business.vo.ArticleConditionVO in project OneBlog by zhangyd-c.
the class BizArticleServiceImpl method listRecommended.
/**
* 站长推荐
*
* @param pageSize
* @return
*/
@Override
public List<Article> listRecommended(int pageSize) {
ArticleConditionVO vo = new ArticleConditionVO();
vo.setRecommended(true);
vo.setStatus(ArticleStatusEnum.PUBLISHED.getCode());
vo.setPageSize(pageSize);
PageInfo pageInfo = this.findPageBreakByCondition(vo);
return null == pageInfo ? null : pageInfo.getList();
}
use of com.zyd.blog.business.vo.ArticleConditionVO in project OneBlog by zhangyd-c.
the class BizArticleServiceImpl method findPageBreakByCondition.
/**
* 分页查询
*
* @param vo
* @return
*/
@Override
public PageInfo<Article> findPageBreakByCondition(ArticleConditionVO vo) {
PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
List<BizArticle> list = bizArticleMapper.findPageBreakByCondition(vo);
if (CollectionUtils.isEmpty(list)) {
return null;
}
List<Long> ids = list.stream().map(BizArticle::getId).collect(Collectors.toList());
List<BizArticle> listTag = bizArticleMapper.listTagsByArticleId(ids);
Map<Long, BizArticle> tagMap = listTag.stream().collect(Collectors.toMap(BizArticle::getId, a -> a, (k1, k2) -> k1));
List<Article> boList = new LinkedList<>();
Article article = null;
for (BizArticle bizArticle : list) {
BizArticle tagArticle = tagMap.get(bizArticle.getId());
if (null == tagArticle) {
log.warn("文章[{}] 未绑定标签信息,或者已绑定的标签不存在!", bizArticle.getTitle());
} else {
bizArticle.setTags(tagArticle.getTags());
}
this.subquery(bizArticle);
article = new Article(bizArticle);
article.setPassword(null);
boList.add(article);
}
PageInfo bean = new PageInfo<BizArticle>(list);
bean.setList(boList);
return bean;
}
use of com.zyd.blog.business.vo.ArticleConditionVO in project OneBlog by zhangyd-c.
the class BizArticleServiceImpl method listRelatedArticle.
/**
* 根据某篇文章获取与该文章相关的文章<br>
* 搜索同类型、同标签下的文章
*
* @param pageSize
* @param article
* @return
*/
@Override
public List<Article> listRelatedArticle(int pageSize, Article article) {
if (null == article) {
return listRandom(pageSize);
}
ArticleConditionVO vo = new ArticleConditionVO();
vo.setStatus(ArticleStatusEnum.PUBLISHED.getCode());
List<BizTags> tags = article.getTags();
if (!CollectionUtils.isEmpty(tags)) {
List<Long> tagIds = new ArrayList<>();
for (BizTags tag : tags) {
tagIds.add(tag.getId());
}
vo.setTagIds(tagIds);
}
vo.setTypeId(article.getTypeId());
vo.setPageSize(pageSize);
PageInfo pageInfo = this.findPageBreakByCondition(vo);
return null == pageInfo ? null : pageInfo.getList();
}
use of com.zyd.blog.business.vo.ArticleConditionVO in project OneBlog by zhangyd-c.
the class RenderController method type.
/**
* 分类列表
*
* @param typeId
* @param model
* @return
*/
@GetMapping("/type/{typeId}")
@BussinessLog(value = "进入文章分类[{1}]列表页", platform = PlatformEnum.WEB)
public ModelAndView type(@PathVariable("typeId") Long typeId, Model model) {
ArticleConditionVO vo = new ArticleConditionVO();
vo.setTypeId(typeId);
model.addAttribute("url", "type/" + typeId);
loadIndexPage(vo, model);
return ResultUtil.view(INDEX_URL);
}
use of com.zyd.blog.business.vo.ArticleConditionVO in project OneBlog by zhangyd-c.
the class ArticleTags method typeList.
public Object typeList(Map params) {
int pageSize = this.getPageSize(params);
long typeId = -1;
String typeStr = getParam(params, "typeId");
if (!StringUtils.isEmpty(typeStr)) {
typeId = Long.parseLong(typeStr);
}
// 按文章分类查询
ArticleConditionVO vo = new ArticleConditionVO();
vo.setTypeId(typeId);
// 已发布状态
vo.setStatus(ArticleStatusEnum.PUBLISHED.getCode());
vo.setPageSize(pageSize);
PageInfo<Article> pageInfo = articleService.findPageBreakByCondition(vo);
return null == pageInfo ? null : pageInfo.getList();
}
Aggregations