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>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<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.impl.DefaultReactiveRepositoryImpl;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AliasFor;
import org.springframework.data.mongodb.config.EnableReactiveMongoAuditing;
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;

View File

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

View File

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

View File

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

View File

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