首页 > 其他分享 >webflux 实现前一个请求是后一个请求的参数

webflux 实现前一个请求是后一个请求的参数

时间:2022-11-07 09:11:18浏览次数:103  
标签:return 请求 list webflux id 参数 Integer public

当前一个请求结果是后一个请求的参数时,在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

相关文章