Compare commits

..

5 Commits

Author SHA1 Message Date
caojianbin 32ce96ccf9 1.对外接口开发认证开发 2 years ago
caojianbin 8a35947f90 网关开发 2 years ago
caojianbin 2599036dba 修改缓存2 2 years ago
caojianbin a71770d8c5 修改缓存 2 years ago
caojianbin 1a30b7c0da 下发APP接口开发 2 years ago
  1. 5
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/SecurityConstants.java
  2. 9
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/context/SecurityContextHolder.java
  3. 25
      ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java
  4. 2
      ruoyi-common/ruoyi-common-swagger/pom.xml

5
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/SecurityConstants.java

@ -38,6 +38,11 @@ public class SecurityConstants @@ -38,6 +38,11 @@ public class SecurityConstants
public static final String USER_KEY = "user_key";
/**
* 厂商id
*/
public static final String FIRM_ID = "firm_id";
/**
* 登录用户
*/
public static final String LOGIN_USER = "login_user";

9
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/context/SecurityContextHolder.java

@ -77,6 +77,15 @@ public class SecurityContextHolder @@ -77,6 +77,15 @@ public class SecurityContextHolder
set(SecurityConstants.DETAILS_USERNAME, username);
}
public static void setUserAgent(String userId,String useragent)
{
set("userId", useragent);
}
public static String getUserAgent(String userId)
{
return get(userId);
}
public static String getUserKey()
{
return get(SecurityConstants.USER_KEY);

25
ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java

@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean; @@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
@ -28,16 +29,36 @@ public class RedisConfig extends CachingConfigurerSupport @@ -28,16 +29,36 @@ public class RedisConfig extends CachingConfigurerSupport
template.setConnectionFactory(connectionFactory);
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
//JdkSerializationRedisSerializer serializer =new JdkSerializationRedisSerializer();
// 使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(serializer);
// Hash的key也采用StringRedisSerializer的序列化方式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(serializer);
template.setHashValueSerializer((new StringRedisSerializer()));
template.afterPropertiesSet();
return template;
}
// @Bean
// @SuppressWarnings(value = { "unchecked", "rawtypes" })
// public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
// {
// RedisTemplate<Object, Object> template = new RedisTemplate<>();
// template.setConnectionFactory(connectionFactory);
//
// FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
//
// // 使用StringRedisSerializer来序列化和反序列化redis的key值
// template.setKeySerializer(new StringRedisSerializer());
// template.setValueSerializer(serializer);
//
// // Hash的key也采用StringRedisSerializer的序列化方式
// template.setHashKeySerializer(new StringRedisSerializer());
// template.setHashValueSerializer(serializer);
//
// template.afterPropertiesSet();
// return template;
// }
}

2
ruoyi-common/ruoyi-common-swagger/pom.xml

@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
ruoyi-common-swagger系统接口
</description>
<dependencies>
<dependencies>
<!-- SpringBoot Web -->
<dependency>

Loading…
Cancel
Save