Commit 516e3a238776c87bc9c95127ed112eac65be2e51

Authored by YunaiV
1 parent 2585c475

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

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 { @@ -185,11 +185,12 @@ public class IotDeviceController {
185 return success(deviceService.getMqttConnectionParams(deviceId)); 185 return success(deviceService.getMqttConnectionParams(deviceId));
186 } 186 }
187 187
  188 + // TODO @haohao:可以使用 @RequestParam("productKey") String productKey, @RequestParam("deviceNames") List<String> deviceNames 来接收哇?
188 @GetMapping("/list-by-product-key-and-names") 189 @GetMapping("/list-by-product-key-and-names")
189 @Operation(summary = "通过产品标识和设备名称列表获取设备") 190 @Operation(summary = "通过产品标识和设备名称列表获取设备")
190 @PreAuthorize("@ss.hasPermission('iot:device:query')") 191 @PreAuthorize("@ss.hasPermission('iot:device:query')")
191 public CommonResult<List<IotDeviceRespVO>> getDevicesByProductKeyAndNames(@Valid IotDeviceByProductKeyAndNamesReqVO reqVO) { 192 public CommonResult<List<IotDeviceRespVO>> getDevicesByProductKeyAndNames(@Valid IotDeviceByProductKeyAndNamesReqVO reqVO) {
192 - List<IotDeviceDO> devices = deviceService.getDevicesByProductKeyAndNames(reqVO.getProductKey(), reqVO.getDeviceNames()); 193 + List<IotDeviceDO> devices = deviceService.getDeviceListByProductKeyAndNames(reqVO.getProductKey(), reqVO.getDeviceNames());
193 return success(BeanUtils.toBean(devices, IotDeviceRespVO.class)); 194 return success(BeanUtils.toBean(devices, IotDeviceRespVO.class));
194 } 195 }
195 196
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 { @@ -84,6 +84,9 @@ public class IotProductController {
84 @PreAuthorize("@ss.hasPermission('iot:product:query')") 84 @PreAuthorize("@ss.hasPermission('iot:product:query')")
85 public CommonResult<IotProductRespVO> getProduct(@RequestParam("id") Long id) { 85 public CommonResult<IotProductRespVO> getProduct(@RequestParam("id") Long id) {
86 IotProductDO product = productService.getProduct(id); 86 IotProductDO product = productService.getProduct(id);
  87 + if (product == null) {
  88 + return success(null);
  89 + }
87 // 拼接数据 90 // 拼接数据
88 IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId()); 91 IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
89 return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> { 92 return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
@@ -99,6 +102,9 @@ public class IotProductController { @@ -99,6 +102,9 @@ public class IotProductController {
99 @PreAuthorize("@ss.hasPermission('iot:product:query')") 102 @PreAuthorize("@ss.hasPermission('iot:product:query')")
100 public CommonResult<IotProductRespVO> getProductByKey(@RequestParam("productKey") String productKey) { 103 public CommonResult<IotProductRespVO> getProductByKey(@RequestParam("productKey") String productKey) {
101 IotProductDO product = productService.getProductByProductKey(productKey); 104 IotProductDO product = productService.getProductByProductKey(productKey);
  105 + if (product == null) {
  106 + return success(null);
  107 + }
102 // 拼接数据 108 // 拼接数据
103 IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId()); 109 IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
104 return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> { 110 return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
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 { @@ -145,6 +145,7 @@ public class IotRuleSceneDO extends TenantBaseDO {
145 public static class TriggerConditionParameter { 145 public static class TriggerConditionParameter {
146 146
147 // TODO @芋艿: identifier0 存事件和服务的 identifier 属性的情况 identifier0 就为 null 解决前端回显问题 147 // TODO @芋艿: identifier0 存事件和服务的 identifier 属性的情况 identifier0 就为 null 解决前端回显问题
  148 + // TODO @haohao:可以根据 TriggerCondition.type 判断,是服务、还是事件、还是属性么?
148 /** 149 /**
149 * 标识符(事件、服务) 150 * 标识符(事件、服务)
150 * 151 *
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 { @@ -226,6 +226,6 @@ public interface IotDeviceService {
226 * @param deviceNames 设备名称列表 226 * @param deviceNames 设备名称列表
227 * @return 设备列表 227 * @return 设备列表
228 */ 228 */
229 - List<IotDeviceDO> getDevicesByProductKeyAndNames(String productKey, List<String> deviceNames); 229 + List<IotDeviceDO> getDeviceListByProductKeyAndNames(String productKey, List<String> deviceNames);
230 230
231 } 231 }
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 { @@ -452,7 +452,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
452 } 452 }
453 453
454 @Override 454 @Override
455 - public List<IotDeviceDO> getDevicesByProductKeyAndNames(String productKey, List<String> deviceNames) { 455 + public List<IotDeviceDO> getDeviceListByProductKeyAndNames(String productKey, List<String> deviceNames) {
456 if (StrUtil.isBlank(productKey) || CollUtil.isEmpty(deviceNames)) { 456 if (StrUtil.isBlank(productKey) || CollUtil.isEmpty(deviceNames)) {
457 return Collections.emptyList(); 457 return Collections.emptyList();
458 } 458 }