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,6 +39,7 @@ public class WorkServiceImpl implements WorkService { | ||
| 39 | private WorkRepo workRepo; | 39 | private WorkRepo workRepo; |
| 40 | 40 | ||
| 41 | @Override | 41 | @Override |
| 42 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 42 | public Long countWork(WorkDto workDto) { | 43 | public Long countWork(WorkDto workDto) { |
| 43 | Work work = WorkDto.toWork(new Work(), workDto, false); | 44 | Work work = WorkDto.toWork(new Work(), workDto, false); |
| 44 | Example<Work> example = Example.of(work); | 45 | Example<Work> example = Example.of(work); |
| @@ -46,6 +47,7 @@ public class WorkServiceImpl implements WorkService { | @@ -46,6 +47,7 @@ public class WorkServiceImpl implements WorkService { | ||
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | @Override | 49 | @Override |
| 50 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 49 | public List<WorkDto> listWorks(WorkDto workDto, Pageable pageable) { | 51 | public List<WorkDto> listWorks(WorkDto workDto, Pageable pageable) { |
| 50 | Work work = WorkDto.toWork(new Work(), workDto, false); | 52 | Work work = WorkDto.toWork(new Work(), workDto, false); |
| 51 | Example<Work> example = Example.of(work); | 53 | Example<Work> example = Example.of(work); |
| @@ -83,6 +85,7 @@ public class WorkServiceImpl implements WorkService { | @@ -83,6 +85,7 @@ public class WorkServiceImpl implements WorkService { | ||
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | @Override | 87 | @Override |
| 88 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 86 | public WorkDto findWorkById(Long id) { | 89 | public WorkDto findWorkById(Long id) { |
| 87 | Optional<Work> optionalWork = this.workRepo.findById(id); | 90 | Optional<Work> optionalWork = this.workRepo.findById(id); |
| 88 | Work work = optionalWork.isPresent() ? optionalWork.get() : null; | 91 | Work work = optionalWork.isPresent() ? optionalWork.get() : null; |