From a808157a622e6a2756a5a6973a0664176d6f8f64 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 15 Sep 2024 11:33:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=95=86=E5=9F=8E:=20=E6=A0=A1=E9=AA=8C=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=B1=82=E7=BA=A7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/service/category/ProductCategoryService.java | 1 + .../product/service/category/ProductCategoryServiceImpl.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java index 5cacccdb5..59495a11b 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java @@ -87,6 +87,7 @@ public interface ProductCategoryService { * 校验商品分类是否有效。如下情况,视为无效: * 1. 商品分类编号不存在 * 2. 商品分类被禁用 + * 3. 商品分类层级校验,必须使用第二级的商品分类及以下 * * @param ids 商品分类编号数组 */ diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java index 64b8a6127..288543b41 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; @@ -119,6 +120,10 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { if (!CommonStatusEnum.ENABLE.getStatus().equals(category.getStatus())) { throw exception(CATEGORY_DISABLED, category.getName()); } + // 校验层级 + if (getCategoryLevel(id) < CATEGORY_LEVEL) { + throw exception(SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR); + } }); }