From 1b6cc8ccd5279cc2fe488b3778c78d71cd23a47c Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <773861846@qq.com> Date: Thu, 24 Dec 2020 00:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=88=AC=E8=99=AB=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/java2nb/novel/core/crawl/CrawlParser.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 1cd1c95..eb30f0f 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 @@ -232,7 +232,6 @@ public class CrawlParser { bookContent.setContent(content); contentList.add(bookContent); - if (hasIndex != null) { //章节更新 bookIndex.setId(hasIndex.getId()); @@ -241,8 +240,6 @@ public class CrawlParser { //章节插入 //设置目录和章节内容 Long indexId = idWorker.nextId(); - lastIndexId = indexId; - lastIndexName = indexName; bookIndex.setId(indexId); bookIndex.setBookId(book.getId()); @@ -252,8 +249,14 @@ public class CrawlParser { } bookIndex.setUpdateTime(currentDate); - //计算总字数 - totalWordCount += wordCount; + //判断是新书入库还是老书更新 + if (hasIndexs.size() == 0) { + //新书入库 + lastIndexId = bookIndex.getId(); + lastIndexName = indexName; + //计算总字数 + totalWordCount += wordCount; + } }