当前一个请求结果是后一个请求的参数时,在Handler
是进行逻辑处理:
public Flux<Integer> responseDepartmentListByHospitalId(Integer id){
return this.middleOfDepartmentRepository.findById(id);
}
public Flux<Departments> findDepartmentByHospitalId(Collection<Integer> lists){
return this.departmentsRepository.findByIdIn(lists);
}
public Mono<ServerResponse> getDepartmentsByHospitalId(ServerRequest request){
Integer id = Integer.valueOf(request.pathVariable("id"));
return this.commonService.responseDepartmentListByHospitalId(id)
.collectList()
.flatMap(list -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON)
.body(commonService.findDepartmentByHospitalId(list), Departments.class));
}