diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java index e4bda3f0..038fe2b8 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java @@ -470,4 +470,6 @@ public interface IVideoManagerStorager { void delCatalogByPlatformId(String serverGBId); void delRelationByPlatformId(String serverGBId); + + PlatformCatalog queryDefaultCatalogInPlatform(String platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java index 59ecdbcb..95015bda 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java @@ -41,4 +41,7 @@ public interface PlatformCatalogMapper { @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.platformId=#{platformId}") List selectByPlatForm(String platformId); + + @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = (SELECT pp.catalogId from parent_platform pp WHERE pp.serverGBId=#{platformId})") + PlatformCatalog selectDefaultByPlatFormId(String platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java index 98f3594e..816a749d 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java @@ -1058,4 +1058,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { platformGbStreamMapper.delByPlatformId(serverGBId); platformChannelMapper.delByPlatformId(serverGBId); } + + @Override + public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) { + return catalogMapper.selectDefaultByPlatFormId(platformId); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index 1111ff7d..532d928d 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -465,25 +465,30 @@ public class PlatformController { }) @DeleteMapping("/catalog/del") @ResponseBody - public ResponseEntity>> delCatalog(String id){ + public ResponseEntity> delCatalog(String id, String platformId){ if (logger.isDebugEnabled()) { logger.debug("删除目录,{}", id); } - // 如果删除的是默认目录则根目录设置为默认目录 - PlatformCatalog catalog = storager.getCatalog(id); - if (catalog != null) { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(catalog.getPlatformId()); - if (parentPlatform != null) { - if (id.equals(parentPlatform.getCatalogId())) { - storager.setDefaultCatalog(parentPlatform.getServerGBId(), parentPlatform.getServerGBId()); - } - } + WVPResult result = new WVPResult<>(); + + if (StringUtils.isEmpty(id) || StringUtils.isEmpty(platformId)) { + result.setCode(-1); + result.setMsg("param error"); + return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST); } + result.setCode(0); int delResult = storager.delCatalog(id); - WVPResult> result = new WVPResult<>(); - result.setCode(0); + // 如果删除的是默认目录则根目录设置为默认目录 + PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId); + + // 默认节点被移除 + if (parentPlatform == null) { + storager.setDefaultCatalog(platformId, platformId); + result.setData(platformId); + } + if (delResult > 0) { result.setMsg("success"); diff --git a/web_src/src/components/dialog/chooseChannelForCatalog.vue b/web_src/src/components/dialog/chooseChannelForCatalog.vue index 5133caa5..2d87bdd5 100644 --- a/web_src/src/components/dialog/chooseChannelForCatalog.vue +++ b/web_src/src/components/dialog/chooseChannelForCatalog.vue @@ -132,6 +132,7 @@ export default { url:`/api/platform/catalog/del`, params: { id: id, + platformId: this.platformId, } }) .then((res) => { @@ -139,8 +140,8 @@ export default { console.log("移除成功") node.parent.loaded = false node.parent.expand(); - if(this.defaultCatalogId === id) { - this.defaultCatalogId = this.platformId; + if (res.data.data) { + this.defaultCatalogId = res.data.data; } } })