use of com.zyd.blog.business.entity.Article 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.entity.Article in project OneBlog by zhangyd-c.
the class BizArticleServiceImpl method listHotArticle.
/**
* 获取热门文章
*
* @return
*/
@Override
public List<Article> listHotArticle(int pageSize) {
PageHelper.startPage(1, pageSize);
List<BizArticle> entityList = bizArticleMapper.listHotArticle();
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 RemoverServiceImpl method saveArticle.
private Article saveArticle(Long typeId, boolean isConvertImg, HunterPrintWriter writerUtil, User user, VirtualArticle virtualArticle) {
Article article = new Article();
article.setContent(isConvertImg ? parseImgForHtml(virtualArticle, writerUtil) : virtualArticle.getContent());
article.setTitle(virtualArticle.getTitle());
article.setCoverImage(CollectionUtils.isEmpty(virtualArticle.getImageLinks()) ? null : new ArrayList<>(virtualArticle.getImageLinks()).get(0).getSrcLink());
article.setTypeId(typeId);
article.setUserId(user.getId());
article.setComment(true);
article.setOriginal(true);
// 默认是草稿
article.setStatus(ArticleStatusEnum.UNPUBLISHED.getCode());
article.setIsMarkdown(false);
article.setDescription(virtualArticle.getDescription());
article.setKeywords(virtualArticle.getKeywords());
article.setEditorType("we");
article = articleService.insert(article);
writerUtil.print(String.format("[ save ] Succeed! <a href=\"%s\" target=\"_blank\">%s</a>", virtualArticle.getSource(), article.getTitle()));
return article;
}
use of com.zyd.blog.business.entity.Article 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();
}
use of com.zyd.blog.business.entity.Article in project OneBlog by zhangyd-c.
the class RemoverServiceImpl method saveArticles.
private void saveArticles(Long typeId, HunterConfig config, HunterPrintWriter writerUtil, CopyOnWriteArrayList<VirtualArticle> list) {
// 获取数据库中的标签列表
List<Tags> tags = tagsService.listAll();
Map<String, Long> originalTags = tags.stream().collect(Collectors.toMap(tag -> tag.getName().toUpperCase(), Tags::getId));
User user = SessionUtil.getUser();
// 添加文章到数据库
Article article = null;
for (VirtualArticle spiderVirtualArticle : list) {
article = this.saveArticle(typeId, config.isConvertImg(), writerUtil, user, spiderVirtualArticle);
this.saveTags(writerUtil, originalTags, article, spiderVirtualArticle);
}
}
Aggregations