Browse Source

完成chat search

tsurumure 5 tháng trước cách đây
mục cha
commit
3b4f4142d6

+ 6 - 5
src/main/java/com/backendsys/modules/sdk/bocha/service/impl/BochaServiceImpl.java

@@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.databind.module.SimpleModule;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
@@ -140,11 +141,11 @@ public class BochaServiceImpl implements BochaService {
             context.append("{");
             for (BochaResult item : bochaResultList) {
                 context.append("\"" + index + "\":{"+
-                        "\"name\":\"" + item.getName() + "\"," +
-                        "\"summary\":\"" + item.getSummary() + "\"," +
-                        "\"site_icon\":\"" + item.getSiteIcon() + "\"," +
-                        "\"site_name\":\"" + item.getSiteName() + "\"," +
-                        "\"url\":\"" + item.getUrl() + "\"" +
+                        "\"name\":\"" + item.getName().replace("\"", "\\\"") + "\"," +
+                        "\"summary\":\"" + item.getSummary().replace("\"", "\\\"") + "\"," +
+                        "\"site_icon\":\"" + item.getSiteIcon().replace("\"", "\\\"") + "\"," +
+                        "\"site_name\":\"" + item.getSiteName().replace("\"", "\\\"") + "\"," +
+                        "\"url\":\"" + item.getUrl().replace("\"", "\\\"") + "\"" +
                     "}" +
                     ((index == bochaResultList.size()) ? "": ",")
                 );