瀏覽代碼

恢复字典表及 标签表字段校验,及初始化缓存

tags/24080901
niohe·erbao 1 年之前
父節點
當前提交
60e6cba04e
共有 2 個文件被更改,包括 26 次插入27 次删除
  1. +8
    -8
      pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractDictionaryCache.java
  2. +18
    -19
      pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractTagsCache.java

+ 8
- 8
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<DictionaryDTO> dictionaryDTOList = iMetaDictionaryService.queryAll();
// dictionaryMap = buildCateMap(dictionaryDTOList);
// Map<String, List<DictionaryDTO>> 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<DictionaryDTO> dictionaryDTOList = iMetaDictionaryService.queryAll();
dictionaryMap = buildCateMap(dictionaryDTOList);
Map<String, List<DictionaryDTO>> dictionaryTypeListMap = dictionaryDTOList.stream().collect(Collectors.groupingBy(DictionaryDTO::getDictionaryType));
return dictionaryTypeListMap.get(key);
});
warmUp();
}

private Map<String, DictionaryDTO> buildCateMap(List<DictionaryDTO> dictionaryDTOList) {


+ 18
- 19
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<TagDTO> tagDTOList = iMetaTagService.queryAll();
// // TODO 临时关闭校验
//// Assert.isTrue(CollectionUtils.isNotEmpty(tagDTOList), "MetaTags queryAll is Empty");
// tagDtoMap = buildCateMap(tagDTOList);
// List<TagDTO> tagInLevel = tagDTOList.stream().filter(tagDto -> {
// // 只过滤出小于等于level的tag
// if (Objects.isNull(tagDto.getTagLevel())) {
// return false;
// }
// return Integer.parseInt(key) >= tagDto.getTagLevel();
// }).collect(Collectors.toList());
// List<TagTreeDTO> treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel);
// return toTreeStructure(treeDtos);
// });
// warmUp();
tagsCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES)
.refreshAfterWrite(5, TimeUnit.MINUTES)
.build(key -> {
// 查询全部
List<TagDTO> tagDTOList = iMetaTagService.queryAll();
Assert.isTrue(CollectionUtils.isNotEmpty(tagDTOList), "MetaTags queryAll is Empty");
tagDtoMap = buildCateMap(tagDTOList);
List<TagDTO> tagInLevel = tagDTOList.stream().filter(tagDto -> {
// 只过滤出小于等于level的tag
if (Objects.isNull(tagDto.getTagLevel())) {
return false;
}
return Integer.parseInt(key) >= tagDto.getTagLevel();
}).collect(Collectors.toList());
List<TagTreeDTO> treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel);
return toTreeStructure(treeDtos);
});
warmUp();
}

private Map<String, TagDTO> buildCateMap(List<TagDTO> tagDTOList) {


Loading…
取消
儲存