feat:同时支持同步和异步,以保证dbref暂时可用

This commit is contained in:
wangyu 2021-12-08 16:11:37 +08:00
parent 95a35c35b9
commit 75b089c8ad
6 changed files with 19 additions and 6 deletions

View File

@ -33,6 +33,11 @@
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId> <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.github.ulisesbocchio</groupId> <groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId> <artifactId>jasypt-spring-boot-starter</artifactId>

View File

@ -2,6 +2,7 @@ package com.flyfish.framework.annotations;
import com.flyfish.framework.repository.factory.DefaultReactiveRepositoryFactoryBean; import com.flyfish.framework.repository.factory.DefaultReactiveRepositoryFactoryBean;
import com.flyfish.framework.repository.impl.DefaultReactiveRepositoryImpl; import com.flyfish.framework.repository.impl.DefaultReactiveRepositoryImpl;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.data.mongodb.config.EnableReactiveMongoAuditing; import org.springframework.data.mongodb.config.EnableReactiveMongoAuditing;
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories; import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;

View File

@ -24,6 +24,7 @@ public class ReactiveAuthorizeAuditor implements ReactiveBeanAuditor<AuthorizedD
.map(user -> { .map(user -> {
data.setAuthorizeId(user.getAuthority()); data.setAuthorizeId(user.getAuthority());
return data; return data;
}); })
.defaultIfEmpty(data);
} }
} }

View File

@ -35,6 +35,7 @@ public class ReactiveOperationAuditor implements ReactiveBeanAuditor<AuditDomain
data.setModifierId(user.getId()); data.setModifierId(user.getId());
} }
return data; return data;
}); })
.defaultIfEmpty(data);
} }
} }

View File

@ -57,7 +57,8 @@ public class UserBeanAuditor implements ReactiveBeanAuditor<User>, ReactiveBeanP
@Override @Override
public Mono<User> post(User data) { public Mono<User> post(User data) {
// 更新缓存 // 更新缓存
return reactiveRedisOperations.set(UserCacheKeys.get(data.getUsername()), return userDetailsConverter.mapToUserDetails(data)
userDetailsConverter.mapToUserDetails(data)).then(Mono.just(data)); .flatMap(detail -> reactiveRedisOperations.set(UserCacheKeys.get(data.getUsername()), detail))
.thenReturn(data);
} }
} }

View File

@ -49,8 +49,12 @@ public class JwtSecurityContextRepository implements ServerSecurityContextReposi
*/ */
@Override @Override
public Mono<Void> save(ServerWebExchange webExchange, SecurityContext securityContext) { public Mono<Void> save(ServerWebExchange webExchange, SecurityContext securityContext) {
// 添加jwtToken if (null == securityContext) {
tokenProvider.addToken(webExchange, securityContext.getAuthentication()); return tokenProvider.removeToken(webExchange);
} else {
// 添加jwtToken
tokenProvider.addToken(webExchange, securityContext.getAuthentication());
}
return Mono.empty(); return Mono.empty();
} }
} }