fix: 修复单本小说采集即使没有采集到内容仍然标记状态为采集成功的问题

This commit is contained in:
xiaoyang 2021-12-17 10:20:59 +08:00
parent b2eb6686e9
commit 78969f9fd1
2 changed files with 6 additions and 4 deletions

View File

@ -139,7 +139,7 @@ public class CrawlParser {
handler.handle(book);
}
public static void parseBookIndexAndContent(String sourceBookId, Book book, RuleBean ruleBean, Map<Integer, BookIndex> existBookIndexMap, CrawlBookChapterHandler handler) {
public static boolean parseBookIndexAndContent(String sourceBookId, Book book, RuleBean ruleBean, Map<Integer, BookIndex> existBookIndexMap, CrawlBookChapterHandler handler) {
Date currentDate = new Date();
@ -275,7 +275,7 @@ public class CrawlParser {
setBookContentList(contentList);
}});
return;
return true;
}
@ -285,6 +285,7 @@ public class CrawlParser {
setBookIndexList(new ArrayList<>(0));
setBookContentList(new ArrayList<>(0));
}});
return false;
}

View File

@ -302,15 +302,16 @@ public class CrawlServiceImpl implements CrawlService {
book.setCrawlLastTime(new Date());
book.setId(IdWorker.INSTANCE.nextId());
//解析章节目录
CrawlParser.parseBookIndexAndContent(bookId, book, ruleBean, new HashMap<>(0), chapter -> {
boolean parseIndexContentResult = CrawlParser.parseBookIndexAndContent(bookId, book, ruleBean, new HashMap<>(0), chapter -> {
bookService.saveBookAndIndexAndContent(book, chapter.getBookIndexList(), chapter.getBookContentList());
});
parseResult.set(parseIndexContentResult);
} else {
//只更新书籍的爬虫相关字段
bookService.updateCrawlProperties(existBook.getId(), sourceId, bookId);
parseResult.set(true);
}
parseResult.set(true);
});
return parseResult.get();