Browse Source

1.专辑分类删除添加校验

yuanliang 1 year ago
parent
commit
63d5a7b5ef

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

@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yonge.cooleshow.biz.dal.entity.TenantAlbum;
 import com.yonge.cooleshow.biz.dal.entity.TenantAlbumCategory;
 import com.yonge.cooleshow.biz.dal.entity.TenantAlbumCategoryDetail;
 import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
 import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumCategoryMapper;
+import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper;
 import com.yonge.cooleshow.biz.dal.service.TenantAlbumCategoryDetailService;
 import com.yonge.cooleshow.biz.dal.service.TenantAlbumCategoryService;
@@ -35,6 +37,8 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
     private TenantAlbumCategoryDetailService tenantAlbumCategoryDetailService;
     @Autowired
     private TenantAlbumMusicMapper tenantAlbumMusicMapper;
+    @Autowired
+    private TenantAlbumMapper tenantAlbumMapper;
 
     /**
      * 查询详情
@@ -155,10 +159,20 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
         if (albumCategory == null) {
             throw new BizException("删除的数据不存在");
         }
-        List<TenantAlbumCategoryDetail> list = tenantAlbumCategoryDetailService.lambdaQuery()
-                .eq(TenantAlbumCategoryDetail::getTenantAlbumCategoryId, albumCategory.getId())
-                .list();
-        checkTenantAlbumCategoryDetailUsed(albumCategory.getCategoryType(), list);
+        QueryWrapper<TenantAlbum> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda()
+                .eq(TenantAlbum::getCategoryLevelId, id)
+                .or()
+                .eq(TenantAlbum::getCategoryTypeId, id);
+        Integer count = tenantAlbumMapper.selectCount(queryWrapper);
+        if (count > 0) {
+            throw new BizException("专辑分类被使用");
+        }
+
+//        List<TenantAlbumCategoryDetail> list = tenantAlbumCategoryDetailService.lambdaQuery()
+//                .eq(TenantAlbumCategoryDetail::getTenantAlbumCategoryId, albumCategory.getId())
+//                .list();
+//        checkTenantAlbumCategoryDetailUsed(albumCategory.getCategoryType(), list);
         albumCategory.setDelFlag(true);
         this.updateById(albumCategory);
         return true;