From ed588f5797153b7d1023c8bbeaf9aa8cc5e07a64 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Fri, 25 Oct 2024 17:29:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91matype=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bonus/sgzb/base/controller/MaTypeController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java index 66fa3c0..d583f6e 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java @@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_NUM; import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE; @@ -270,7 +272,11 @@ public class MaTypeController extends BaseController { public AjaxResult edit(@RequestBody MaType maType) { Long parentId = maType.getParentId(); List subMas = maTypeMapper.getListByParentId(parentId, null); - boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName())); + List filteredItems = subMas.stream().collect(Collectors.toList()); + if (Objects.nonNull(maType.getTypeId())) { + filteredItems = subMas.stream().filter(item -> !maType.getTypeId().equals(item.getTypeId())).collect(Collectors.toList()); + } + boolean containsSameBrother = filteredItems.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName())); if (containsSameBrother) { return AjaxResult.error("修改失败,同级存在相同名称"); }