Commit 6b2f2e922c4f3ff3393fd054fc65a71b25f44c03
1 parent
3a6150f5
fix(promotion):删除 DIY 模板级联删除其自动生成的默认页面——deleteDiyTemplate 补删 getDiyPageByTemplat…
…eId 的「首页/我的」页并加事务,消除页面列表孤儿页(A69)
Showing
1 changed file
with
4 additions
and
0 deletions
yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java
| ... | ... | @@ -91,6 +91,7 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | + @Transactional(rollbackFor = Exception.class) | |
| 94 | 95 | @Override |
| 95 | 96 | public void deleteDiyTemplate(Long id) { |
| 96 | 97 | // 校验存在 |
| ... | ... | @@ -101,6 +102,9 @@ public class DiyTemplateServiceImpl implements DiyTemplateService { |
| 101 | 102 | } |
| 102 | 103 | // 删除 |
| 103 | 104 | diyTemplateMapper.deleteById(id); |
| 105 | + // 级联删除模板下自动生成的默认页面(createDiyTemplate 的「首页/我的」),避免页面列表残留孤儿页 | |
| 106 | + diyPageService.getDiyPageByTemplateId(id) | |
| 107 | + .forEach(page -> diyPageService.deleteDiyPage(page.getId())); | |
| 104 | 108 | } |
| 105 | 109 | |
| 106 | 110 | private DiyTemplateDO validateDiyTemplateExists(Long id) { | ... | ... |