diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java index ca8c3b08..dd849c1e 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java @@ -86,14 +86,17 @@ public class BrandServiceImpl extends ServiceImpl implements @Override public boolean brandDisable(String brandId, boolean disable) { Brand brand = this.checkExist(brandId); + //如果是要禁用,则需要先判定绑定关系 if (Boolean.TRUE.equals(disable)) { + //分了绑定关系查询 List categoryBrands = categoryBrandService.getCategoryBrandListByBrandId(brandId); - List brandIds = categoryBrands.stream().map(categoryBrand -> { - return categoryBrand.getCategoryId(); - }).collect(Collectors.toList()); - - throw new ServiceException(ResultCode.BRAND_USE_DISABLE_ERROR, - JSONUtil.toJsonStr(categoryService.getCategoryNameByIds(brandIds))); + if (!categoryBrands.isEmpty()) { + List brandIds = categoryBrands.stream().map(categoryBrand -> { + return categoryBrand.getCategoryId(); + }).collect(Collectors.toList()); + throw new ServiceException(ResultCode.BRAND_USE_DISABLE_ERROR, + JSONUtil.toJsonStr(categoryService.getCategoryNameByIds(brandIds))); + } } brand.setDeleteFlag(disable); return updateById(brand);