Skip to content

Commit

Permalink
♻️ refactor(menus): 优化了删除菜单的逻辑处理方式
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed Jun 5, 2024
1 parent 052d87a commit 2c79cba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@
public interface MenusRepository extends R2dbcRepository<Menu, Integer> {

/**
* findByCode
* findByCode
*
* @param code entity code
* @return entity
*/
Mono<Menu> findByCode(String code);

/**
* deleteByAuthority
*
* @param authority entity authority
* @return entity
*/
Mono<Long> deleteByAuthority(String authority);
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public Mono<Void> delete(MenuRequest request) {
}
var deleteAuthorityMono = Flux.concatDelayError(this.groupAuthoritiesRepository.deleteByAuthorityIn(rules),
this.userAuthoritiesRepository.deleteByAuthorityIn(rules));
var deleteNextMono = Flux.concatDelayError(this.menusRepository.delete(request.toMenu()), deleteAuthorityMono);
var deleteNextMono = Flux.concatDelayError(this.menusRepository.deleteByAuthority(
request.getAuthority()), deleteAuthorityMono);
return deleteNextMono.then().doAfterTerminate(() -> this.cache.clear());
} else {
return this.menusRepository.delete(request.toMenu()).doAfterTerminate(() -> this.cache.clear());
Expand Down

0 comments on commit 2c79cba

Please sign in to comment.