Ver Fonte

拓展删除接口

xucaiqin há 1 ano atrás
pai
commit
1be27ec477

+ 12 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/controller/VideoController.java

@@ -38,6 +38,7 @@ public class VideoController {
 
     /**
      * 获取未关联的设备
+     *
      * @param name
      * @return
      */
@@ -68,6 +69,17 @@ public class VideoController {
         return Result.ok(sDeviceService.update(streamUpdateRes) != 0 ? "更新成功" : "更新失败");
     }
 
+    /**
+     * 删除
+     *
+     * @param id
+     * @return
+     */
+    @DeleteMapping(value = "/delete", name = "删除")
+    public Result<Object> delete(@RequestParam("id") Long id) {
+        return Result.ok(sDeviceService.delete(id), "删除成功");
+    }
+
     /**
      * 更新拉流信息状态
      *

+ 14 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/SDeviceService.java

@@ -30,6 +30,7 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -101,6 +102,10 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         SDevice sDevice = new SDevice();
         BeanUtil.copyProperties(streamAddRes, sDevice);
         sDevice.setUseFlag(1);
+        SDevice sDevice1 = sDeviceMapper.selectOne(new LambdaQueryWrapper<SDevice>().eq(SDevice::getPath, sDevice.getPath()).eq(SDevice::getDelFlag, Global.UN_DEL));
+        if (Objects.nonNull(sDevice1)) {
+            throw new BusinessException(sDevice.getPath() + "流标签已存在");
+        }
         int insert = sDeviceMapper.insert(sDevice);
         //这里需要拉流一下
         if (insert > 0) {
@@ -245,4 +250,13 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         List<SDevice> sDevices = sDeviceMapper.selectList(new LambdaQueryWrapper<SDevice>().eq(SDevice::getDelFlag, Global.UN_DEL));
         return devicesVos.stream().filter(d -> sDevices.stream().noneMatch(d2 -> Objects.equals(d2.getDeviceId(), d.getId()))).collect(Collectors.toList());
     }
+
+    public Object delete(Long id) {
+        SDevice sDevice = new SDevice();
+        sDevice.setId(id);
+        sDevice.setDeleteTime(LocalDateTime.now());
+        sDevice.setDelFlag(Global.DEL);
+        sDeviceMapper.updateById(sDevice);
+        return true;
+    }
 }