wangyunpeng 12 saat önce
ebeveyn
işleme
3528e9c6d3

+ 2 - 1
core/src/main/java/com/tzld/videoVector/service/VideoSearchService.java

@@ -1,5 +1,6 @@
 package com.tzld.videoVector.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.tzld.videoVector.model.param.DeconstructParam;
 import com.tzld.videoVector.model.param.GetDeconstructParam;
 import com.tzld.videoVector.model.param.MatchTopNVideoParam;
@@ -20,7 +21,7 @@ public interface VideoSearchService {
      * @param param 查询参数
      * @return 解构结果JSON字符串
      */
-    String getDeconstructResult(GetDeconstructParam param);
+    JSONObject getDeconstructResult(GetDeconstructParam param);
 
     /**
      * 匹配TopN视频

+ 1 - 1
core/src/main/java/com/tzld/videoVector/service/impl/DeconstructServiceImpl.java

@@ -117,7 +117,7 @@ public class DeconstructServiceImpl implements DeconstructService {
                     return null;
                 }
 
-                String taskId = data.getString("taskId");
+                String taskId = data.getString("task_id");
                 log.info("内容解构任务创建成功,taskId: {}", taskId);
                 return taskId;
             }

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

@@ -109,7 +109,7 @@ public class VideoSearchServiceImpl implements VideoSearchService {
     }
 
     @Override
-    public String getDeconstructResult(GetDeconstructParam param) {
+    public JSONObject getDeconstructResult(GetDeconstructParam param) {
         if (param == null || param.getTaskId() == null || param.getTaskId().trim().isEmpty()) {
             log.error("getDeconstructResult 参数或 taskId 为空");
             return null;
@@ -228,7 +228,7 @@ public class VideoSearchServiceImpl implements VideoSearchService {
     /**
      * 从数据库记录构建返回结果
      */
-    private String buildResultFromContent(DeconstructContent content) {
+    private JSONObject buildResultFromContent(DeconstructContent content) {
         JSONObject jsonResult = new JSONObject();
         jsonResult.put("taskId", content.getTaskId());
         jsonResult.put("status", content.getStatus());
@@ -238,7 +238,7 @@ public class VideoSearchServiceImpl implements VideoSearchService {
         jsonResult.put("fromCache", true);
 
         if (content.getResultJson() != null) {
-            jsonResult.put("result", content.getResultJson());
+            jsonResult.put("result", JSONObject.parseObject(content.getResultJson()));
         }
 
         if (content.getFailureReason() != null) {
@@ -260,13 +260,13 @@ public class VideoSearchServiceImpl implements VideoSearchService {
             jsonResult.put("url", urlObj);
         }
 
-        return jsonResult.toJSONString();
+        return jsonResult;
     }
 
     /**
      * 从API结果构建返回结果
      */
-    private String buildResultFromApiResult(DeconstructResult result) {
+    private JSONObject buildResultFromApiResult(DeconstructResult result) {
         JSONObject jsonResult = new JSONObject();
         jsonResult.put("taskId", result.getTaskId());
         jsonResult.put("status", result.getStatus());
@@ -276,7 +276,7 @@ public class VideoSearchServiceImpl implements VideoSearchService {
         jsonResult.put("fromCache", false);
 
         if (result.getResult() != null) {
-            jsonResult.put("result", result.getResult());
+            jsonResult.put("result", JSONObject.parseObject(result.getResult()));
         }
 
         if (result.getReason() != null) {
@@ -298,7 +298,7 @@ public class VideoSearchServiceImpl implements VideoSearchService {
             jsonResult.put("url", urlObj);
         }
 
-        return jsonResult.toJSONString();
+        return jsonResult;
     }
 
     /**

+ 2 - 1
server/src/main/java/com/tzld/videoVector/controller/VideoSearchController.java

@@ -1,5 +1,6 @@
 package com.tzld.videoVector.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.tzld.videoVector.common.base.CommonResponse;
 import com.tzld.videoVector.model.param.DeconstructParam;
 import com.tzld.videoVector.model.param.GetDeconstructParam;
@@ -26,7 +27,7 @@ public class VideoSearchController {
     }
 
     @PostMapping("/getDeconstructResult")
-    public CommonResponse<String> getDeconstructResult(@RequestBody GetDeconstructParam param) {
+    public CommonResponse<JSONObject> getDeconstructResult(@RequestBody GetDeconstructParam param) {
         return CommonResponse.success(videoSearchService.getDeconstructResult(param));
     }