修改事务

This commit is contained in:
wuchunlei
2024-12-04 18:00:24 +08:00
parent d9651adb6f
commit 94682e011a
2 changed files with 10 additions and 10 deletions

View File

@@ -348,13 +348,14 @@ public class BookController {
@RequestMapping("/getChapter") @RequestMapping("/getChapter")
@Transactional @Transactional
public R getChapter(@RequestParam("id") Integer id) { public R getChapter(@RequestParam("id") Integer id) {
if (bookService.getWordSection(id)){
bookService.getWordSection(id); BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
BookEntity bookEntity = bookService.getBaseMapper().selectById(id); bookEntity.setChapterStatus("2");
bookEntity.setChapterStatus("2"); bookService.updateById(bookEntity);
bookService.updateById(bookEntity); return R.ok();
}else {
return R.ok(); return R.error();
}
} }

View File

@@ -457,7 +457,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
try{ try{
bookChapterService.remove(new LambdaQueryWrapper<BookChapterEntity>().eq(BookChapterEntity::getBookId,bookId)); bookChapterService.remove(new LambdaQueryWrapper<BookChapterEntity>().eq(BookChapterEntity::getBookId,bookId));
bookChapterContentService.remove(new LambdaQueryWrapper<BookChapterContentEntity>().eq(BookChapterContentEntity::getBookId,bookId)); bookChapterContentService.remove(new LambdaQueryWrapper<BookChapterContentEntity>().eq(BookChapterContentEntity::getBookId,bookId));
int topText = 22; int topText = 22;
int secText = 16; int secText = 16;
BookEntity bookEntity = this.getBaseMapper().selectById(bookId); BookEntity bookEntity = this.getBaseMapper().selectById(bookId);
@@ -539,13 +538,13 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
} }
} }
} }
throw new NullPointerException(); return true;
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
//事务回滚 //事务回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return false;
} }
return false;
} }
public String uploadFile(InputStream inputStream,String fileName) { public String uploadFile(InputStream inputStream,String fileName) {
String endpoint = ConstantPropertiesUtils.END_POIND; String endpoint = ConstantPropertiesUtils.END_POIND;