|
@@ -1,6 +1,5 @@ |
|
|
package com.hz.pm.api.meta.helper.basic; |
|
|
package com.hz.pm.api.meta.helper.basic; |
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
|
|
import com.github.benmanes.caffeine.cache.Caffeine; |
|
|
import com.github.benmanes.caffeine.cache.Caffeine; |
|
|
import com.github.benmanes.caffeine.cache.LoadingCache; |
|
|
import com.github.benmanes.caffeine.cache.LoadingCache; |
|
|
import com.hz.pm.api.meta.assembler.MetaTagAssembler; |
|
|
import com.hz.pm.api.meta.assembler.MetaTagAssembler; |
|
@@ -8,6 +7,7 @@ import com.hz.pm.api.meta.helper.TagCache; |
|
|
import com.hz.pm.api.meta.model.dto.TagDTO; |
|
|
import com.hz.pm.api.meta.model.dto.TagDTO; |
|
|
import com.hz.pm.api.meta.model.dto.TagTreeDTO; |
|
|
import com.hz.pm.api.meta.model.dto.TagTreeDTO; |
|
|
import com.hz.pm.api.meta.service.IMetaTagService; |
|
|
import com.hz.pm.api.meta.service.IMetaTagService; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.springframework.beans.factory.InitializingBean; |
|
|
import org.springframework.beans.factory.InitializingBean; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@@ -21,6 +21,7 @@ import java.util.stream.Collectors; |
|
|
* @author liuxinxin |
|
|
* @author liuxinxin |
|
|
* @date 2022/12/22 上午11:56 |
|
|
* @date 2022/12/22 上午11:56 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
public abstract class AbstractTagsCache implements InitializingBean, TagCache { |
|
|
public abstract class AbstractTagsCache implements InitializingBean, TagCache { |
|
|
|
|
|
|
|
|
protected static final int MAX_LEVEL = 4; |
|
|
protected static final int MAX_LEVEL = 4; |
|
@@ -39,7 +40,10 @@ public abstract class AbstractTagsCache implements InitializingBean, TagCache { |
|
|
.build(key -> { |
|
|
.build(key -> { |
|
|
// 查询全部 |
|
|
// 查询全部 |
|
|
List<TagDTO> tagDTOList = iMetaTagService.queryAll(); |
|
|
List<TagDTO> tagDTOList = iMetaTagService.queryAll(); |
|
|
Assert.isTrue(CollectionUtils.isNotEmpty(tagDTOList), "MetaTags queryAll is Empty"); |
|
|
|
|
|
|
|
|
if (tagDTOList.isEmpty()) { |
|
|
|
|
|
log.warn("当前层级对应树不存在:{}", key); |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
tagDtoMap = buildCateMap(tagDTOList); |
|
|
tagDtoMap = buildCateMap(tagDTOList); |
|
|
List<TagDTO> tagInLevel = tagDTOList.stream().filter(tagDto -> { |
|
|
List<TagDTO> tagInLevel = tagDTOList.stream().filter(tagDto -> { |
|
|
// 只过滤出小于等于level的tag |
|
|
// 只过滤出小于等于level的tag |
|
|