| | |
| | | import org.springframework.core.ParameterizedTypeReference; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | | import org.springframework.http.*; |
| | | import org.springframework.web.reactive.function.client.ExchangeStrategies; |
| | | import org.springframework.web.reactive.function.client.WebClient; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | @ApiOperation(value = "获取任务结果") |
| | | @GetMapping("/tasks/{taskId}") |
| | | public Mono<TaskResultResponse> getTaskResult(@PathVariable String taskId) { |
| | | return webClient.get() |
| | | WebClient webClient2 = WebClient.builder() |
| | | .exchangeStrategies(ExchangeStrategies.builder() |
| | | .codecs(configurer -> configurer.defaultCodecs() |
| | | .maxInMemorySize(10 * 1024 * 1024)) // 10MB |
| | | .build()) |
| | | .build(); |
| | | return webClient2.get() |
| | | .uri(baseUrl + "/api/v1/tasks/" + taskId + "/result") |
| | | .accept(MediaType.APPLICATION_JSON) |
| | | .retrieve() |
| | |
| | | }) |
| | | .onErrorResume(e -> { |
| | | System.out.println("获取任务结果失败"); |
| | | log.error("获取任务结果失败: {}", e.getMessage(), e); |
| | | TaskResultResponse result = new TaskResultResponse(); |
| | | result.setDetail("获取任务结果失败: " + e.getMessage()); |
| | | return Mono.just(result); |