♻️ 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

@@ -29,7 +29,7 @@ import com.pig4cloud.pigx.common.core.util.MsgUtils;
import com.pig4cloud.pigx.common.core.util.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
@@ -45,7 +45,7 @@ import java.util.concurrent.TimeUnit;
@AllArgsConstructor
public class AppMobileServiceImpl implements AppMobileService {
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
/**
* 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端
@@ -51,7 +51,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@@ -77,7 +77,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
private final AppUserRoleService appUserRoleService;
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
private final AppRoleService appRoleService;
@@ -30,11 +30,13 @@ import com.pig4cloud.pigx.common.data.resolver.ParamResolver;
import com.pig4cloud.pigx.common.log.event.SysLogEvent;
import com.pig4cloud.pigx.common.log.util.LogTypeEnum;
import com.pig4cloud.pigx.common.log.util.SysLogUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
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;
@@ -46,8 +48,6 @@ import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
@@ -62,7 +62,7 @@ public class PigxAuthenticationFailureEventHandler implements AuthenticationFail
private static final MappingJackson2HttpMessageConverter errorHttpResponseConverter = new MappingJackson2HttpMessageConverter();
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
private final ApplicationEventPublisher publisher;
@@ -32,7 +32,7 @@ import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.security.core.Authentication;
@@ -62,7 +62,7 @@ public class PigxAuthenticationSuccessEventHandler implements AuthenticationSucc
private static final HttpMessageConverter<OAuth2AccessTokenResponse> accessTokenHttpResponseConverter = new OAuth2AccessTokenResponseHttpMessageConverter();
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
private final ApplicationEventPublisher publisher;
@@ -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) {
@@ -12,7 +12,7 @@ import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.scheduling.annotation.Async;
@@ -37,7 +37,7 @@ public class ClientDetailsInitRunner implements InitializingBean {
private final SysTenantService tenantService;
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
/**
* WebServerInitializedEvent 使用 TransactionalEventListener 时启动时无法获取到事件
@@ -33,7 +33,7 @@ import com.pig4cloud.pigx.common.core.util.MsgUtils;
import com.pig4cloud.pigx.common.core.util.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -50,7 +50,7 @@ import java.util.concurrent.TimeUnit;
@AllArgsConstructor
public class MobileServiceImpl implements MobileService {
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate redisTemplate;
private final SysUserMapper userMapper;