648540858 1 рік тому
батько
коміт
c96c29776d

+ 4 - 5
src/main/java/com/genersoft/iot/vmp/streamProxy/controller/StreamProxyController.java

@@ -192,10 +192,9 @@ public class StreamProxyController {
     @GetMapping(value = "/stop")
     @ResponseBody
     @Operation(summary = "停用代理", security = @SecurityRequirement(name = JwtUtils.HEADER))
-    @Parameter(name = "app", description = "应用名", required = true)
-    @Parameter(name = "stream", description = "流id", required = true)
-    public void stop(String app, String stream){
-        log.info("停用代理: " + app + "/" + stream);
-        streamProxyService.stopByAppAndStream(app, stream);
+    @Parameter(name = "id", description = "代理Id", required = true)
+    public void stop(int id){
+        log.info("停用代理: {}", id);
+        streamProxyService.stop(id);
     }
 }

+ 2 - 0
src/main/java/com/genersoft/iot/vmp/streamProxy/service/IStreamProxyService.java

@@ -94,4 +94,6 @@ public interface IStreamProxyService {
     void delete(int id);
 
     StreamInfo start(int id);
+
+    void stop(int id);
 }

+ 8 - 2
src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java

@@ -474,8 +474,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
         return streamProxyMapper.select(id);
     }
 
-
-
+    @Override
+    public void stop(int id) {
+        StreamProxy streamProxy = streamProxyMapper.select(id);
+        if (streamProxy == null) {
+            throw new ControllerException(ErrorCode.ERROR404.getCode(), "代理信息未找到");
+        }
+        stopProxy(streamProxy);
+    }
 
     //    @Scheduled(cron = "* 0/10 * * * ?")
 //    public void asyncCheckStreamProxyStatus() {

+ 23 - 1
web_src/src/components/StreamProxyList.vue

@@ -74,8 +74,10 @@
         <el-table-column prop="createTime" label="创建时间"  min-width="150" show-overflow-tooltip/>
         <el-table-column label="操作" width="360"  fixed="right">
           <template slot-scope="scope">
-            <el-button size="medium" icon="el-icon-video-play" type="text" v-if="scope.row.enable" @click="play(scope.row)">播放</el-button>
+            <el-button size="medium" icon="el-icon-video-play" type="text" @click="play(scope.row)">播放</el-button>
             <el-divider direction="vertical"></el-divider>
+            <el-button size="medium" icon="el-icon-switch-button" style="color: #f56c6c"  type="text" v-if="scope.row.pulling" @click="stopPlay(scope.row)">停止</el-button>
+            <el-divider direction="vertical" v-if="scope.row.pulling" ></el-divider>
             <el-button size="medium" icon="el-icon-edit" type="text" @click="edit(scope.row)">
               编辑
             </el-button>
@@ -274,6 +276,26 @@
 					console.log(error);
 				});
 
+			},
+      stopPlay: function(row){
+				let that = this;
+				this.$axios({
+					method: 'get',
+					url:`/api/proxy/stop`,
+					params: {
+						id: row.id,
+					}
+				}).then(function (res) {
+					if (res.data.code === 0) {
+
+          }else {
+            that.$message.error(res.data.msg);
+          }
+
+				}).catch(function (error) {
+					console.log(error);
+				});
+
 			},
       queryCloudRecords: function (row) {