wangyunpeng před 20 hodinami
rodič
revize
b7f5aa9ae4

+ 7 - 0
core/src/main/java/com/tzld/videoVector/service/VideoSearchService.java

@@ -8,6 +8,7 @@ import com.tzld.videoVector.model.param.MatchTopNVideoParam;
 import com.tzld.videoVector.model.vo.VideoMatchResult;
 
 import java.util.List;
+import java.util.Map;
 
 public interface VideoSearchService {
 
@@ -31,4 +32,10 @@ public interface VideoSearchService {
      * @return 匹配结果列表
      */
     List<VideoMatchResult> matchTopNVideo(MatchTopNVideoParam param);
+
+    /**
+     * 获取所有启用的 configCode 列表
+     * @return configCode -> configName 的映射
+     */
+    Map<String, String> getAllConfigCodes();
 }

+ 21 - 0
core/src/main/java/com/tzld/videoVector/service/impl/VideoSearchServiceImpl.java

@@ -739,4 +739,25 @@ public class VideoSearchServiceImpl implements VideoSearchService {
 
         return filteredMatches;
     }
+
+    @Override
+    public Map<String, String> getAllConfigCodes() {
+        try {
+            DeconstructVectorConfigExample example = new DeconstructVectorConfigExample();
+            example.createCriteria().andEnabledEqualTo((short) 1);
+            example.setOrderByClause("priority ASC");
+            List<DeconstructVectorConfig> configs = deconstructVectorConfigMapper.selectByExample(example);
+            if (configs == null || configs.isEmpty()) {
+                return Collections.emptyMap();
+            }
+            Map<String, String> result = new LinkedHashMap<>();
+            for (DeconstructVectorConfig config : configs) {
+                result.putIfAbsent(config.getConfigCode(), config.getConfigName());
+            }
+            return result;
+        } catch (Exception e) {
+            log.error("查询所有 configCode 失败: {}", e.getMessage(), e);
+            return Collections.emptyMap();
+        }
+    }
 }

+ 7 - 4
server/src/main/java/com/tzld/videoVector/controller/VideoSearchController.java

@@ -8,12 +8,10 @@ import com.tzld.videoVector.model.param.MatchTopNVideoParam;
 import com.tzld.videoVector.model.vo.VideoMatchResult;
 import com.tzld.videoVector.service.VideoSearchService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/videoSearch")
@@ -36,4 +34,9 @@ public class VideoSearchController {
     public CommonResponse<List<VideoMatchResult>> matchTopNVideo(@RequestBody MatchTopNVideoParam param) {
         return CommonResponse.success(videoSearchService.matchTopNVideo(param));
     }
+
+    @GetMapping("/getAllConfigCodes")
+    public CommonResponse<Map<String, String>> getAllConfigCodes() {
+        return CommonResponse.success(videoSearchService.getAllConfigCodes());
+    }
 }