|
@@ -26,6 +26,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -116,10 +117,17 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
|
|
|
throw new BizException("专辑分类名称已存在");
|
|
|
}
|
|
|
|
|
|
+ // 校验子分类值是否存在重复
|
|
|
+ List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
|
|
|
+ Set<String> names = values.stream().map(TenantAlbumCategoryDetail::getValue).collect(Collectors.toSet());
|
|
|
+ if (names.size() != values.size()) {
|
|
|
+ ETenantAlbumCategoryType categoryType = tenantAlbumCategory.getCategoryType();
|
|
|
+ throw new BizException(ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型不能有重复" : "级别不能有重复");
|
|
|
+ }
|
|
|
+
|
|
|
TenantAlbumCategory albumCategory = JSON.parseObject(tenantAlbumCategory.jsonString(),
|
|
|
TenantAlbumCategory.class);
|
|
|
this.save(albumCategory);
|
|
|
- List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
|
|
|
if (!values.isEmpty()) {
|
|
|
values.forEach(next -> next.setTenantAlbumCategoryId(albumCategory.getId()));
|
|
|
tenantAlbumCategoryDetailService.saveBatch(values);
|
|
@@ -147,12 +155,20 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
|
|
|
throw new BizException("专辑分类名称已存在");
|
|
|
}
|
|
|
|
|
|
+ // 校验子分类值是否存在重复
|
|
|
+ List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
|
|
|
+ Set<String> names = values.stream().map(TenantAlbumCategoryDetail::getValue).collect(Collectors.toSet());
|
|
|
+ if (names.size() != values.size()) {
|
|
|
+ TenantAlbumCategory albumCategory = this.getById(tenantAlbumCategory.getId());
|
|
|
+ ETenantAlbumCategoryType categoryType = albumCategory.getCategoryType();
|
|
|
+ throw new BizException(ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型不能有重复" : "级别不能有重复");
|
|
|
+ }
|
|
|
+
|
|
|
// 校验是否存在引用删除
|
|
|
List<TenantAlbumCategoryDetail> detailList = tenantAlbumCategoryDetailService.lambdaQuery()
|
|
|
.eq(TenantAlbumCategoryDetail::getTenantAlbumCategoryId, tenantAlbumCategory.getId())
|
|
|
.list();
|
|
|
|
|
|
- List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
|
|
|
List<Long> newUpdateIds = values.stream().map(TenantAlbumCategoryDetail::getId).filter(Objects::nonNull)
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
@@ -226,7 +242,8 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
|
|
|
Integer useCount = tenantAlbumMusicMapper.selectCount(queryWrapper);
|
|
|
// 删除的ID被应用的数量大于0
|
|
|
if (useCount > 0) {
|
|
|
- throw new BizException("专辑分类存在" + (ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型" : "级别") + "引用");
|
|
|
+ throw new BizException("专辑分类存在" + (ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型" :
|
|
|
+ "级别") + "引用");
|
|
|
}
|
|
|
}
|
|
|
}
|