♻️ Refactoring code. 统一 Redis 序列化规则

This commit is contained in:
lbw committed 2023-12-04 13:37:18 +08:00
1 parent 9b3280ff5d
commit 8370878ace
9 files changed
+22 -22

No files matched your search

@@ -39,7 +39,7 @@ import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFac
import org.springframework.cloud.gateway.filter.factory.rewrite.CachedBodyOutputMessage;
import org.springframework.cloud.gateway.support.BodyInserterContext;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.codec.HttpMessageReader;
@@ -79,7 +79,7 @@ public class PasswordDecoderFilter extends AbstractGatewayFilterFactory {
private static final String KEY_ALGORITHM = "AES";
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
private final GatewayConfigProperties gatewayConfig;
@@ -143,14 +143,14 @@ public class PasswordDecoderFilter extends AbstractGatewayFilterFactory {
String key = String.format("%s:%s:%s", StrUtil.isBlank(tenantId) ? CommonConstants.TENANT_ID_1 : tenantId,
CacheConstants.CLIENT_FLAG, clientId);
Object val = redisTemplate.opsForValue().get(key);
String val = redisTemplate.opsForValue().get(key);
// 当配置不存在时,默认需要解密
if (val == null) {
return true;
}
JSONObject information = JSONUtil.parseObj(val.toString());
JSONObject information = JSONUtil.parseObj(val);
if (StrUtil.equals(EncFlagTypeEnum.NO.getType(), information.getStr(CommonConstants.ENC_FLAG))) {
return false;
}
@@ -37,7 +37,7 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -56,7 +56,7 @@ import reactor.core.publisher.Mono;
@SuppressWarnings("all")
public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
private final ObjectMapper objectMapper;
@@ -22,7 +22,7 @@ import io.springboot.captcha.ArithmeticCaptcha;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
@@ -49,7 +49,7 @@ public class ImageCodeMathHandler implements HandlerFunction<ServerResponse> {
private static final Integer DEFAULT_IMAGE_HEIGHT = 40;
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {