我试图以迭代方式检查另一项服务的条件后调用一项服务,如下所示:
if (productService.isProductNotExcluded(product)){
List<Properties> properties = propertiesService.getProductDetailProperties(product)
...
}
Run Code Online (Sandbox Code Playgroud)
但自从isProductExcluded
返回以来Mono<Boolean>
,我正在使用这种方法,这看起来很奇怪:
Flux<Properties> properties = productService.isProductNotExcluded(productId)
.filter(notExcluded -> notExcluded)
.map(ok-> propertiesService.getProductDetailProperties(product))
...
Run Code Online (Sandbox Code Playgroud)
处理这种情况的正确方法是什么?