Ver código fonte

Merge remote-tracking branch 'origin/master'

2507040827 4 semanas atrás
pai
commit
ba263717d1

+ 11 - 2
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/impl/FastApiServiceImpl.java

@@ -67,8 +67,17 @@ public class FastApiServiceImpl implements FastApiService {
             HttpPost httpPost = new HttpPost(url);
             httpPost.setHeader("Content-Type", "application/json");
 
-            // 构造请求体
-            String requestBody = JSON.toJSONString(request);
+            // 手动构造符合 FastAPI 要求的 JSON 请求体(使用下划线格式)
+            com.alibaba.fastjson.JSONObject jsonBody = new com.alibaba.fastjson.JSONObject();
+            jsonBody.put("business_attr", request.getBusinessAttr());
+            jsonBody.put("phrase", request.getPhrase());
+            if (request.getTagCategoryId() != null) {
+                jsonBody.put("tag_category_id", request.getTagCategoryId());
+            }
+
+            String requestBody = jsonBody.toJSONString();
+            log.info("请求体:{}", requestBody);
+
             httpPost.setEntity(new StringEntity(requestBody, "UTF-8"));
 
             try (CloseableHttpResponse response = httpClient.execute(httpPost)) {