是否可以将CompletableFuture<CompletableFuture<Result>>
返回到Play框架?
以下是我的行动代码:
@BodyParser.Of(BodyParser.Json.class)
public CompletableFuture<CompletableFuture<Result>> addPageGroupMedia(){
JsonNode payloadJson = request().body().asJson();
PageGroupPayload payload = Json.fromJson(payloadJson, PageGroupPayload.class);
logger.debug("PageGroupMediaPayload :: " + payload);
Response res = new Response();
CompletableFuture<CompletableFuture<Boolean>> cf = mediaLibraryService.addPageGroupMedia(payload);
return cf.thenApply(data -> data.handle((d, e) -> {
if (e != null) {
res.setStatus(ERROR);
logger.error("Failed to add page group media - : {}", payload, e);
} else {
res.setStatus(SUCCESS);
res.setData(data);
}
logger.debug("res :: " + res);
return ok(Json.toJson(res));
}));
}
执行此操作时出现以下错误:
Cannot use a method returning java.util.concurrent.CompletableFuture[java.util.concurrent.CompletableFuture[play.mvc.Result]] as a Handler for requests