修改事务

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")
@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();
if (bookService.getWordSection(id)){
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
bookEntity.setChapterStatus("2");
bookService.updateById(bookEntity);
return R.ok();
}else {
return R.error();
}
}

View File

@@ -457,7 +457,6 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
try{
bookChapterService.remove(new LambdaQueryWrapper<BookChapterEntity>().eq(BookChapterEntity::getBookId,bookId));
bookChapterContentService.remove(new LambdaQueryWrapper<BookChapterContentEntity>().eq(BookChapterContentEntity::getBookId,bookId));
int topText = 22;
int secText = 16;
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) {
e.printStackTrace();
//事务回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return false;
}
return false;
}
public String uploadFile(InputStream inputStream,String fileName) {
String endpoint = ConstantPropertiesUtils.END_POIND;