mirror of
https://github.com/yzcheng90/X-SpringBoot
synced 2025-11-09 00:59:27 +08:00
修改redis
This commit is contained in:
@@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
public class SecurityConfigurer {
|
public class SecurityConfigurer {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<Object, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AuthIgnoreConfig authIgnoreConfig;
|
private AuthIgnoreConfig authIgnoreConfig;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<Object,Object> redisTemplate;
|
private RedisTemplate<String,Object> redisTemplate;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.Date;
|
|||||||
public class CustomLogoutSuccessHandler implements LogoutSuccessHandler {
|
public class CustomLogoutSuccessHandler implements LogoutSuccessHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<Object,Object> redisTemplate;
|
private RedisTemplate<String,Object> redisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class RedisLock {
|
public class RedisLock {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<Object, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
/*** 释放锁脚本,原子操作,lua脚本*/
|
/*** 释放锁脚本,原子操作,lua脚本*/
|
||||||
private static final String UNLOCK_LUA;
|
private static final String UNLOCK_LUA;
|
||||||
/*** 默认过期时间(30ms)*/
|
/*** 默认过期时间(30ms)*/
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package com.suke.czx.config;
|
package com.suke.czx.config;
|
||||||
|
|
||||||
|
|
||||||
|
import com.suke.czx.common.utils.Constant;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.data.redis.core.*;
|
import org.springframework.data.redis.core.*;
|
||||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
import com.suke.czx.common.utils.Constant;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
@@ -22,7 +21,6 @@ import java.time.Duration;
|
|||||||
public class RedisConfig {
|
public class RedisConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Primary
|
|
||||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||||
redisTemplate.setKeySerializer(RedisSerializer.string());
|
redisTemplate.setKeySerializer(RedisSerializer.string());
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ import java.io.IOException;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class AuthenticationTokenFilter extends OncePerRequestFilter {
|
public class AuthenticationTokenFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
private final RedisTemplate<Object,Object> redisTemplate;
|
private final RedisTemplate<String,Object> redisTemplate;
|
||||||
private final AuthIgnoreConfig authIgnoreConfig;
|
private final AuthIgnoreConfig authIgnoreConfig;
|
||||||
|
|
||||||
public AuthenticationTokenFilter(AuthIgnoreConfig authIgnoreConfig,RedisTemplate<Object,Object> template) {
|
public AuthenticationTokenFilter(AuthIgnoreConfig authIgnoreConfig,RedisTemplate<String,Object> template) {
|
||||||
this.redisTemplate = template;
|
this.redisTemplate = template;
|
||||||
this.authIgnoreConfig = authIgnoreConfig;
|
this.authIgnoreConfig = authIgnoreConfig;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ import org.springframework.web.filter.OncePerRequestFilter;
|
|||||||
public class ValidateCodeFilter extends OncePerRequestFilter {
|
public class ValidateCodeFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||||
private final RedisTemplate<Object,Object> redisTemplate;
|
private final RedisTemplate<String,Object> redisTemplate;
|
||||||
private final AuthenticationFailureHandler authenticationFailureHandler;
|
private final AuthenticationFailureHandler authenticationFailureHandler;
|
||||||
|
|
||||||
public ValidateCodeFilter(RedisTemplate<Object,Object> redisTemplate, AuthenticationFailureHandler authenticationFailureHandler){
|
public ValidateCodeFilter(RedisTemplate<String,Object> redisTemplate, AuthenticationFailureHandler authenticationFailureHandler){
|
||||||
this.redisTemplate = redisTemplate;
|
this.redisTemplate = redisTemplate;
|
||||||
this.authenticationFailureHandler = authenticationFailureHandler;
|
this.authenticationFailureHandler = authenticationFailureHandler;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class SysLoginController extends AbstractController {
|
public class SysLoginController extends AbstractController {
|
||||||
|
|
||||||
private final Producer producer;
|
private final Producer producer;
|
||||||
private final RedisTemplate<Object,Object> redisTemplate;
|
private final RedisTemplate<String,Object> redisTemplate;
|
||||||
|
|
||||||
@AuthIgnore
|
@AuthIgnore
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||||
|
|||||||
Reference in New Issue
Block a user