소스 검색

增加iot 服务信息删除功能

jingyuanchao 1 년 전
부모
커밋
b155786eea

+ 6 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotServerInfoController.java

@@ -52,6 +52,12 @@ public class IotServerInfoController {
         serverInfoService.editIot(req);
         return AjaxResult.success();
     }
+    @ApiOperation("删除")
+    @DeleteMapping({"/{id}"})
+    AjaxResult del(@PathVariable Long id) {
+        serverInfoService.del(id);
+        return AjaxResult.success();
+    }
 
 
     @ApiOperation("详情")

+ 2 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotServerInfoService.java

@@ -26,4 +26,6 @@ public interface IotServerInfoService extends IService<IotServerInfo> {
     void editIot(IotServerInfoEditDto req);
 
     void export(IotServerInfoPageDto req, HttpServletResponse response);
+
+    void del(Long id);
 }

+ 13 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotServerInfoServiceImpl.java

@@ -159,4 +159,17 @@ public class IotServerInfoServiceImpl extends ServiceImpl<IotServerInfoMapper, I
             response.setCharacterEncoding("utf-8");
         }
     }
+
+    @Transactional
+    @Override
+    public void del(Long id) {
+        final IotServerInfo info = getById(id);
+        if (ObjectUtil.isEmpty(info)) {
+            throw new RuntimeException("未找到具体iot服务!");
+        }
+        if (1 == info.getIotStatus()) {
+            throw new RuntimeException("请先停用该iot服务!");
+        }
+        removeById(id);
+    }
 }