From 4c86dee4b0478c2ff19e3d6014398594dbc47c00 Mon Sep 17 00:00:00 2001 From: mors <3067699729@qq.com> Date: Mon, 30 Jan 2023 19:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9E=E5=B8=A6=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/base/controller/ZyClothsTypeController.java | 9 +++++++++ .../modules/demo/base/mapper/ZyClothsTypeMapper.java | 3 +++ 2 files changed, 12 insertions(+) diff --git a/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/controller/ZyClothsTypeController.java b/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/controller/ZyClothsTypeController.java index 4c67e11e..b9c45c65 100644 --- a/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/controller/ZyClothsTypeController.java +++ b/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/controller/ZyClothsTypeController.java @@ -1,5 +1,6 @@ package org.jeecg.modules.demo.base.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -24,6 +25,7 @@ import javax.servlet.http.HttpServletResponse; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.stream.Collectors; /** * @Description: zy_cloths_type @@ -147,6 +149,13 @@ public class ZyClothsTypeController extends JeecgController delete(@RequestParam(name = "id", required = true) String id) { zyClothsTypeService.removeById(id); + //如果这是父级 连带子集一起删除 + String parentId = zyClothsTypeMapper.getParentId(id); + if (StringUtils.isEmpty(parentId)){ + List zyClothsTypeList = zyClothsTypeService.list(new LambdaQueryWrapper().eq(ZyClothsType::getTypeId,id)); + List collect = zyClothsTypeList.stream().map(ZyClothsType::getId).collect(Collectors.toList()); + zyClothsTypeService.removeByIds(collect); + } return Result.OK("删除成功!"); } diff --git a/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/mapper/ZyClothsTypeMapper.java b/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/mapper/ZyClothsTypeMapper.java index 41357cf9..a8f3f0bc 100644 --- a/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/mapper/ZyClothsTypeMapper.java +++ b/jeecg-boot/jeecg-boot-module-process/src/main/java/org/jeecg/modules/demo/base/mapper/ZyClothsTypeMapper.java @@ -43,4 +43,7 @@ public interface ZyClothsTypeMapper extends BaseMapper { /**根据type_id拿到类型名称*/ @Select("select type_name from zy_cloths_type where id = #{id} ") String getNameByTypeId(String id); + + @Select("select type_id from zy_cloths_type where id = #{id} ") + String getParentId(String id); }