Commit 70be3b70b4c672022c68040ef22d42a969d1a0bf
1 parent
c37aa623
1、修改WorkServiceImpl,部分方法添加事务标注
Showing
1 changed file
with
3 additions
and
0 deletions
src/main/java/com/bsth/luban_springboot2/service/impl/WorkServiceImpl.java
| ... | ... | @@ -39,6 +39,7 @@ public class WorkServiceImpl implements WorkService { |
| 39 | 39 | private WorkRepo workRepo; |
| 40 | 40 | |
| 41 | 41 | @Override |
| 42 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 42 | 43 | public Long countWork(WorkDto workDto) { |
| 43 | 44 | Work work = WorkDto.toWork(new Work(), workDto, false); |
| 44 | 45 | Example<Work> example = Example.of(work); |
| ... | ... | @@ -46,6 +47,7 @@ public class WorkServiceImpl implements WorkService { |
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | @Override |
| 50 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 49 | 51 | public List<WorkDto> listWorks(WorkDto workDto, Pageable pageable) { |
| 50 | 52 | Work work = WorkDto.toWork(new Work(), workDto, false); |
| 51 | 53 | Example<Work> example = Example.of(work); |
| ... | ... | @@ -83,6 +85,7 @@ public class WorkServiceImpl implements WorkService { |
| 83 | 85 | } |
| 84 | 86 | |
| 85 | 87 | @Override |
| 88 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 86 | 89 | public WorkDto findWorkById(Long id) { |
| 87 | 90 | Optional<Work> optionalWork = this.workRepo.findById(id); |
| 88 | 91 | Work work = optionalWork.isPresent() ? optionalWork.get() : null; | ... | ... |