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 aa722292..705d5dd1 100644 --- a/src/main/java/com/peanut/modules/book/controller/BookController.java +++ b/src/main/java/com/peanut/modules/book/controller/BookController.java @@ -348,10 +348,12 @@ public class BookController { @RequestMapping("/getChapter") @Transactional public R getChapter(@RequestParam("id") Integer id) { + bookService.getWordSection(id); BookEntity bookEntity = bookService.getBaseMapper().selectById(id); bookEntity.setChapterStatus("2"); bookService.updateById(bookEntity); + return R.ok(); } diff --git a/src/main/java/com/peanut/modules/book/service/impl/BookServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BookServiceImpl.java index c1cc8a49..b4ee7e14 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/BookServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/BookServiceImpl.java @@ -32,6 +32,7 @@ import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.util.CollectionUtils; import javax.imageio.ImageIO; @@ -454,6 +455,9 @@ public class BookServiceImpl extends ServiceImpl implements @Override public boolean getWordSection(Integer bookId) { try{ + bookChapterService.remove(new LambdaQueryWrapper().eq(BookChapterEntity::getBookId,bookId)); + bookChapterContentService.remove(new LambdaQueryWrapper().eq(BookChapterContentEntity::getBookId,bookId)); + int topText = 22; int secText = 16; BookEntity bookEntity = this.getBaseMapper().selectById(bookId); @@ -535,8 +539,11 @@ public class BookServiceImpl extends ServiceImpl implements } } } + throw new NullPointerException(); }catch (Exception e) { - e.printStackTrace();; + e.printStackTrace(); + //事务回滚 + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } return false; } diff --git a/src/main/java/com/peanut/modules/common/entity/BookChapterEntity.java b/src/main/java/com/peanut/modules/common/entity/BookChapterEntity.java index 02277d3c..5e76b3cb 100644 --- a/src/main/java/com/peanut/modules/common/entity/BookChapterEntity.java +++ b/src/main/java/com/peanut/modules/common/entity/BookChapterEntity.java @@ -62,7 +62,7 @@ public class BookChapterEntity implements Serializable { /** * */ - @TableLogic +// @TableLogic private Integer delFlag; @TableField(exist = false) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index dace4ba8..78c2dc0a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,7 +11,7 @@ connection-timeout: 6000000ms spring: # 环境 dev/dev1|test|prod profiles: - active: dev + active: dev1 # jackson时间格式化 jackson: time-zone: GMT+8