diff --git a/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java b/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java index 85955cd..9ec4628 100644 --- a/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java +++ b/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java @@ -139,7 +139,7 @@ public class CrawlParser { handler.handle(book); } - public static void parseBookIndexAndContent(String sourceBookId, Book book, RuleBean ruleBean, Map existBookIndexMap, CrawlBookChapterHandler handler) { + public static boolean parseBookIndexAndContent(String sourceBookId, Book book, RuleBean ruleBean, Map 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; } diff --git a/novel-crawl/src/main/java/com/java2nb/novel/service/impl/CrawlServiceImpl.java b/novel-crawl/src/main/java/com/java2nb/novel/service/impl/CrawlServiceImpl.java index 2e95141..028f44b 100644 --- a/novel-crawl/src/main/java/com/java2nb/novel/service/impl/CrawlServiceImpl.java +++ b/novel-crawl/src/main/java/com/java2nb/novel/service/impl/CrawlServiceImpl.java @@ -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();