bug修复

This commit is contained in:
2025-12-23 17:43:33 +08:00
parent 0ee6263970
commit 97abbefaa3
@@ -2667,7 +2667,12 @@ public class AiChatServiceImpl implements AiChatService {
if (response.statusCode() != 200) {
String errorBody = response.body().collect(java.util.stream.Collectors.joining("\n"));
log.error("工作流请求失败,状态码: {}, 响应: {}", response.statusCode(), errorBody);
apiCall.setResponseBody(errorBody);
// 将错误响应包装成JSON格式存储
Map<String, Object> errorWrapper = new HashMap<>();
errorWrapper.put("type", "error");
errorWrapper.put("data", errorBody);
errorWrapper.put("timestamp", System.currentTimeMillis());
apiCall.setResponseBody(JSON.toJSONString(errorWrapper));
cozeApiCallService.updateById(apiCall);
throw new RuntimeException("工作流请求失败,状态码: " + response.statusCode());
}
@@ -2755,9 +2760,13 @@ public class AiChatServiceImpl implements AiChatService {
}
}
// 保存原始响应数据到API调用记录
// 保存原始响应数据到API调用记录(包装成JSON格式)
try {
apiCall.setResponseBody(fullStreamData.toString());
Map<String, Object> streamDataWrapper = new HashMap<>();
streamDataWrapper.put("type", "workflow_stream");
streamDataWrapper.put("data", fullStreamData.toString());
streamDataWrapper.put("timestamp", System.currentTimeMillis());
apiCall.setResponseBody(JSON.toJSONString(streamDataWrapper));
cozeApiCallService.updateById(apiCall);
} catch (Exception e) {
log.error("保存工作流响应数据失败: {}", e.getMessage(), e);