Commit abc65c6317db3d57c501615125b5a4e17b0448c9

Authored by 648540858
1 parent 08468edd

优化目录移除时默认目录的选择

src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
@@ -470,4 +470,6 @@ public interface IVideoManagerStorager { @@ -470,4 +470,6 @@ public interface IVideoManagerStorager {
470 void delCatalogByPlatformId(String serverGBId); 470 void delCatalogByPlatformId(String serverGBId);
471 471
472 void delRelationByPlatformId(String serverGBId); 472 void delRelationByPlatformId(String serverGBId);
  473 +
  474 + PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
473 } 475 }
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
@@ -41,4 +41,7 @@ public interface PlatformCatalogMapper { @@ -41,4 +41,7 @@ public interface PlatformCatalogMapper {
41 41
42 @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.platformId=#{platformId}") 42 @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.platformId=#{platformId}")
43 List<PlatformCatalog> selectByPlatForm(String platformId); 43 List<PlatformCatalog> selectByPlatForm(String platformId);
  44 +
  45 + @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = (SELECT pp.catalogId from parent_platform pp WHERE pp.serverGBId=#{platformId})")
  46 + PlatformCatalog selectDefaultByPlatFormId(String platformId);
44 } 47 }
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -1058,4 +1058,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { @@ -1058,4 +1058,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
1058 platformGbStreamMapper.delByPlatformId(serverGBId); 1058 platformGbStreamMapper.delByPlatformId(serverGBId);
1059 platformChannelMapper.delByPlatformId(serverGBId); 1059 platformChannelMapper.delByPlatformId(serverGBId);
1060 } 1060 }
  1061 +
  1062 + @Override
  1063 + public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) {
  1064 + return catalogMapper.selectDefaultByPlatFormId(platformId);
  1065 + }
1061 } 1066 }
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
@@ -465,25 +465,30 @@ public class PlatformController { @@ -465,25 +465,30 @@ public class PlatformController {
465 }) 465 })
466 @DeleteMapping("/catalog/del") 466 @DeleteMapping("/catalog/del")
467 @ResponseBody 467 @ResponseBody
468 - public ResponseEntity<WVPResult<List<PlatformCatalog>>> delCatalog(String id){ 468 + public ResponseEntity<WVPResult<String>> delCatalog(String id, String platformId){
469 469
470 if (logger.isDebugEnabled()) { 470 if (logger.isDebugEnabled()) {
471 logger.debug("删除目录,{}", id); 471 logger.debug("删除目录,{}", id);
472 } 472 }
473 - // 如果删除的是默认目录则根目录设置为默认目录  
474 - PlatformCatalog catalog = storager.getCatalog(id);  
475 - if (catalog != null) {  
476 - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(catalog.getPlatformId());  
477 - if (parentPlatform != null) {  
478 - if (id.equals(parentPlatform.getCatalogId())) {  
479 - storager.setDefaultCatalog(parentPlatform.getServerGBId(), parentPlatform.getServerGBId());  
480 - }  
481 - } 473 + WVPResult<String> result = new WVPResult<>();
  474 +
  475 + if (StringUtils.isEmpty(id) || StringUtils.isEmpty(platformId)) {
  476 + result.setCode(-1);
  477 + result.setMsg("param error");
  478 + return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
482 } 479 }
  480 + result.setCode(0);
483 481
484 int delResult = storager.delCatalog(id); 482 int delResult = storager.delCatalog(id);
485 - WVPResult<List<PlatformCatalog>> result = new WVPResult<>();  
486 - result.setCode(0); 483 + // 如果删除的是默认目录则根目录设置为默认目录
  484 + PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId);
  485 +
  486 + // 默认节点被移除
  487 + if (parentPlatform == null) {
  488 + storager.setDefaultCatalog(platformId, platformId);
  489 + result.setData(platformId);
  490 + }
  491 +
487 492
488 if (delResult > 0) { 493 if (delResult > 0) {
489 result.setMsg("success"); 494 result.setMsg("success");
web_src/src/components/dialog/chooseChannelForCatalog.vue
@@ -132,6 +132,7 @@ export default { @@ -132,6 +132,7 @@ export default {
132 url:`/api/platform/catalog/del`, 132 url:`/api/platform/catalog/del`,
133 params: { 133 params: {
134 id: id, 134 id: id,
  135 + platformId: this.platformId,
135 } 136 }
136 }) 137 })
137 .then((res) => { 138 .then((res) => {
@@ -139,8 +140,8 @@ export default { @@ -139,8 +140,8 @@ export default {
139 console.log("移除成功") 140 console.log("移除成功")
140 node.parent.loaded = false 141 node.parent.loaded = false
141 node.parent.expand(); 142 node.parent.expand();
142 - if(this.defaultCatalogId === id) {  
143 - this.defaultCatalogId = this.platformId; 143 + if (res.data.data) {
  144 + this.defaultCatalogId = res.data.data;
144 } 145 }
145 } 146 }
146 }) 147 })