@@ -137,7 +137,7 @@ private Client createClient() throws Exception {
137137 * 创建API信息
138138 */
139139 private Params createApiInfo (String WorkspaceId ) throws Exception {
140- Params params = new Params ()
140+ return new Params ()
141141 // 接口名称
142142 .setAction ("Retrieve" )
143143 // 接口版本
@@ -154,7 +154,6 @@ private Params createApiInfo(String WorkspaceId) throws Exception {
154154 .setReqBodyType ("json" )
155155 // 接口响应体内容格式
156156 .setBodyType ("json" );
157- return params ;
158157 }
159158
160159 /**
@@ -190,7 +189,7 @@ private Long safeCastToLong(Object obj) {
190189 * @param content the content
191190 * @return String the String
192191 */
193- public Result < List < NodeDto >> chatSearch (String content ) {
192+ public Result chatSearch (String content ) {
194193 try {
195194 Client client = createClient ();
196195 Params params = createApiInfo (WORK_SPACE_ID );
@@ -204,31 +203,31 @@ public Result<List<NodeDto>> chatSearch(String content) {
204203 OpenApiRequest request = new OpenApiRequest ()
205204 .setQuery (com .aliyun .openapiutil .Client .query (queries ));
206205
207- Map <String , Map < String , Object >> response = ( Map < String , Map < String , Object >>) client .callApi (params , request , runtime );
208- Map <String , Object > body = response .get ("body" );
206+ Map <String , ?> response = client .callApi (params , request , runtime );
207+ Map <String , Object > body = ( Map < String , Object >) response .get ("body" );
209208
210209 if (body == null ) {
211210 return Result .failed ("响应体为空" );
212211 }
213212
214- Long status = safeCastToLong (body .get ("Status" ));
215- if (status != 200 ) {
213+ long status = safeCastToLong (body .get ("Status" ));
214+ if (status != 200L ) {
216215 String message = safeCastToString (body .get ("Message" ));
217216 log .error ("搜索失败: status={}, message={}" , status , message );
218217 return Result .failed ("搜索失败: " + message );
219218 }
220219
221- Map < String , Object > data = safeCast (body .get ("Data" ), Map .class , new HashMap <>());
220+ Map data = safeCast (body .get ("Data" ), Map .class , new HashMap <>());
222221 if (data == null || data .isEmpty ()) {
223222 return Result .success (new ArrayList <>());
224223 }
225224
226- List < Map < String , Object >> nodes = safeCast (data .get ("Nodes" ), List .class , new ArrayList <>());
225+ List nodes = safeCast (data .get ("Nodes" ), List .class , new ArrayList <>());
227226 if (nodes .isEmpty ()) {
228227 return Result .success (new ArrayList <>());
229228 }
230229
231- List < NodeDto > nodeDtos = convertToNodeDtos (nodes );
230+ List nodeDtos = convertToNodeDtos (nodes );
232231 return Result .success (nodeDtos );
233232
234233 } catch (TeaException e ) {
@@ -262,7 +261,7 @@ private List<NodeDto> convertToNodeDtos(List<Map<String, Object>> nodes) {
262261 }
263262
264263 // 安全获取元数据
265- Map < String , Object > metadata = safeCast (node .get ("Metadata" ), Map .class , new HashMap <>());
264+ Map metadata = safeCast (node .get ("Metadata" ), Map .class , new HashMap <>());
266265 if (metadata != null ) {
267266 nodeDto .setDocName (safeCastToString (metadata .get ("doc_name" )));
268267 }
0 commit comments