Skip to content

Commit

Permalink
🐛 fix: 修复了 delete 方法中的逻辑错误
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed May 27, 2024
1 parent 7d81311 commit 6a12eae
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ public Mono<Menu> save(Menu menu) {

@Transactional(rollbackFor = Exception.class)
public Mono<Void> delete(MenuRequest request) {
List<String> rules = new ArrayList<>(Collections.singletonList(request.getAuthority()));
if (!ObjectUtils.isEmpty(request.getPermissions())) {
rules.addAll(request.getPermissions().stream().map(Menu.Permission::getAuthority).toList());
if (ObjectUtils.nullSafeEquals(request.getTenantCode(), "0")) {
List<String> rules = new ArrayList<>(Collections.singletonList(request.getAuthority()));
if (!ObjectUtils.isEmpty(request.getPermissions())) {
rules.addAll(request.getPermissions().stream().map(Menu.Permission::getAuthority).toList());
}
var deleteAuthorityMono = Flux.concatDelayError(this.groupAuthoritiesRepository.deleteByAuthorityIn(rules),
this.userAuthoritiesRepository.deleteByAuthorityIn(rules));
var deleteNextMono = Flux.concatDelayError(this.menusRepository.delete(request.toMenu()), deleteAuthorityMono);
return deleteNextMono.then().doAfterTerminate(() -> this.cache.clear());
} else {
return this.menusRepository.delete(request.toMenu()).doAfterTerminate(() -> this.cache.clear());
}
var deleteAuthorityMono = Flux.concatDelayError(this.groupAuthoritiesRepository.deleteByAuthorityIn(rules),
this.userAuthoritiesRepository.deleteByAuthorityIn(rules));
var deleteNextMono = Flux.concatDelayError(this.menusRepository.delete(request.toMenu()), deleteAuthorityMono);
return deleteNextMono.then().doAfterTerminate(() -> this.cache.clear());
}
}

0 comments on commit 6a12eae

Please sign in to comment.