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); + }); + } }); }