|
@@ -3,6 +3,7 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -199,8 +200,20 @@ public class SysMusicScoreCategoriesServiceImpl extends BaseServiceImpl<Integer,
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void del(Integer id) {
|
|
|
- String byCategoriesIds = sysMusicScoreCategoriesDao.findByCategoriesIds(id.toString());
|
|
|
- byCategoriesIds = sysMusicScoreCategoriesDao.findByCategoriesIds(byCategoriesIds);
|
|
|
+
|
|
|
+ List<Integer> categoriesIdList = new ArrayList<>();
|
|
|
+ Integer categoriesId = id;
|
|
|
+
|
|
|
+ SysMusicScoreCategories sysMusicScoreCategories = get(categoriesId);
|
|
|
+
|
|
|
+ if(sysMusicScoreCategories == null){
|
|
|
+ throw new BizException("分类找不到");
|
|
|
+ }
|
|
|
+ categoriesIdList.add(categoriesId);
|
|
|
+ sysMusicScoreCategories = getChildTree(sysMusicScoreCategories);
|
|
|
+ getAllCategoryIdList(categoriesIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());
|
|
|
+
|
|
|
+ String byCategoriesIds = categoriesIdList.stream().map(Objects :: toString).collect(Collectors.joining(","));
|
|
|
//是否有在使用的分类
|
|
|
int count = sysMusicScoreDao.countBuyCategoriesIds(byCategoriesIds);
|
|
|
if(count > 0){
|
|
@@ -286,4 +299,15 @@ public class SysMusicScoreCategoriesServiceImpl extends BaseServiceImpl<Integer,
|
|
|
}
|
|
|
parentTree.add(targetCategory);
|
|
|
}
|
|
|
+
|
|
|
+ private void getAllCategoryIdList(List<Integer> categoryIdList, List<SysMusicScoreCategories> sysMusicScoreCategoriesList){
|
|
|
+
|
|
|
+ if(sysMusicScoreCategoriesList != null && sysMusicScoreCategoriesList.size() > 0){
|
|
|
+ for(SysMusicScoreCategories sysMusicScoreCategories : sysMusicScoreCategoriesList){
|
|
|
+ categoryIdList.add(sysMusicScoreCategories.getId());
|
|
|
+ getAllCategoryIdList(categoryIdList, sysMusicScoreCategories.getSysMusicScoreCategoriesList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|