zhou-hao 5 年 前
コミット
1411df7bf8
15 ファイル変更365 行追加29 行削除
  1. 7 0
      hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/EnableCacheReactiveCrudService.java
  2. 0 1
      hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/GenericReactiveCacheSupportCrudService.java
  3. 5 0
      hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/ReactiveCache.java
  4. 17 1
      hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/CaffeineReactiveCache.java
  5. 16 0
      hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/GuavaReactiveCache.java
  6. 30 2
      hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/RedisReactiveCache.java
  7. 11 0
      hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/UnSupportedReactiveCache.java
  8. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/AuthorizationSettingEntity.java
  9. 21 3
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/event/ClearUserAuthorizationCacheEvent.java
  10. 10 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/configuration/AuthorizationServiceAutoConfiguration.java
  11. 115 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultAuthorizationSettingService.java
  12. 95 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultDimensionUserService.java
  13. 24 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveAuthenticationManager.java
  14. 7 7
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxAuthorizationSettingController.java
  15. 6 14
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionUserController.java

+ 7 - 0
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/EnableCacheReactiveCrudService.java

@@ -1,5 +1,6 @@
 package org.hswebframework.web.crud.service;
 
+import org.hswebframework.ezorm.rdb.mapping.ReactiveDelete;
 import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
 import org.hswebframework.ezorm.rdb.mapping.defaults.SaveResult;
 import org.hswebframework.web.cache.ReactiveCache;
@@ -58,4 +59,10 @@ public interface EnableCacheReactiveCrudService<E, K> extends ReactiveCrudServic
         return ReactiveCrudService.super.createUpdate()
                 .onExecute(s -> s.doFinally((__) -> getCache().clear().subscribe()));
     }
+
+    @Override
+    default ReactiveDelete createDelete() {
+        return ReactiveCrudService.super.createDelete()
+                .onExecute(s -> s.doFinally((__) -> getCache().clear().subscribe()));
+    }
 }

+ 0 - 1
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/GenericReactiveCacheSupportCrudService.java

@@ -22,7 +22,6 @@ public abstract class GenericReactiveCacheSupportCrudService<E, K> implements En
 
     protected ReactiveCache<E> cache;
 
-
     @Override
     public ReactiveCache<E> getCache() {
         if (cache != null) {

+ 5 - 0
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/ReactiveCache.java

@@ -6,6 +6,7 @@ import reactor.cache.CacheMono;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.util.Collection;
 import java.util.function.Function;
 
 public interface ReactiveCache<E> {
@@ -18,6 +19,10 @@ public interface ReactiveCache<E> {
 
     Mono<Void> evict(Object key);
 
+    Flux<E> getAll(Object... keys);
+
+    Mono<Void> evictAll(Iterable<?> key);
+
     Mono<Void> clear();
 
     default CacheFlux.FluxCacheBuilderMapMiss<E> flux(Object key) {

+ 17 - 1
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/CaffeineReactiveCache.java

@@ -7,6 +7,9 @@ import org.reactivestreams.Publisher;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.util.Arrays;
+import java.util.Collection;
+
 @SuppressWarnings("all")
 @AllArgsConstructor
 public class CaffeineReactiveCache<E> implements ReactiveCache<E> {
@@ -15,7 +18,7 @@ public class CaffeineReactiveCache<E> implements ReactiveCache<E> {
 
     @Override
     public Flux<E> getFlux(Object key) {
-        return (Flux)Flux.defer(() -> {
+        return (Flux) Flux.defer(() -> {
             Object v = cache.getIfPresent(key);
             if (v == null) {
                 return Flux.empty();
@@ -55,6 +58,19 @@ public class CaffeineReactiveCache<E> implements ReactiveCache<E> {
         });
     }
 
+    @Override
+    public Mono<Void> evictAll(Iterable<?> key) {
+        return Mono.fromRunnable(() -> cache.invalidateAll(key));
+    }
+
+    @Override
+    public Flux<E> getAll(Object... keys) {
+        return Flux.<E>defer(() -> {
+            return Flux.fromIterable(cache.getAllPresent(Arrays.asList(keys)).values())
+                    .map(e -> (E) e);
+        });
+    }
+
     @Override
     public Mono<Void> evict(Object key) {
         return Mono.fromRunnable(() -> cache.invalidate(key));

+ 16 - 0
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/GuavaReactiveCache.java

@@ -7,6 +7,9 @@ import org.reactivestreams.Publisher;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.util.Arrays;
+import java.util.Collection;
+
 @SuppressWarnings("all")
 @AllArgsConstructor
 public class GuavaReactiveCache<E> implements ReactiveCache<E> {
@@ -55,10 +58,23 @@ public class GuavaReactiveCache<E> implements ReactiveCache<E> {
         });
     }
 
+    @Override
+    public Mono<Void> evictAll(Iterable<?> key) {
+        return Mono.fromRunnable(() -> cache.invalidateAll(key));
+    }
+
     @Override
     public Mono<Void> evict(Object key) {
         return Mono.fromRunnable(() -> cache.invalidate(key));
     }
+    @Override
+    public Flux<E> getAll(Object... keys) {
+        return Flux.<E>defer(() -> {
+            return Flux.fromIterable(cache.getAllPresent(Arrays.asList(keys)).values())
+                    .map(e -> (E) e);
+        });
+    }
+
 
     @Override
     public Mono<Void> clear() {

+ 30 - 2
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/RedisReactiveCache.java

@@ -7,8 +7,11 @@ import org.springframework.data.redis.core.ReactiveRedisOperations;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.function.Function;
+import java.util.stream.StreamSupport;
 
 @SuppressWarnings("all")
 public class RedisReactiveCache<E> implements ReactiveCache<E> {
@@ -73,7 +76,7 @@ public class RedisReactiveCache<E> implements ReactiveCache<E> {
                                 .then(localCache.put(key, data))
                                 .then(operations.convertAndSend(topicName, key));
 
-                    }) .then();
+                    }).then();
         }
         if (data instanceof Flux) {
             return ((Flux) data)
@@ -89,13 +92,38 @@ public class RedisReactiveCache<E> implements ReactiveCache<E> {
         return Mono.error(new UnsupportedOperationException("unsupport publisher:" + data));
     }
 
+    @Override
+    public Mono<Void> evictAll(Iterable<?> key) {
+        return operations.opsForHash()
+                .remove(redisKey, StreamSupport.stream(key.spliterator(), false).toArray())
+                .then(localCache.evictAll(key))
+                .flatMap(nil -> Flux.fromIterable(key).flatMap(k -> operations.convertAndSend(topicName, key)))
+                .then();
+    }
+
+    @Override
+    public Flux<E> getAll(Object... keys) {
+        if (keys.length == 0) {
+            return operations
+                    .opsForHash()
+                    .values(redisKey)
+                    .map(r -> (E) r);
+        }
+        return operations.opsForHash()
+                .multiGet(redisKey, Arrays.asList(keys))
+                .flatMapIterable(Function.identity())
+                .map(r -> (E) r);
+    }
+
+
     @Override
     public Mono<Void> evict(Object key) {
         return operations
                 .opsForHash()
                 .remove(redisKey, key)
                 .then(localCache.evict(key))
-                .then(operations.convertAndSend(topicName, key));
+                .then(operations.convertAndSend(topicName, key))
+                .then();
     }
 
     @Override

+ 11 - 0
hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/UnSupportedReactiveCache.java

@@ -9,6 +9,7 @@ import reactor.cache.CacheMono;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
+import java.util.Collection;
 import java.util.function.Supplier;
 
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
@@ -40,6 +41,16 @@ public class UnSupportedReactiveCache<E> implements ReactiveCache<E> {
         return Mono.empty();
     }
 
+    @Override
+    public Mono<Void> evictAll(Iterable<?> key) {
+        return Mono.empty();
+    }
+
+    @Override
+    public Flux<E> getAll(Object... keys) {
+        return Flux.empty();
+    }
+
     @Override
     public Mono<Void> clear() {
         return Mono.empty();

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/AuthorizationSettingEntity.java

@@ -17,7 +17,7 @@ import java.util.List;
 import java.util.Set;
 
 @Table(name = "s_autz_setting_info", indexes = {
-        @Index(name = "idx_sasi_dss", columnList = "dimension,setting_target,state desc")
+        @Index(name = "idx_sasi_dss", columnList = "dimension_type,dimension_target,state desc")
 })
 @Getter
 @Setter

+ 21 - 3
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/event/ClearUserAuthorizationCacheEvent.java

@@ -1,17 +1,35 @@
 package org.hswebframework.web.system.authorization.api.event;
 
-import lombok.AllArgsConstructor;
 import lombok.Getter;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * @author zhouhao
  * @see org.springframework.context.event.EventListener
  * @since 3.0.0-RC
  */
-@AllArgsConstructor
 @Getter
 public class ClearUserAuthorizationCacheEvent {
-    private String userId;
+    private Set<String> userId;
 
     private boolean all;
+
+    public static ClearUserAuthorizationCacheEvent of(Collection<String> collection) {
+        ClearUserAuthorizationCacheEvent event = new ClearUserAuthorizationCacheEvent();
+        if (collection == null || collection.isEmpty()) {
+            event.all = true;
+        } else {
+            event.userId = new HashSet<>(collection);
+        }
+        return event;
+    }
+
+    public static ClearUserAuthorizationCacheEvent of(String... userId) {
+
+        return of(userId == null ? null : Arrays.asList(userId));
+    }
 }

+ 10 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/configuration/AuthorizationServiceAutoConfiguration.java

@@ -52,6 +52,16 @@ public class AuthorizationServiceAutoConfiguration {
         public UserDimensionProvider userPermissionDimensionProvider() {
             return new UserDimensionProvider();
         }
+
+        @Bean
+        public DefaultDimensionUserService defaultDimensionUserService(){
+            return new DefaultDimensionUserService();
+        }
+
+        @Bean
+        public DefaultAuthorizationSettingService defaultAuthorizationSettingService(){
+            return new DefaultAuthorizationSettingService();
+        }
     }
 
 

+ 115 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultAuthorizationSettingService.java

@@ -0,0 +1,115 @@
+package org.hswebframework.web.system.authorization.defaults.service;
+
+import org.hswebframework.ezorm.rdb.mapping.ReactiveDelete;
+import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
+import org.hswebframework.ezorm.rdb.mapping.defaults.SaveResult;
+import org.hswebframework.web.authorization.DimensionProvider;
+import org.hswebframework.web.authorization.DimensionType;
+import org.hswebframework.web.crud.service.GenericReactiveCrudService;
+import org.hswebframework.web.system.authorization.api.entity.AuthorizationSettingEntity;
+import org.hswebframework.web.system.authorization.api.event.ClearUserAuthorizationCacheEvent;
+import org.reactivestreams.Publisher;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+import reactor.util.function.Tuple2;
+import reactor.util.function.Tuples;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class DefaultAuthorizationSettingService extends GenericReactiveCrudService<AuthorizationSettingEntity, String> {
+
+    @Autowired
+    private ApplicationEventPublisher eventPublisher;
+
+    @Autowired
+    private List<DimensionProvider> providers;
+
+
+    @Override
+    public Mono<SaveResult> save(Publisher<AuthorizationSettingEntity> entityPublisher) {
+        return Flux.from(entityPublisher)
+                .collectList()
+                .flatMap(autz -> super.save(Flux.fromIterable(autz)).doOnSuccess(r -> clearUserAuthCache(autz)));
+    }
+
+    @Override
+    public Mono<Integer> updateById(String id, Mono<AuthorizationSettingEntity> entityPublisher) {
+        return entityPublisher
+                .flatMap(autz -> super.updateById(id, Mono.just(autz))
+                        .doOnSuccess((r) -> clearUserAuthCache(Collections.singletonList(autz))));
+    }
+
+    @Override
+    public Mono<Integer> deleteById(Publisher<String> idPublisher) {
+        return Flux.from(idPublisher)
+                .collectList()
+                .flatMap(list -> super.deleteById(Flux.fromIterable(list))
+                        .flatMap(r -> findById(Flux.fromIterable(list))
+                                .collectList()
+                                .doOnSuccess(this::clearUserAuthCache)
+                                .thenReturn(r)));
+    }
+
+    @Override
+    public Mono<Integer> insert(Publisher<AuthorizationSettingEntity> entityPublisher) {
+
+        return Flux.from(entityPublisher)
+                .collectList()
+                .flatMap(list -> super.insert(Flux.fromIterable(list))
+                        .doOnSuccess(i -> clearUserAuthCache(list)));
+    }
+
+    @Override
+    public Mono<Integer> insertBatch(Publisher<? extends Collection<AuthorizationSettingEntity>> entityPublisher) {
+        return Flux.from(entityPublisher)
+                .collectList()
+                .flatMap(list -> super.insertBatch(Flux.fromIterable(list))
+                        .doOnSuccess(i -> clearUserAuthCache(list.stream().flatMap(Collection::stream).collect(Collectors.toList()))));
+    }
+
+    @Override
+    public ReactiveUpdate<AuthorizationSettingEntity> createUpdate() {
+        ReactiveUpdate<AuthorizationSettingEntity> update = super.createUpdate();
+
+
+        return update.onExecute(r -> r.doOnSuccess(i -> {
+            createQuery()
+                    .setParam(update.toQueryParam())
+                    .fetch()
+                    .collectList()
+                    .subscribe(this::clearUserAuthCache);
+        }));
+    }
+
+    @Override
+    public ReactiveDelete createDelete() {
+        ReactiveDelete delete = super.createDelete();
+        return delete.onExecute(r -> r.doOnSuccess(i -> {
+            createQuery()
+                    .setParam(delete.toQueryParam())
+                    .fetch()
+                    .collectList()
+                    .subscribe(this::clearUserAuthCache);
+        }));
+    }
+
+    protected void clearUserAuthCache(List<AuthorizationSettingEntity> settings) {
+        Flux.fromIterable(providers)
+                .flatMap(provider ->
+                        //按维度类型进行映射
+                        provider.getAllType()
+                                .map(DimensionType::getId)
+                                .map(t -> Tuples.of(t, provider)))
+                .collect(Collectors.toMap(Tuple2::getT1, Tuple2::getT2))
+                .flatMapMany(typeProviderMapping -> Flux
+                        .fromIterable(settings)//根据维度获取所有userId
+                        .flatMap(setting -> Mono.justOrEmpty(typeProviderMapping.get(setting.getDimensionType()))
+                                .flatMapMany(provider -> provider.getUserIdByDimensionId(setting.getDimensionTarget()))))
+                .collectList()
+                .map(ClearUserAuthorizationCacheEvent::of)
+                .subscribe(eventPublisher::publishEvent);
+    }
+}

+ 95 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultDimensionUserService.java

@@ -0,0 +1,95 @@
+package org.hswebframework.web.system.authorization.defaults.service;
+
+import org.hswebframework.ezorm.rdb.mapping.ReactiveDelete;
+import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
+import org.hswebframework.ezorm.rdb.mapping.defaults.SaveResult;
+import org.hswebframework.web.crud.service.GenericReactiveCrudService;
+import org.hswebframework.web.system.authorization.api.entity.DimensionUserEntity;
+import org.hswebframework.web.system.authorization.api.event.ClearUserAuthorizationCacheEvent;
+import org.reactivestreams.Publisher;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+public class DefaultDimensionUserService extends GenericReactiveCrudService<DimensionUserEntity, String> {
+
+    @Autowired
+    private ApplicationEventPublisher eventPublisher;
+
+    @Override
+    public Mono<SaveResult> save(Publisher<DimensionUserEntity> entityPublisher) {
+        return Flux.from(entityPublisher)
+                .doOnNext(entity -> eventPublisher.publishEvent(ClearUserAuthorizationCacheEvent.of(entity.getUserId())))
+                .as(super::save);
+    }
+
+    @Override
+    public Mono<Integer> updateById(String id, Mono<DimensionUserEntity> entityPublisher) {
+        return entityPublisher
+                .doOnNext(entity -> eventPublisher.publishEvent(ClearUserAuthorizationCacheEvent.of(entity.getUserId())))
+                .as(e -> super.updateById(id, e));
+    }
+
+    @Override
+    public Mono<Integer> insert(Publisher<DimensionUserEntity> entityPublisher) {
+        return Flux.from(entityPublisher)
+                .doOnNext(entity -> eventPublisher.publishEvent(ClearUserAuthorizationCacheEvent.of(entity.getUserId())))
+                .as(super::insert);
+    }
+
+    @Override
+    public Mono<Integer> insertBatch(Publisher<? extends Collection<DimensionUserEntity>> entityPublisher) {
+        return Flux.from(entityPublisher)
+                .doOnNext(entity -> eventPublisher.publishEvent(ClearUserAuthorizationCacheEvent.of(entity
+                        .stream()
+                        .map(DimensionUserEntity::getUserId)
+                        .collect(Collectors.toSet()))))
+                .as(super::insertBatch);
+    }
+
+    @Override
+    public Mono<Integer> deleteById(Publisher<String> idPublisher) {
+        return findById(Flux.from(idPublisher))
+                .doOnNext(entity -> eventPublisher.publishEvent(ClearUserAuthorizationCacheEvent.of(entity.getUserId())))
+                .map(DimensionUserEntity::getId)
+                .as(super::deleteById);
+    }
+
+    @Override
+    @SuppressWarnings("all")
+    public ReactiveUpdate<DimensionUserEntity> createUpdate() {
+        ReactiveUpdate<DimensionUserEntity> update = super.createUpdate();
+        return update
+                .onExecute(r -> r.doOnSuccess(i -> {
+                    createQuery()
+                            .select(DimensionUserEntity::getUserId)
+                            .setParam(update.toQueryParam())
+                            .fetch()
+                            .map(DimensionUserEntity::getUserId)
+                            .collectList()
+                            .map(ClearUserAuthorizationCacheEvent::of)
+                            .subscribe();
+                }));
+    }
+
+    @Override
+    @SuppressWarnings("all")
+    public ReactiveDelete createDelete() {
+        ReactiveDelete delete = super.createDelete();
+        return delete
+                .onExecute(r -> r.doOnSuccess(i -> {
+                    createQuery()
+                            .select(DimensionUserEntity::getUserId)
+                            .setParam(delete.toQueryParam())
+                            .fetch()
+                            .map(DimensionUserEntity::getUserId)
+                            .collectList()
+                            .map(ClearUserAuthorizationCacheEvent::of)
+                            .subscribe();
+                }));
+    }
+}

+ 24 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/service/DefaultReactiveAuthenticationManager.java

@@ -1,16 +1,20 @@
 package org.hswebframework.web.system.authorization.defaults.service;
 
+import lombok.extern.slf4j.Slf4j;
 import org.hswebframework.web.authorization.*;
 import org.hswebframework.web.authorization.exception.AccessDenyException;
 import org.hswebframework.web.authorization.simple.PlainTextUsernamePasswordAuthenticationRequest;
 import org.hswebframework.web.cache.ReactiveCacheManager;
 import org.hswebframework.web.system.authorization.api.entity.UserEntity;
+import org.hswebframework.web.system.authorization.api.event.ClearUserAuthorizationCacheEvent;
 import org.hswebframework.web.system.authorization.api.service.reactive.ReactiveUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.CacheManager;
 import org.springframework.cache.support.SimpleValueWrapper;
+import org.springframework.context.event.EventListener;
 import reactor.core.publisher.Mono;
 
+@Slf4j
 public class DefaultReactiveAuthenticationManager implements ReactiveAuthenticationManagerProvider {
 
     @Autowired
@@ -22,6 +26,26 @@ public class DefaultReactiveAuthenticationManager implements ReactiveAuthenticat
     @Autowired(required = false)
     private ReactiveCacheManager cacheManager;
 
+
+    @EventListener
+    public void handleClearAuthCache(ClearUserAuthorizationCacheEvent event) {
+        if (cacheManager != null) {
+            if (event.isAll()) {
+                cacheManager.getCache("user-auth")
+                        .clear()
+                        .doOnSuccess(nil->log.info("clear all user authentication cache success"))
+                        .doOnError(err -> log.error(err.getMessage(), err))
+                        .subscribe();
+            } else {
+                cacheManager.getCache("user-auth")
+                        .evictAll(event.getUserId())
+                        .doOnError(err -> log.error(err.getMessage(), err))
+                        .doOnSuccess(__->log.info("clear user {} authentication cache success", event.getUserId()))
+                        .subscribe( );
+            }
+        }
+    }
+
     @Override
     public Mono<Authentication> authenticate(Mono<AuthenticationRequest> request) {
         return request

+ 7 - 7
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxAuthorizationSettingController.java

@@ -4,8 +4,11 @@ package org.hswebframework.web.system.authorization.defaults.webflux;
 import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository;
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.authorization.annotation.Resource;
+import org.hswebframework.web.crud.service.ReactiveCrudService;
 import org.hswebframework.web.crud.web.reactive.ReactiveCrudController;
+import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController;
 import org.hswebframework.web.system.authorization.api.entity.AuthorizationSettingEntity;
+import org.hswebframework.web.system.authorization.defaults.service.DefaultAuthorizationSettingService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -14,16 +17,13 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/autz-setting")
 @Authorize
 @Resource(id = "autz-setting",name = "权限分配",group = "system")
-public class WebFluxAuthorizationSettingController implements ReactiveCrudController<AuthorizationSettingEntity, String> {
+public class WebFluxAuthorizationSettingController implements ReactiveServiceCrudController<AuthorizationSettingEntity, String> {
 
     @Autowired
-    private ReactiveRepository<AuthorizationSettingEntity, String> reactiveRepository;
+    private DefaultAuthorizationSettingService settingService;
 
     @Override
-    public ReactiveRepository<AuthorizationSettingEntity, String> getRepository() {
-        return reactiveRepository;
+    public ReactiveCrudService<AuthorizationSettingEntity, String> getService() {
+        return settingService;
     }
-
-
-
 }

+ 6 - 14
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionUserController.java

@@ -1,34 +1,26 @@
 package org.hswebframework.web.system.authorization.defaults.webflux;
 
-import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository;
-import org.hswebframework.web.api.crud.entity.QueryParamEntity;
 import org.hswebframework.web.authorization.annotation.Authorize;
-import org.hswebframework.web.authorization.annotation.QueryAction;
 import org.hswebframework.web.authorization.annotation.Resource;
-import org.hswebframework.web.crud.web.reactive.ReactiveCrudController;
+import org.hswebframework.web.crud.service.ReactiveCrudService;
 import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController;
-import org.hswebframework.web.system.authorization.api.entity.DimensionEntity;
 import org.hswebframework.web.system.authorization.api.entity.DimensionUserEntity;
-import org.hswebframework.web.system.authorization.defaults.service.DefaultDimensionService;
+import org.hswebframework.web.system.authorization.defaults.service.DefaultDimensionUserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import reactor.core.publisher.Mono;
-
-import java.util.List;
 
 @RestController
 @RequestMapping("/dimension-user")
 @Authorize
 @Resource(id = "dimension",name = "权限维度管理",group = "system")
-public class WebFluxDimensionUserController implements ReactiveCrudController<DimensionUserEntity, String> {
+public class WebFluxDimensionUserController implements ReactiveServiceCrudController<DimensionUserEntity, String> {
 
     @Autowired
-    private ReactiveRepository<DimensionUserEntity, String> repository;
+    private DefaultDimensionUserService dimensionUserService;
 
     @Override
-    public ReactiveRepository<DimensionUserEntity, String> getRepository() {
-        return repository;
+    public ReactiveCrudService<DimensionUserEntity, String> getService() {
+        return dimensionUserService;
     }
 }