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

This commit is contained in:
YunaiV 2025-03-30 09:57:27 +08:00
parent 2585c4753a
commit 516e3a2387
5 changed files with 11 additions and 3 deletions

View File

@ -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));
}

View File

@ -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 -> {

View File

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

View File

@ -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);
}

View File

@ -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();
}