Browse Source

按钮权限不从缓存取

laoyao 3 years ago
parent
commit
e3560e69c8

+ 7 - 7
imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/auth/impl/ResourceServiceImpl.java

@@ -67,15 +67,15 @@ public class ResourceServiceImpl extends SuperCacheServiceImpl<ResourceMapper, R
         BaseContextHandler.setTenant("0000");
 
         List<Resource> visibleResource = new ArrayList<>();
-        CacheObject cacheObject = cacheChannel.get(CacheKey.USER_RESOURCE, userResourceKey, (key) -> {
+//        CacheObject cacheObject = cacheChannel.get(CacheKey.USER_RESOURCE, userResourceKey, (key) -> {
             visibleResource.addAll(baseMapper.findVisibleResource(resource));
-            return visibleResource.stream().mapToLong(Resource::getId).boxed().collect(Collectors.toList());
-        });
+//            return visibleResource.stream().mapToLong(Resource::getId).boxed().collect(Collectors.toList());
+//        });
 
         //cache 和 db 都没有时直接返回
-        if (cacheObject.getValue() == null) {
-            return Collections.emptyList();
-        }
+//        if (cacheObject.getValue() == null) {
+//            return Collections.emptyList();
+//        }
 
         if (!visibleResource.isEmpty()) {
             visibleResource.forEach((r) -> {
@@ -87,7 +87,7 @@ public class ResourceServiceImpl extends SuperCacheServiceImpl<ResourceMapper, R
 
         // 若list里面的值过多,而资源又均没有缓存(或者缓存击穿),则这里的效率并不高
 
-        List<Long> list = (List<Long>) cacheObject.getValue();
+        List<Long> list = visibleResource.stream().mapToLong(Resource::getId).boxed().collect(Collectors.toList());
         List<Resource> resourceList = list.stream().map(this::getByIdCache).filter(Objects::nonNull).collect(Collectors.toList());
 
         if (resource.getMenuId() == null) {