|
@@ -67,8 +67,17 @@ public class FastApiServiceImpl implements FastApiService {
|
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
|
httpPost.setHeader("Content-Type", "application/json");
|
|
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"));
|
|
httpPost.setEntity(new StringEntity(requestBody, "UTF-8"));
|
|
|
|
|
|
|
|
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
|
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|