This commit is contained in:
@@ -68,16 +68,9 @@ public class ProductServiceImpl implements ProductService {
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* 检查是否有商品使用该分类,存在则不允许删除
|
||||
*/
|
||||
@Override
|
||||
public void deleteCategory(String id) {
|
||||
// 检查是否有商品使用该分类
|
||||
Long count = productMapper.selectCount(new LambdaQueryWrapper<Product>()
|
||||
.eq(Product::getCategoryId, id));
|
||||
if (count > 0) {
|
||||
throw new RuntimeException("该分类下有商品,无法删除");
|
||||
}
|
||||
categoryMapper.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user