From 57a5c5a0f13c42a5323580ed5739f4b12ee960f8 Mon Sep 17 00:00:00 2001 From: Chopper Date: Wed, 22 Sep 2021 11:19:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=BB=91=E5=AE=9A=E5=93=81?= =?UTF-8?q?=E7=89=8C=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/serviceimpl/BrandServiceImpl.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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);