Project reactor 我有两个不同的Api响应,需要从这两个Api创建新对象';s响应和需要返回通量
我有两个不同的API,分别是NonBillableEmployee和BillableEmployee。我想将非计费api响应和计费api响应公共值添加到新对象,即Employee对象 (常用值是ename、etype、eid),我需要返回Flux =============DTO=======Project reactor 我有两个不同的Api响应,需要从这两个Api创建新对象';s响应和需要返回通量,project-reactor,Project Reactor,我有两个不同的API,分别是NonBillableEmployee和BillableEmployee。我想将非计费api响应和计费api响应公共值添加到新对象,即Employee对象 (常用值是ename、etype、eid),我需要返回Flux =============DTO======= public class NonBillableEmployee { List<NonBillableEmployeeDto> list; //setter and get
public class NonBillableEmployee {
List<NonBillableEmployeeDto> list;
//setter and getter
}
public class NonBillableEmployeeDto {
String name;
Long eid;
String eType;
//setters and getters
}
public class BillableEmployee {
List<BillableEmployee> list;
}
public class BillableEmployeeDto {
String name;
Long eid;
String eType;
}
公共类不计费员工{
名单;
//接二连三
}
公共类非付费雇员{
字符串名;
长开斋节;
字串;
//二传手和接球手
}
公共类可付费员工{
名单;
}
公共类BillableEmployeeDto{
字符串名;
长开斋节;
字串;
}
=====================================逻辑=================
Flux<BillableEmployee> billable= webClient1.get().retrieve().bodyToFlux(BillableEmployee.class);
Flux<NonBillableEmployee> nonbillable= webClient2.get().retrieve()
.bodyToFlux(NonBillableEmployee.class);
Flux<Employee> f = Flux.zip(billable, nonbillable).flatMap(tuples->{
List<BillableEmployee> l1 = tuples.getT1().list.parallelStream().collect(Collectors.toList());
List<NonBillableEmployee> l2 = tuples.getT2().list.parallelStream().collect(Collectors.toList());
//here how can we do it
return Flux.just(new Employee());
})
Flux billable=webClient1.get().retrieve().bodyToFlux(BillableEmployee.class);
Flux nonbilable=webClient2.get().retrieve()
.bodyToFlux(非付费员工类别);
Flux f=Flux.zip(可计费、不可计费).flatMap(元组->{
List l1=tuples.getT1().List.parallelStream().collect(Collectors.toList());
List l2=tuples.getT2().List.parallelStream().collect(Collectors.toList());
//这里我们怎么做
return Flux.just(新员工());
})
我将从每个API响应中获得1000条以上的记录。如何做得更好?我将从每个API响应中获得1000条以上的记录。怎样才能做得更好