From cb0883bcda72d7d329cc61d9a2ca212d5731b0bc Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 7 Jun 2025 17:17:56 +0800 Subject: [PATCH] fix --- config/redis/cmd.txt | 3 +++ .../north/controller/SearchController.java | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 config/redis/cmd.txt diff --git a/config/redis/cmd.txt b/config/redis/cmd.txt new file mode 100644 index 0000000..e075582 --- /dev/null +++ b/config/redis/cmd.txt @@ -0,0 +1,3 @@ + +# 获取redis中的key-value +redis-cli keys "kb*" | while read key; do echo "$key : $(redis-cli get "$key")"; done \ No newline at end of file diff --git a/src/main/java/com/knowledge/base/infrastructure/north/controller/SearchController.java b/src/main/java/com/knowledge/base/infrastructure/north/controller/SearchController.java index 55b9946..14148e0 100644 --- a/src/main/java/com/knowledge/base/infrastructure/north/controller/SearchController.java +++ b/src/main/java/com/knowledge/base/infrastructure/north/controller/SearchController.java @@ -2,8 +2,8 @@ package com.knowledge.base.infrastructure.north.controller; import cn.hutool.core.map.MapUtil; import cn.hutool.json.JSONUtil; +import com.knowledge.base.infrastructure.cache.FileCacheService; import com.knowledge.base.infrastructure.north.dto.SearchReq; -import com.knowledge.base.infrastructure.util.LocalCacheUtil; import com.google.common.collect.Maps; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; @@ -17,6 +17,7 @@ import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.sort.SortOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -36,6 +37,9 @@ public class SearchController { private final RestHighLevelClient esClient; + @Autowired + private FileCacheService fileCacheService; + @Value("${search.default-page-size:10}") private int defaultPageSize; @@ -92,8 +96,8 @@ public class SearchController { List fileNames = (List)req.get("fileNames"); Map filePaths = Maps.newHashMap(); fileNames.forEach(name -> { - if(LocalCacheUtil.get(name) != null) { - filePaths.put(name, LocalCacheUtil.get(name)); + if(fileCacheService.getPath(name).isPresent()) { + filePaths.put(name, fileCacheService.getPath(name)); } }); Map result = Maps.newHashMap();