修改事务
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<BookDao, BookEntity> implements
|
||||
@Override
|
||||
public boolean getWordSection(Integer bookId) {
|
||||
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);
|
||||
@@ -535,8 +539,11 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new NullPointerException();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();;
|
||||
e.printStackTrace();
|
||||
//事务回滚
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class BookChapterEntity implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableLogic
|
||||
// @TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
|
||||
@@ -11,7 +11,7 @@ connection-timeout: 6000000ms
|
||||
spring:
|
||||
# 环境 dev/dev1|test|prod
|
||||
profiles:
|
||||
active: dev
|
||||
active: dev1
|
||||
# jackson时间格式化
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
|
||||
Reference in New Issue
Block a user