Search in sources :

Example 1 with HunterConfig

use of me.zhyd.hunter.config.HunterConfig 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);
    }
}
Also used : ArticleStatusEnum(com.zyd.blog.business.enums.ArticleStatusEnum) java.util(java.util) User(com.zyd.blog.business.entity.User) Autowired(org.springframework.beans.factory.annotation.Autowired) Hunter(me.zhyd.hunter.Hunter) HunterConfig(me.zhyd.hunter.config.HunterConfig) Service(org.springframework.stereotype.Service) BizTagsService(com.zyd.blog.business.service.BizTagsService) BizArticleService(com.zyd.blog.business.service.BizArticleService) PrintWriter(java.io.PrintWriter) Validated(org.springframework.validation.annotation.Validated) SessionUtil(com.zyd.blog.util.SessionUtil) ImageLink(me.zhyd.hunter.entity.ImageLink) HunterPrintWriter(me.zhyd.hunter.util.HunterPrintWriter) BlogHunterProcessor(me.zhyd.hunter.processor.BlogHunterProcessor) Article(com.zyd.blog.business.entity.Article) Collectors(java.util.stream.Collectors) VirtualArticle(me.zhyd.hunter.entity.VirtualArticle) BizArticleTagsService(com.zyd.blog.business.service.BizArticleTagsService) RemoverService(com.zyd.blog.business.service.RemoverService) Tags(com.zyd.blog.business.entity.Tags) ImageDownloadUtil(com.zyd.blog.business.util.ImageDownloadUtil) CollectionUtils(org.springframework.util.CollectionUtils) HunterProcessor(me.zhyd.hunter.processor.HunterProcessor) Transactional(org.springframework.transaction.annotation.Transactional) StringUtils(org.springframework.util.StringUtils) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) VirtualArticle(me.zhyd.hunter.entity.VirtualArticle) User(com.zyd.blog.business.entity.User) Article(com.zyd.blog.business.entity.Article) VirtualArticle(me.zhyd.hunter.entity.VirtualArticle) Tags(com.zyd.blog.business.entity.Tags)

Aggregations

Article (com.zyd.blog.business.entity.Article)1 Tags (com.zyd.blog.business.entity.Tags)1 User (com.zyd.blog.business.entity.User)1 ArticleStatusEnum (com.zyd.blog.business.enums.ArticleStatusEnum)1 BizArticleService (com.zyd.blog.business.service.BizArticleService)1 BizArticleTagsService (com.zyd.blog.business.service.BizArticleTagsService)1 BizTagsService (com.zyd.blog.business.service.BizTagsService)1 RemoverService (com.zyd.blog.business.service.RemoverService)1 ImageDownloadUtil (com.zyd.blog.business.util.ImageDownloadUtil)1 SessionUtil (com.zyd.blog.util.SessionUtil)1 PrintWriter (java.io.PrintWriter)1 java.util (java.util)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Collectors (java.util.stream.Collectors)1 Hunter (me.zhyd.hunter.Hunter)1 HunterConfig (me.zhyd.hunter.config.HunterConfig)1 ImageLink (me.zhyd.hunter.entity.ImageLink)1 VirtualArticle (me.zhyd.hunter.entity.VirtualArticle)1 BlogHunterProcessor (me.zhyd.hunter.processor.BlogHunterProcessor)1 HunterProcessor (me.zhyd.hunter.processor.HunterProcessor)1