瀏覽代碼

【代码评审】IoT:场景联动的 review

YunaiV 7 月之前
父節點
當前提交
516e3a2387

+ 2 - 1
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java

@@ -185,11 +185,12 @@ public class IotDeviceController {
         return success(deviceService.getMqttConnectionParams(deviceId));
     }
 
+    // TODO @haohao:可以使用 @RequestParam("productKey") String productKey, @RequestParam("deviceNames") List<String> deviceNames 来接收哇?
     @GetMapping("/list-by-product-key-and-names")
     @Operation(summary = "通过产品标识和设备名称列表获取设备")
     @PreAuthorize("@ss.hasPermission('iot:device:query')")
     public CommonResult<List<IotDeviceRespVO>> getDevicesByProductKeyAndNames(@Valid IotDeviceByProductKeyAndNamesReqVO reqVO) {
-        List<IotDeviceDO> devices = deviceService.getDevicesByProductKeyAndNames(reqVO.getProductKey(), reqVO.getDeviceNames());
+        List<IotDeviceDO> devices = deviceService.getDeviceListByProductKeyAndNames(reqVO.getProductKey(), reqVO.getDeviceNames());
         return success(BeanUtils.toBean(devices, IotDeviceRespVO.class));
     }
 

+ 6 - 0
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/IotProductController.java

@@ -84,6 +84,9 @@ public class IotProductController {
     @PreAuthorize("@ss.hasPermission('iot:product:query')")
     public CommonResult<IotProductRespVO> getProduct(@RequestParam("id") Long id) {
         IotProductDO product = productService.getProduct(id);
+        if (product == null) {
+            return success(null);
+        }
         // 拼接数据
         IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
         return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
@@ -99,6 +102,9 @@ public class IotProductController {
     @PreAuthorize("@ss.hasPermission('iot:product:query')")
     public CommonResult<IotProductRespVO> getProductByKey(@RequestParam("productKey") String productKey) {
         IotProductDO product = productService.getProductByProductKey(productKey);
+        if (product == null) {
+            return success(null);
+        }
         // 拼接数据
         IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
         return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {

+ 1 - 0
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotRuleSceneDO.java

@@ -145,6 +145,7 @@ public class IotRuleSceneDO extends TenantBaseDO {
     public static class TriggerConditionParameter {
 
         // TODO @芋艿: identifier0 存事件和服务的 identifier 属性的情况 identifier0 就为 null 解决前端回显问题
+        // TODO @haohao:可以根据 TriggerCondition.type 判断,是服务、还是事件、还是属性么?
         /**
          * 标识符(事件、服务)
          *

+ 1 - 1
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceService.java

@@ -226,6 +226,6 @@ public interface IotDeviceService {
      * @param deviceNames 设备名称列表
      * @return 设备列表
      */
-    List<IotDeviceDO> getDevicesByProductKeyAndNames(String productKey, List<String> deviceNames);
+    List<IotDeviceDO> getDeviceListByProductKeyAndNames(String productKey, List<String> deviceNames);
 
 }

+ 1 - 1
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceServiceImpl.java

@@ -452,7 +452,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
     }
 
     @Override
-    public List<IotDeviceDO> getDevicesByProductKeyAndNames(String productKey, List<String> deviceNames) {
+    public List<IotDeviceDO> getDeviceListByProductKeyAndNames(String productKey, List<String> deviceNames) {
         if (StrUtil.isBlank(productKey) || CollUtil.isEmpty(deviceNames)) {
             return Collections.emptyList();
         }