mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
🐛 Fixing a bug. 序列化问题 修正
This commit is contained in:
1 parent
3832226a8c
commit
0da6ef25e2
7 files changed
+29
-24
No files matched your search
+3
@@ -33,6 +33,7 @@ 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.serializer.StringRedisSerializer;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
@@ -125,6 +126,8 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
||||
}
|
||||
|
||||
String key = CommonConstants.DEFAULT_CODE_KEY + randomStr;
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
|
||||
if (!redisTemplate.hasKey(key)) {
|
||||
throw new ValidateCodeException("验证码不合法");
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -60,6 +61,7 @@ public class ImageCodeHandler implements HandlerFunction<ServerResponse> {
|
||||
|
||||
//保存验证码信息
|
||||
String randomStr = serverRequest.queryParam("randomStr").get();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.opsForValue().set(CommonConstants.DEFAULT_CODE_KEY + randomStr, text
|
||||
, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
Reference in new issue
Block a user