优化目录移除时默认目录的选择
This commit is contained in:
parent
16c7f007c6
commit
e57dc37e50
@ -470,4 +470,6 @@ public interface IVideoManagerStorager {
|
|||||||
void delCatalogByPlatformId(String serverGBId);
|
void delCatalogByPlatformId(String serverGBId);
|
||||||
|
|
||||||
void delRelationByPlatformId(String serverGBId);
|
void delRelationByPlatformId(String serverGBId);
|
||||||
|
|
||||||
|
PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
|
||||||
}
|
}
|
||||||
|
@ -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}")
|
@Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.platformId=#{platformId}")
|
||||||
List<PlatformCatalog> selectByPlatForm(String platformId);
|
List<PlatformCatalog> 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);
|
||||||
}
|
}
|
||||||
|
@ -1058,4 +1058,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
|||||||
platformGbStreamMapper.delByPlatformId(serverGBId);
|
platformGbStreamMapper.delByPlatformId(serverGBId);
|
||||||
platformChannelMapper.delByPlatformId(serverGBId);
|
platformChannelMapper.delByPlatformId(serverGBId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) {
|
||||||
|
return catalogMapper.selectDefaultByPlatFormId(platformId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,25 +465,30 @@ public class PlatformController {
|
|||||||
})
|
})
|
||||||
@DeleteMapping("/catalog/del")
|
@DeleteMapping("/catalog/del")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<WVPResult<List<PlatformCatalog>>> delCatalog(String id){
|
public ResponseEntity<WVPResult<String>> delCatalog(String id, String platformId){
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("删除目录,{}", id);
|
logger.debug("删除目录,{}", id);
|
||||||
}
|
}
|
||||||
// 如果删除的是默认目录则根目录设置为默认目录
|
WVPResult<String> result = new WVPResult<>();
|
||||||
PlatformCatalog catalog = storager.getCatalog(id);
|
|
||||||
if (catalog != null) {
|
if (StringUtils.isEmpty(id) || StringUtils.isEmpty(platformId)) {
|
||||||
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(catalog.getPlatformId());
|
result.setCode(-1);
|
||||||
if (parentPlatform != null) {
|
result.setMsg("param error");
|
||||||
if (id.equals(parentPlatform.getCatalogId())) {
|
return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
|
||||||
storager.setDefaultCatalog(parentPlatform.getServerGBId(), parentPlatform.getServerGBId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
result.setCode(0);
|
||||||
|
|
||||||
int delResult = storager.delCatalog(id);
|
int delResult = storager.delCatalog(id);
|
||||||
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
|
// 如果删除的是默认目录则根目录设置为默认目录
|
||||||
result.setCode(0);
|
PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId);
|
||||||
|
|
||||||
|
// 默认节点被移除
|
||||||
|
if (parentPlatform == null) {
|
||||||
|
storager.setDefaultCatalog(platformId, platformId);
|
||||||
|
result.setData(platformId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (delResult > 0) {
|
if (delResult > 0) {
|
||||||
result.setMsg("success");
|
result.setMsg("success");
|
||||||
|
@ -132,6 +132,7 @@ export default {
|
|||||||
url:`/api/platform/catalog/del`,
|
url:`/api/platform/catalog/del`,
|
||||||
params: {
|
params: {
|
||||||
id: id,
|
id: id,
|
||||||
|
platformId: this.platformId,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -139,8 +140,8 @@ export default {
|
|||||||
console.log("移除成功")
|
console.log("移除成功")
|
||||||
node.parent.loaded = false
|
node.parent.loaded = false
|
||||||
node.parent.expand();
|
node.parent.expand();
|
||||||
if(this.defaultCatalogId === id) {
|
if (res.data.data) {
|
||||||
this.defaultCatalogId = this.platformId;
|
this.defaultCatalogId = res.data.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user