Browse Source

添加媒体服务器节点管理ui-移除接口

pull/174/head
648540858 3 years ago
parent
commit
d6544c0c71
  1. 5
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
  2. 2
      src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
  3. 8
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
  4. 23
      src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
  5. 22
      web_src/src/components/MediaServerManger.vue
  6. 14
      web_src/src/components/service/MediaServer.js

5
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java

@ -81,6 +81,7 @@ public class ZLMRunner implements CommandLineRunner {
if (startGetMedia == null) startGetMedia = new HashMap<>();
startGetMedia.put(mediaServerItem.getId(), true);
new Thread(() -> {
ZLMServerConfig zlmServerConfig = getMediaServerConfig(mediaServerItem);
if (zlmServerConfig != null) {
zlmServerConfig.setIp(mediaServerItem.getIp());
@ -88,6 +89,7 @@ public class ZLMRunner implements CommandLineRunner {
startGetMedia.remove(mediaServerItem.getId());
mediaServerService.handLeZLMServerConfig(zlmServerConfig);
}
}).start();
}
Timer timer = new Timer();
@ -109,6 +111,9 @@ public class ZLMRunner implements CommandLineRunner {
public ZLMServerConfig getMediaServerConfig(MediaServerItem mediaServerItem) {
if (startGetMedia == null) { return null;}
if (mediaServerService.getOne(mediaServerItem.getId()) == null) {
return null;
}
if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) {
return null;
}

2
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java

@ -57,4 +57,6 @@ public interface IMediaServerService {
WVPResult<MediaServerItem> checkMediaServer(String ip, int port, String secret);
boolean checkMediaRecordServer(String ip, int port);
void delete(String id);
}

8
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

@ -519,4 +519,12 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR
return result;
}
@Override
public void delete(String id) {
redisUtil.zRemove(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX, id);
String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + id;
redisUtil.del(key);
mediaServerMapper.delOne(id);
}
}

23
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java

@ -129,7 +129,7 @@ public class ServerController {
})
@PostMapping(value = "/media_server/save")
@ResponseBody
public WVPResult<String> checkMediaServer(@RequestBody MediaServerItem mediaServerItem){
public WVPResult<String> saveMediaServer(@RequestBody MediaServerItem mediaServerItem){
if (mediaServerService.getOne(mediaServerItem.getId()) != null) {
mediaServerService.update(mediaServerItem);
}else {
@ -141,6 +141,27 @@ public class ServerController {
return result;
}
@ApiOperation("移除流媒体服务")
@ApiImplicitParams({
@ApiImplicitParam(name="id", value = "流媒体ID", dataTypeClass = String.class)
})
@DeleteMapping(value = "/media_server/delete")
@ResponseBody
public WVPResult<String> deleteMediaServer(@RequestParam String id){
if (mediaServerService.getOne(id) != null) {
mediaServerService.delete(id);
}else {
WVPResult<String> result = new WVPResult<>();
result.setCode(-1);
result.setMsg("未找到此节点");
return result;
}
WVPResult<String> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
return result;
}
@ApiOperation("重启服务")

22
web_src/src/components/MediaServerManger.vue

@ -18,9 +18,10 @@
<div class="card-img-zlm"></div>
<div style="padding: 14px;text-align: left">
<span style="font-size: 16px">{{item.id}}</span>
<el-button icon="el-icon-edit" style="padding: 0;float: right;" type="text" @click="edit(item)">编辑</el-button>
<el-button icon="el-icon-delete" style="margin-right: 10px;padding: 0;float: right;" type="text" @click="del(item)">移除</el-button>
<div style="margin-top: 13px; line-height: 12px; ">
<span style="font-size: 14px; color: #999; margin-top: 5px">创建时间 {{item.createTime}}</span>
<el-button icon="el-icon-edit" style="padding: 0;float: right;" type="text" @click="edit(item)">编辑</el-button>
</div>
</div>
<i v-if="item.status" class="iconfont icon-online server-card-status-online" title="在线"></i>
@ -88,6 +89,25 @@
edit: function (row){
this.$refs.mediaServerEdit.openDialog(row, this.initData)
},
del: function (row){
this.$confirm('确认删除此节点?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.mediaServerObj.delete(row.id, (data)=>{
if (data.code === 0) {
this.$message({
type: 'success',
message: '删除成功!'
});
}
})
}).catch(() => {
});
},
getNumberByWidth(){
let candidateNums = [1, 2, 3, 4, 6, 8, 12, 24]
let clientWidth = window.innerWidth - 30;

14
web_src/src/components/service/MediaServer.js

@ -80,6 +80,20 @@ class MediaServer{
console.log(error);
});
}
delete(id, callback) {
this.$axios({
method: 'delete',
url:`/api/server/media_server/delete`,
params: {
id: id
}
}).then(function (res) {
if (typeof (callback) == "function") callback(res.data)
}).catch(function (error) {
console.log(error);
});
}
}
export default MediaServer;

Loading…
Cancel
Save