From 89244932c6185cd39e9a9f8aa8bf3acf99329335 Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: 星期日, 11 四月 2021 15:00:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java |   44 +++++++++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
index ef617a6..834c00b 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
@@ -8,6 +8,7 @@
 import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
 import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam;
 import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,9 +18,13 @@
 import org.springframework.web.bind.annotation.*;
 import com.genersoft.iot.vmp.conf.SipConfig;
 
+/**
+ * 绾ц仈骞冲彴绠$悊
+ */
+@Api("绾ц仈骞冲彴绠$悊")
 @CrossOrigin
 @RestController
-@RequestMapping("/api")
+@RequestMapping("/api/platform")
 public class PlatformController {
 
     private final static Logger logger = LoggerFactory.getLogger(PlatformController.class);
@@ -36,7 +41,7 @@
 	@Autowired
 	private SipConfig sipConfig;
 
-    @GetMapping("/platforms/serverconfig")
+    @GetMapping("/server_config")
     public ResponseEntity<JSONObject> serverConfig() {
         JSONObject result = new JSONObject();
         result.put("deviceIp", sipConfig.getSipIp());
@@ -46,7 +51,7 @@
         return new ResponseEntity<>(result, HttpStatus.OK);
     }
 
-    @GetMapping("/platforms/{count}/{page}")
+    @GetMapping("/query/{count}/{page}")
     public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){
 
         if (logger.isDebugEnabled()) {
@@ -55,12 +60,12 @@
         return storager.queryParentPlatformList(page, count);
     }
 
-    @RequestMapping("/platforms/save")
+    @PostMapping("/save")
     @ResponseBody
     public ResponseEntity<String> savePlatform(@RequestBody ParentPlatform parentPlatform){
 
         if (logger.isDebugEnabled()) {
-            logger.debug("鏌ヨ鎵�鏈変笂绾ц澶嘇PI璋冪敤");
+            logger.debug("淇濆瓨涓婄骇骞冲彴淇℃伅API璋冪敤");
         }
         if (StringUtils.isEmpty(parentPlatform.getName())
                 ||StringUtils.isEmpty(parentPlatform.getServerGBId())
@@ -87,29 +92,30 @@
             if (parentPlatform.isEnable()) {
                 //  鍙淇濆瓨灏卞彂閫佹敞鍐�
                 commanderForPlatform.register(parentPlatform);
-            }else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 鍏抽棴鍚敤鏃舵敞閿�
+            } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 鍏抽棴鍚敤鏃舵敞閿�
                 commanderForPlatform.unregister(parentPlatform, null, null);
             }
 
-
+ 
             return new ResponseEntity<>("success", HttpStatus.OK);
-        }else {
+        } else {
             return new ResponseEntity<>("fail", HttpStatus.OK);
         }
     }
 
-    @RequestMapping("/platforms/delete")
+    @DeleteMapping("/delete/{serverGBId}")
     @ResponseBody
-    public ResponseEntity<String> deletePlatform(@RequestBody ParentPlatform parentPlatform){
+    public ResponseEntity<String> deletePlatform(@PathVariable String serverGBId){
 
         if (logger.isDebugEnabled()) {
-            logger.debug("鏌ヨ鎵�鏈変笂绾ц澶嘇PI璋冪敤");
+            logger.debug("鍒犻櫎涓婄骇骞冲彴API璋冪敤");
         }
-        if (StringUtils.isEmpty(parentPlatform.getServerGBId())
+        if (StringUtils.isEmpty(serverGBId)
         ){
             return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
         }
-
+        ParentPlatform parentPlatform = storager.queryParentPlatById(serverGBId);
+        if (parentPlatform == null) return new ResponseEntity<>("fail", HttpStatus.OK);
         // 鍙戦�佺绾挎秷鎭�,鏃犺鏄惁鎴愬姛閮藉垹闄ょ紦瀛�
         commanderForPlatform.unregister(parentPlatform, (event -> {
             // 娓呯┖redis缂撳瓨
@@ -133,18 +139,18 @@
         }
     }
 
-    @RequestMapping("/platforms/exit/{deviceGbId}")
+    @GetMapping("/exit/{deviceGbId}")
     @ResponseBody
     public ResponseEntity<String> exitPlatform(@PathVariable String deviceGbId){
 
         if (logger.isDebugEnabled()) {
-            logger.debug("鏌ヨ鎵�鏈変笂绾ц澶嘇PI璋冪敤");
+            logger.debug("鏌ヨ涓婄骇骞冲彴鏄惁瀛樺湪API璋冪敤锛�" + deviceGbId);
         }
         ParentPlatform parentPlatform = storager.queryParentPlatById(deviceGbId);
         return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK);
     }
 
-    @RequestMapping("/platforms/channelList")
+    @GetMapping("/channel_list")
     @ResponseBody
     public PageInfo<ChannelReduce> channelList(int page, int count,
                                               @RequestParam(required = false) String platformId,
@@ -167,7 +173,7 @@
     }
 
 
-    @RequestMapping("/platforms/updateChannelForGB")
+    @PostMapping("/update_channel_for_gb")
     @ResponseBody
     public ResponseEntity<String> updateChannelForGB(@RequestBody UpdateChannelParam param){
 
@@ -179,12 +185,12 @@
         return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
     }
 
-    @RequestMapping("/platforms/delChannelForGB")
+    @DeleteMapping("/del_channel_for_gb")
     @ResponseBody
     public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){
 
         if (logger.isDebugEnabled()) {
-            logger.debug("缁欎笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾API璋冪敤");
+            logger.debug("缁欎笂绾у钩鍙板垹闄ゅ浗鏍囬�氶亾API璋冪敤");
         }
         int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces());
 

--
Gitblit v1.8.0