diff --git a/src/main/java/com/peanut/modules/book/controller/BookController.java b/src/main/java/com/peanut/modules/book/controller/BookController.java index 20b4a99..6f2247d 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookController.java @@ -424,46 +424,48 @@ public class BookController { XWPFParagraph paragraph = (XWPFParagraph) element; String text = paragraph.getText(); if (text != null && !text.isEmpty()) {//处理段落或正文 - if (heading1Llist.contains(text)||paragraph.getRuns().get(0).getFontSize()>=topText){//判断是否是顶级标题 - chapterName = text; - BookChapterEntity bookChapter = new BookChapterEntity(); - bookChapter.setBookId(bookEntity.getId()); - bookChapter.setLanguage(language); - bookChapter.setChapter(text); - bookChapter.setNumber(number++); - for (int j=1;j=secText){//判断是否是二级标题 - if (StringUtils.isNotBlank(chapterName)){ + if (paragraph.getRuns().size() > 0){ + if (heading1Llist.contains(text)||paragraph.getRuns().get(0).getFontSize()>=topText){//判断是否是顶级标题 + chapterName = text; BookChapterEntity bookChapter = new BookChapterEntity(); bookChapter.setBookId(bookEntity.getId()); bookChapter.setLanguage(language); - bookChapter.setChapter(chapterName); - bookChapter.setContent(text); + bookChapter.setChapter(text); bookChapter.setNumber(number++); - bookChapterService.save(bookChapter); - bookChapterId = bookChapter.getId(); - } - }else {//正文 - if (bookChapterId!=0){ - BookChapterContentEntity contentEntity = new BookChapterContentEntity(); - contentEntity.setBookId(bookEntity.getId()); - contentEntity.setLanguage(language); - contentEntity.setBookChatperId(bookChapterId); - contentEntity.setContent(text); - contentEntity.setNumber(number++); - contentsBatch.add(contentEntity); + for (int j=1;j=secText){//判断是否是二级标题 + if (StringUtils.isNotBlank(chapterName)){ + BookChapterEntity bookChapter = new BookChapterEntity(); + bookChapter.setBookId(bookEntity.getId()); + bookChapter.setLanguage(language); + bookChapter.setChapter(chapterName); + bookChapter.setContent(text); + bookChapter.setNumber(number++); + bookChapterService.save(bookChapter); + bookChapterId = bookChapter.getId(); + } + }else {//正文 + if (bookChapterId!=0){ + BookChapterContentEntity contentEntity = new BookChapterContentEntity(); + contentEntity.setBookId(bookEntity.getId()); + contentEntity.setLanguage(language); + contentEntity.setBookChatperId(bookChapterId); + contentEntity.setContent(text); + contentEntity.setNumber(number++); + contentsBatch.add(contentEntity); + } } } } else {// 顺序遍历图片