diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractDictionaryCache.java b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractDictionaryCache.java index 080acb7..e1175b6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractDictionaryCache.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractDictionaryCache.java @@ -29,14 +29,14 @@ public abstract class AbstractDictionaryCache implements InitializingBean, Dicti @Override public void afterPropertiesSet() { -// dictionaryCacheHelper = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) -// .refreshAfterWrite(5, TimeUnit.MINUTES).build(key -> { -// List dictionaryDTOList = iMetaDictionaryService.queryAll(); -// dictionaryMap = buildCateMap(dictionaryDTOList); -// Map> dictionaryTypeListMap = dictionaryDTOList.stream().collect(Collectors.groupingBy(DictionaryDTO::getDictionaryType)); -// return dictionaryTypeListMap.get(key); -// }); -// warmUp(); + dictionaryCacheHelper = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) + .refreshAfterWrite(5, TimeUnit.MINUTES).build(key -> { + List dictionaryDTOList = iMetaDictionaryService.queryAll(); + dictionaryMap = buildCateMap(dictionaryDTOList); + Map> dictionaryTypeListMap = dictionaryDTOList.stream().collect(Collectors.groupingBy(DictionaryDTO::getDictionaryType)); + return dictionaryTypeListMap.get(key); + }); + warmUp(); } private Map buildCateMap(List dictionaryDTOList) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractTagsCache.java b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractTagsCache.java index c20fc7b..413e410 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractTagsCache.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractTagsCache.java @@ -34,25 +34,24 @@ public abstract class AbstractTagsCache implements InitializingBean, TagCache { @Override public void afterPropertiesSet() { -// tagsCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) -// .refreshAfterWrite(5, TimeUnit.MINUTES) -// .build(key -> { -// // 查询全部 -// List tagDTOList = iMetaTagService.queryAll(); -// // TODO 临时关闭校验 -//// Assert.isTrue(CollectionUtils.isNotEmpty(tagDTOList), "MetaTags queryAll is Empty"); -// tagDtoMap = buildCateMap(tagDTOList); -// List tagInLevel = tagDTOList.stream().filter(tagDto -> { -// // 只过滤出小于等于level的tag -// if (Objects.isNull(tagDto.getTagLevel())) { -// return false; -// } -// return Integer.parseInt(key) >= tagDto.getTagLevel(); -// }).collect(Collectors.toList()); -// List treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel); -// return toTreeStructure(treeDtos); -// }); -// warmUp(); + tagsCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) + .refreshAfterWrite(5, TimeUnit.MINUTES) + .build(key -> { + // 查询全部 + List tagDTOList = iMetaTagService.queryAll(); + Assert.isTrue(CollectionUtils.isNotEmpty(tagDTOList), "MetaTags queryAll is Empty"); + tagDtoMap = buildCateMap(tagDTOList); + List tagInLevel = tagDTOList.stream().filter(tagDto -> { + // 只过滤出小于等于level的tag + if (Objects.isNull(tagDto.getTagLevel())) { + return false; + } + return Integer.parseInt(key) >= tagDto.getTagLevel(); + }).collect(Collectors.toList()); + List treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel); + return toTreeStructure(treeDtos); + }); + warmUp(); } private Map buildCateMap(List tagDTOList) {