From 849c4bddf61d2946b84775ce565b850e4b94ee3d Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 15 Oct 2024 17:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B=E5=8F=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=90=8C=E5=90=8D=E7=A7=B0bug?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bonus/sgzb/base/controller/MaTypeController.java | 6 ++++++ .../com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java | 2 +- 2 files 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 8febe50..66fa3c0 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 @@ -268,6 +268,12 @@ public class MaTypeController extends BaseController { @Log(title = "机具类型管理ma_type", businessType = BusinessType.UPDATE) @PutMapping 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())); + if (containsSameBrother) { + return AjaxResult.error("修改失败,同级存在相同名称"); + } return toAjax(iTypeService.updateMaType(maType)); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index d8ccb53..f68e393 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -53,7 +53,7 @@ public class MaTypeServiceImpl implements ITypeService { public int insertMaType(MaType maType) { Long parentId = maType.getParentId(); List subMas = maTypeMapper.getListByParentId(parentId, null); - boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().contains(maType.getTypeName())); + boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName())); if (containsSameBrother) { return 0; }