Jelajahi Sumber

调整设备型号缓存管理

liuyaowen 1 tahun lalu
induk
melakukan
d3d9de16ce

+ 7 - 5
src/main/java/com/yunfeiyun/agmp/iotm/device/service/impl/TosDevicetypeServiceImpl.java

@@ -5,6 +5,7 @@ import com.yunfeiyun.agmp.common.enums.RedisCacheKey;
 import com.yunfeiyun.agmp.common.framework.manager.RedisCacheManager;
 import com.yunfeiyun.agmp.common.utils.DictUtils;
 import com.yunfeiyun.agmp.iot.common.domain.TosDevicetype;
+import com.yunfeiyun.agmp.iot.common.service.TypeCacheService;
 import com.yunfeiyun.agmp.iotm.device.domain.resvo.IotDevicetypeListResVo;
 import com.yunfeiyun.agmp.iotm.device.domain.resvo.TosDevicetypeResVo;
 import com.yunfeiyun.agmp.iotm.device.mapper.TosDevicetypeMapper;
@@ -31,13 +32,14 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
     @Autowired
     private TosDevicetypeMapper tosDevicetypeMapper;
     @Resource
-    private RedisCacheManager redisCacheManager;
+    private TypeCacheService typeCacheService;
+
 
     @PostConstruct
     public void init(){
         List<TosDevicetype> tosDevicetypeList = tosDevicetypeMapper.selectTosDevicetypeList(null);
         for(TosDevicetype tosDevicetype : tosDevicetypeList){
-            redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode(),tosDevicetype);
+            typeCacheService.setCache(tosDevicetype);
         }
     }
 
@@ -72,7 +74,7 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
     @Override
     public int insertTosDevicetypeByTosMsg(TosDevicetype tosDevicetype){
         int result = tosDevicetypeMapper.insertTosDevicetype(tosDevicetype);
-        redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode(),tosDevicetype);
+        typeCacheService.setCache(tosDevicetype);
         return result;
     }
 
@@ -85,7 +87,7 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
     @Override
     public int updateTosDevicetypeByTosMsg(TosDevicetype tosDevicetype){
         int result = tosDevicetypeMapper.updateTosDevicetype(tosDevicetype);
-        redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode(),tosDevicetype);
+        typeCacheService.setCache(tosDevicetype);
         return result;
     }
 
@@ -109,7 +111,7 @@ public class TosDevicetypeServiceImpl implements ITosDevicetypeService
            return result;
         }
         result = tosDevicetypeMapper.deleteTosDevicetypeByDevtypeBid(tosDevicetype.getDevtypeBid());
-        redisCacheManager.deleteObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode());
+        typeCacheService.deleteCache(tosDevicetype);
         return result;
     }