修改事务
This commit is contained in:
@@ -348,10 +348,12 @@ public class BookController {
|
|||||||
@RequestMapping("/getChapter")
|
@RequestMapping("/getChapter")
|
||||||
@Transactional
|
@Transactional
|
||||||
public R getChapter(@RequestParam("id") Integer id) {
|
public R getChapter(@RequestParam("id") Integer id) {
|
||||||
|
|
||||||
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();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.joda.time.DateTime;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -454,6 +455,9 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
|||||||
@Override
|
@Override
|
||||||
public boolean getWordSection(Integer bookId) {
|
public boolean getWordSection(Integer bookId) {
|
||||||
try{
|
try{
|
||||||
|
bookChapterService.remove(new LambdaQueryWrapper<BookChapterEntity>().eq(BookChapterEntity::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);
|
||||||
@@ -535,8 +539,11 @@ public class BookServiceImpl extends ServiceImpl<BookDao, BookEntity> implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new NullPointerException();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();;
|
e.printStackTrace();
|
||||||
|
//事务回滚
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class BookChapterEntity implements Serializable {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@TableLogic
|
// @TableLogic
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ connection-timeout: 6000000ms
|
|||||||
spring:
|
spring:
|
||||||
# 环境 dev/dev1|test|prod
|
# 环境 dev/dev1|test|prod
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev1
|
||||||
# jackson时间格式化
|
# jackson时间格式化
|
||||||
jackson:
|
jackson:
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
|
|||||||
Reference in New Issue
Block a user