From 03d6ad289baddf8feed64ffca5f1b13828bea710 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 01 九月 2022 14:50:28 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0'

---
 src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java |   74 +++++++++++++-----------------------
 1 files changed, 27 insertions(+), 47 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
index d8a87d7..d0aff58 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
@@ -5,6 +5,7 @@
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.conf.security.SecurityUtils;
 import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
@@ -17,6 +18,7 @@
 import com.genersoft.iot.vmp.service.IStreamPushService;
 import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler;
 import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import com.github.pagehelper.PageInfo;
@@ -95,11 +97,9 @@
     @PostMapping(value = "/save_to_gb")
     @ResponseBody
     @Operation(summary = "灏嗘帹娴佹坊鍔犲埌鍥芥爣")
-    public Object saveToGB(@RequestBody GbStream stream){
-        if (streamPushService.saveToGB(stream)){
-            return "success";
-        }else {
-            return "fail";
+    public void saveToGB(@RequestBody GbStream stream){
+        if (!streamPushService.saveToGB(stream)){
+           throw new ControllerException(ErrorCode.ERROR100);
         }
     }
 
@@ -107,11 +107,9 @@
     @DeleteMapping(value = "/remove_form_gb")
     @ResponseBody
     @Operation(summary = "灏嗘帹娴佺Щ鍑哄埌鍥芥爣")
-    public Object removeFormGB(@RequestBody GbStream stream){
-        if (streamPushService.removeFromGB(stream)){
-            return "success";
-        }else {
-            return "fail";
+    public void removeFormGB(@RequestBody GbStream stream){
+        if (!streamPushService.removeFromGB(stream)){
+            throw new ControllerException(ErrorCode.ERROR100);
         }
     }
 
@@ -121,25 +119,21 @@
     @Operation(summary = "涓涓�涓帹娴�")
     @Parameter(name = "app", description = "搴旂敤鍚�", required = true)
     @Parameter(name = "stream", description = "娴乮d", required = true)
-    public Object stop(String app, String streamId){
-        if (streamPushService.stop(app, streamId)){
-            return "success";
-        }else {
-            return "fail";
+    public void stop(String app, String streamId){
+        if (!streamPushService.stop(app, streamId)){
+            throw new ControllerException(ErrorCode.ERROR100);
         }
     }
 
     @DeleteMapping(value = "/batchStop")
     @ResponseBody
     @Operation(summary = "涓澶氫釜鎺ㄦ祦")
-    public Object batchStop(@RequestBody BatchGBStreamParam batchGBStreamParam){
+    public void batchStop(@RequestBody BatchGBStreamParam batchGBStreamParam){
         if (batchGBStreamParam.getGbStreams().size() == 0) {
-            return "fail";
+            throw new ControllerException(ErrorCode.ERROR100);
         }
-        if (streamPushService.batchStop(batchGBStreamParam.getGbStreams())){
-            return "success";
-        }else {
-            return "fail";
+        if (!streamPushService.batchStop(batchGBStreamParam.getGbStreams())){
+            throw new ControllerException(ErrorCode.ERROR100);
         }
     }
 
@@ -249,7 +243,7 @@
     @Parameter(name = "app", description = "搴旂敤鍚�", required = true)
     @Parameter(name = "stream", description = "娴乮d", required = true)
     @Parameter(name = "mediaServerId", description = "濯掍綋鏈嶅姟鍣╥d")
-    public WVPResult<StreamInfo> getPlayUrl(@RequestParam String app,@RequestParam String stream,
+    public StreamInfo getPlayUrl(@RequestParam String app,@RequestParam String stream,
                                             @RequestParam(required = false) String mediaServerId){
         boolean authority = false;
         // 鏄惁鐧婚檰鐢ㄦ埛, 鐧婚檰鐢ㄦ埛杩斿洖瀹屾暣淇℃伅
@@ -257,52 +251,38 @@
         if (userInfo!= null) {
             authority = true;
         }
-        WVPResult<StreamInfo> result = new WVPResult<>();
         StreamPushItem push = streamPushService.getPush(app, stream);
         if (push != null && !push.isSelf()) {
-            result.setCode(-1);
-            result.setMsg("鏉ヨ嚜鍏朵粬骞冲彴鐨勬帹娴佷俊鎭�");
-            return result;
+            throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏉ヨ嚜鍏朵粬骞冲彴鐨勬帹娴佷俊鎭�");
         }
         StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
-        if (streamInfo != null){
-            result.setCode(0);
-            result.setMsg("success");
-            result.setData(streamInfo);
-        }else {
-            result.setCode(-1);
-            result.setMsg("鑾峰彇鎾斁鍦板潃澶辫触");
+        if (streamInfo == null){
+            throw new ControllerException(ErrorCode.ERROR100.getCode(), "鑾峰彇鎾斁鍦板潃澶辫触");
         }
-
-        return result;
+        return streamInfo;
     }
 
     /**
-     * 鑾峰彇鎺ㄦ祦鎾斁鍦板潃
+     * 娣诲姞鎺ㄦ祦淇℃伅
      * @param stream 鎺ㄦ祦淇℃伅
      * @return
      */
     @PostMapping(value = "/add")
     @ResponseBody
-    @Operation(summary = "鍋滄瑙嗛鍥炴斁")
-    public WVPResult<StreamInfo> add(@RequestBody StreamPushItem stream){
+    @Operation(summary = "娣诲姞鎺ㄦ祦淇℃伅")
+    public void add(@RequestBody StreamPushItem stream){
         if (ObjectUtils.isEmpty(stream.getGbId())) {
-
-            return new WVPResult<>(400, "鍥芥爣ID涓嶅彲涓虹┖", null);
+            throw new ControllerException(ErrorCode.ERROR400.getCode(), "鍥芥爣ID涓嶅彲涓虹┖");
         }
         if (ObjectUtils.isEmpty(stream.getApp()) && ObjectUtils.isEmpty(stream.getStream())) {
-            return new WVPResult<>(400, "app鎴杝tream涓嶅彲涓虹┖", null);
+            throw new ControllerException(ErrorCode.ERROR400.getCode(), "app鎴杝tream涓嶅彲涓虹┖");
         }
         stream.setStatus(false);
         stream.setPushIng(false);
         stream.setAliveSecond(0L);
         stream.setTotalReaderCount("0");
-        boolean result = streamPushService.add(stream);
-
-        if (result) {
-            return new WVPResult<>(0, "success", null);
-        }else {
-            return new WVPResult<>(-1, "fail", null);
+        if (!streamPushService.add(stream)) {
+            throw new ControllerException(ErrorCode.ERROR100);
         }
     }
 }

--
Gitblit v1.8.0