当前一个请求结果是后一个请求的参数时,在Handler
是进行逻辑处理:
- Service层
public Flux<Integer> responseDepartmentListByHospitalId(Integer id){
return this.middleOfDepartmentRepository.findById(id);
}
public Flux<Departments> findDepartmentByHospitalId(Collection<Integer> lists){
return this.departmentsRepository.findByIdIn(lists);
}
handler处理方法
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));
}
来自为知笔记(Wiz)
标签:return,请求,list,webflux,id,参数,Integer,public From: https://www.cnblogs.com/baiyifengyun/p/16864875.html