From e25d99b887a19fe703f1819b79a869e2c3d9580b Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Fri, 31 May 2024 16:44:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=B8=AE=E5=8A=A9=E4=B8=AD?= =?UTF-8?q?=E5=BF=83bug=201=E3=80=81=E5=88=A0=E9=99=A4=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E4=B8=8D=E6=8F=90=E9=86=92=E9=97=AE=E9=A2=98=202=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=B1=BB=E5=9E=8B=E6=B2=A1=E6=9C=89=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8E=89=E5=AD=90=E7=B1=BB=E5=9E=8B=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=AF=B4=E6=98=8E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operator/dao/helptype/IHelpTypeDao.java | 1 + .../helptype/impl/HelpTypeServiceImpl.java | 30 +++++++++++++++---- .../mapper/helptype/help-type-mapper.xml | 14 +++++++++ .../resources/templates/helptype/list.html | 29 +++++++++++------- 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/main/java/cn/com/tenlion/operator/dao/helptype/IHelpTypeDao.java b/src/main/java/cn/com/tenlion/operator/dao/helptype/IHelpTypeDao.java index c403e0a..db180a5 100644 --- a/src/main/java/cn/com/tenlion/operator/dao/helptype/IHelpTypeDao.java +++ b/src/main/java/cn/com/tenlion/operator/dao/helptype/IHelpTypeDao.java @@ -134,4 +134,5 @@ public interface IHelpTypeDao { */ Integer countByParentId(String parentId) throws SearchException; + List findChildrenByParentIds(Map params); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/service/helptype/impl/HelpTypeServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/helptype/impl/HelpTypeServiceImpl.java index d05b7be..dbfde8f 100644 --- a/src/main/java/cn/com/tenlion/operator/service/helptype/impl/HelpTypeServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/helptype/impl/HelpTypeServiceImpl.java @@ -22,10 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @ClassName: HelpTypeServiceImpl @@ -79,13 +76,36 @@ public class HelpTypeServiceImpl extends DefaultBaseService implements IHelpType @Override public void remove(String token, List ids) { Map params = getHashMap(2); - params.put("helpTypeIds", ids); if (StringUtils.isBlank(token)) { setUpdateInfo(params); } else { setAppUpdateInfo(token, params); } + // helpTypeDao.remove(params); + + List idList = new ArrayList<>(ids); + + List subIdList = findAllTypeData(ids, params); + while(!CollectionUtils.isEmpty(subIdList)) { + idList.addAll(subIdList); + subIdList = findAllTypeData(subIdList, params); + } + + // 删除数据 + params.put("helpTypeIds", idList); helpTypeDao.remove(params); + + // 删除说明数据 + helpDetailService.removeDetailByTypeId(idList, token); + } + + private List findAllTypeData(List ids, Map params) { + params.put("ids", ids); + List children = helpTypeDao.findChildrenByParentIds(params); + if(!CollectionUtils.isEmpty(children)) { + return children; + } + return new ArrayList<>(); } @Override diff --git a/src/main/resources/mybatis/mapper/helptype/help-type-mapper.xml b/src/main/resources/mybatis/mapper/helptype/help-type-mapper.xml index 8e35ed0..9239d80 100644 --- a/src/main/resources/mybatis/mapper/helptype/help-type-mapper.xml +++ b/src/main/resources/mybatis/mapper/helptype/help-type-mapper.xml @@ -346,4 +346,18 @@ parent_id = #{_parameter} + + \ No newline at end of file diff --git a/src/main/resources/templates/helptype/list.html b/src/main/resources/templates/helptype/list.html index 7d9198c..3fbbd4d 100644 --- a/src/main/resources/templates/helptype/list.html +++ b/src/main/resources/templates/helptype/list.html @@ -185,16 +185,25 @@ } function removeDetail(insertData) { - console.log(insertData) - var loadLayerIndex; - var obj = {}; - top.restAjax.delete(top.restAjax.path('api/help-detail/removeDetailByTypeId/{helpTypeIds}', [insertData.helpTypeId]), obj, null, function(code, data) { - }, function(code, data) { - top.dialog.msg(data.msg); - }, function() { - loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3}); - }, function() { - top.dialog.close(loadLayerIndex); + top.dialog.msg(top.dataMessage.delete, { + time: 0, + btn: [top.dataMessage.button.yes, top.dataMessage.button.no], + shade: 0.3, + yes: function (index) { + var loadLayerIndex; + var obj = {}; + top.restAjax.delete(top.restAjax.path('api/help-detail/removeDetailByTypeId/{helpTypeIds}', [insertData.helpTypeId]), obj, null, function(code, data) { + if(200 === code) { + top.dialog.msg('清除成功'); + } + }, function(code, data) { + + }, function() { + loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3}); + }, function() { + top.dialog.close(loadLayerIndex); + }); + } }); }