Selaa lähdekoodia

1.专辑分类修改校验调整

yuanliang 1 vuosi sitten
vanhempi
commit
7e72df88a7

+ 11 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumCategoryServiceImpl.java

@@ -159,8 +159,18 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
         List<TenantAlbumCategoryDetail> removeDetailIdList =
                 detailList.stream().filter(next -> !newUpdateIds.contains(next.getId())).collect(Collectors.toList());
         if (!removeDetailIdList.isEmpty()) {
+            // 校验删除的分类值是否被使用,如果有使用,则提示
             TenantAlbumCategory albumCategory = this.getById(tenantAlbumCategory.getId());
-            checkTenantAlbumCategoryDetailUsed(albumCategory.getCategoryType(), removeDetailIdList);
+            QueryWrapper<TenantAlbum> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda()
+                    .eq(ETenantAlbumCategoryType.CATEGORY_TYPE.equals(albumCategory.getCategoryType()),
+                            TenantAlbum::getCategoryLevelId, tenantAlbumCategory.getId())
+                    .eq(ETenantAlbumCategoryType.CATEGORY_LEVEL.equals(albumCategory.getCategoryType()),
+                            TenantAlbum::getCategoryTypeId, tenantAlbumCategory.getId());
+            Integer useCount = tenantAlbumMapper.selectCount(queryWrapper);
+            if (useCount > 0) {
+                checkTenantAlbumCategoryDetailUsed(albumCategory.getCategoryType(), removeDetailIdList);
+            }
         }
 
         tenantAlbumCategoryDetailService.lambdaUpdate()