From 705f915efead25d61eda5b497ca7018646174e99 Mon Sep 17 00:00:00 2001 From: hhyykk Date: Mon, 15 Jul 2024 21:17:13 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=BD=92=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/infra/service/category/CategoryServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/category/CategoryServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/category/CategoryServiceImpl.java index 56a978556..42fb62a4d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/category/CategoryServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/category/CategoryServiceImpl.java @@ -11,8 +11,10 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; @@ -189,7 +191,9 @@ public class CategoryServiceImpl implements CategoryService { Long parentId = 0L; // 解析路径 - String[] categoryElements = path.split("/"); + List categoryElements = Arrays.stream(path.split("/")) + .filter(s -> !s.isEmpty()) + .toList(); // 根据路径创建文件夹,并返回最后一个文件夹的id for (String categoryElement : categoryElements) {