From d4d6f6a7c51fc5088e859b3ddf72446c6975d176 Mon Sep 17 00:00:00 2001 From: xiwa Date: Sat, 9 Mar 2024 20:23:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E7=BC=93=E5=AD=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cc/iotkit/data/cache/ProductCacheEvict.java | 4 ++++ .../main/java/cc/iotkit/data/service/ProductDataCache.java | 5 +++-- .../main/java/cc/iotkit/data/config/UserIDAuditorConfig.java | 3 ++- .../src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java b/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java index 6a0b5360..adfc1447 100644 --- a/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java +++ b/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java @@ -11,4 +11,8 @@ public class ProductCacheEvict { public void findById(Long id) { } + @CacheEvict(value = Constants.CACHE_PRODUCT, key = "#root.method.name+#productKey") + public void findByProductKey(String productKey) { + } + } diff --git a/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java b/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java index 1ea4d16e..b9dd4d73 100644 --- a/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java +++ b/iot-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java @@ -29,13 +29,13 @@ public class ProductDataCache implements IProductData { } @Override - @Cacheable(value = Constants.CACHE_PRODUCT, key = "#root.targetClass+#productKey", unless = "#result == null") + @Cacheable(value = Constants.CACHE_PRODUCT, key = "#root.method.name+#productKey", unless = "#result == null") public Product findByProductKey(String productKey) { return productData.findByProductKey(productKey); } @Override - @Cacheable(value = Constants.CACHE_PRODUCT, key = "#root.targetClass+#productKey", unless = "#result == null") + @Cacheable(value = Constants.CACHE_PRODUCT, key = "#root.method.name+#productKey", unless = "#result == null") public void delByProductKey(String productKey) { } @@ -72,6 +72,7 @@ public class ProductDataCache implements IProductData { Product p = productData.save(data); //清除缓存 productCacheEvict.findById(p.getId()); + productCacheEvict.findByProductKey(p.getProductKey()); return p; } diff --git a/iot-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/config/UserIDAuditorConfig.java b/iot-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/config/UserIDAuditorConfig.java index 0dfbd85c..70193b44 100644 --- a/iot-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/config/UserIDAuditorConfig.java +++ b/iot-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/config/UserIDAuditorConfig.java @@ -14,6 +14,7 @@ import java.util.Optional; public class UserIDAuditorConfig implements AuditorAware { @Override public Optional getCurrentAuditor() { - return Optional.of(LoginHelper.getUserId()==null?1l:LoginHelper.getUserId()); + Long userId = LoginHelper.getUserId(); + return Optional.of(userId == null ? 1 : userId); } } diff --git a/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java b/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java index 2f488c93..0c6bedde 100644 --- a/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java +++ b/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java @@ -89,6 +89,9 @@ public class PluginMainImpl implements IPluginMain, DeviceService { if (product.isTransparent()) { //如果是透传设备,取父级设备进行链路查找 DeviceInfo parent = deviceInfoData.findByDeviceId(deviceInfo.getParentId()); + if(parent==null){ + throw new BizException(ErrCode.DEVICE_NOT_FOUND,"未找到父级设备"); + } linkPk = parent.getProductKey(); linkDn = parent.getDeviceName(); }