Skip to content

Commit 99f554c

Browse files
committed
1 parent 1b7d4b9 commit 99f554c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

server/api-service/lowcoder-infra/src/main/java/org/lowcoder/infra/birelation/BiRelationServiceImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public Mono<BiRelation> addBiRelation(BiRelation biRelation) {
3636

3737
@Override
3838
public Mono<List<BiRelation>> batchAddBiRelation(Collection<BiRelation> biRelations) {
39-
return biRelationRepository.saveAll(biRelations)
39+
return Flux.fromIterable(biRelations)
40+
.flatMap(this::upsertAndReturn)
4041
.collectList();
4142
}
4243

@@ -232,4 +233,12 @@ public Mono<Boolean> removeBiRelationById(String id) {
232233
.thenReturn(true)
233234
.onErrorReturn(false);
234235
}
236+
237+
private Mono<BiRelation> upsertAndReturn(BiRelation biRelation) {
238+
Criteria criteria = Criteria.where("bizType").is(biRelation.getBizType())
239+
.and("sourceId").is(biRelation.getSourceId())
240+
.and("targetId").is(biRelation.getTargetId());
241+
return mongoUpsertHelper.upsertWithAuditingParams(biRelation, criteria)
242+
.onErrorResume(ex -> Mono.empty());
243+
}
235244
}

0 commit comments

Comments
 (0)