正在显示
4 个修改的文件
包含
9 行增加
和
33 行删除
| @@ -2,6 +2,7 @@ package com.ruoyi.common.utils; | @@ -2,6 +2,7 @@ package com.ruoyi.common.utils; | ||
| 2 | 2 | ||
| 3 | import java.util.Collection; | 3 | import java.util.Collection; |
| 4 | import java.util.List; | 4 | import java.util.List; |
| 5 | +import com.alibaba.fastjson2.JSONArray; | ||
| 5 | import com.ruoyi.common.constant.Constants; | 6 | import com.ruoyi.common.constant.Constants; |
| 6 | import com.ruoyi.common.core.domain.entity.SysDictData; | 7 | import com.ruoyi.common.core.domain.entity.SysDictData; |
| 7 | import com.ruoyi.common.core.redis.RedisCache; | 8 | import com.ruoyi.common.core.redis.RedisCache; |
| @@ -38,10 +39,10 @@ public class DictUtils | @@ -38,10 +39,10 @@ public class DictUtils | ||
| 38 | */ | 39 | */ |
| 39 | public static List<SysDictData> getDictCache(String key) | 40 | public static List<SysDictData> getDictCache(String key) |
| 40 | { | 41 | { |
| 41 | - Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); | ||
| 42 | - if (StringUtils.isNotNull(cacheObj)) | 42 | + JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); |
| 43 | + if (StringUtils.isNotNull(arrayCache)) | ||
| 43 | { | 44 | { |
| 44 | - return StringUtils.cast(cacheObj); | 45 | + return arrayCache.toList(SysDictData.class); |
| 45 | } | 46 | } |
| 46 | return null; | 47 | return null; |
| 47 | } | 48 | } |
| @@ -83,7 +84,9 @@ public class DictUtils | @@ -83,7 +84,9 @@ public class DictUtils | ||
| 83 | StringBuilder propertyString = new StringBuilder(); | 84 | StringBuilder propertyString = new StringBuilder(); |
| 84 | List<SysDictData> datas = getDictCache(dictType); | 85 | List<SysDictData> datas = getDictCache(dictType); |
| 85 | 86 | ||
| 86 | - if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) | 87 | + if (StringUtils.isNotNull(datas)) |
| 88 | + { | ||
| 89 | + if (StringUtils.containsAny(separator, dictValue)) | ||
| 87 | { | 90 | { |
| 88 | for (SysDictData dict : datas) | 91 | for (SysDictData dict : datas) |
| 89 | { | 92 | { |
| @@ -107,6 +110,7 @@ public class DictUtils | @@ -107,6 +110,7 @@ public class DictUtils | ||
| 107 | } | 110 | } |
| 108 | } | 111 | } |
| 109 | } | 112 | } |
| 113 | + } | ||
| 110 | return StringUtils.stripEnd(propertyString.toString(), separator); | 114 | return StringUtils.stripEnd(propertyString.toString(), separator); |
| 111 | } | 115 | } |
| 112 | 116 |
| @@ -3,13 +3,9 @@ package com.ruoyi.framework.config; | @@ -3,13 +3,9 @@ package com.ruoyi.framework.config; | ||
| 3 | import java.nio.charset.Charset; | 3 | import java.nio.charset.Charset; |
| 4 | import org.springframework.data.redis.serializer.RedisSerializer; | 4 | import org.springframework.data.redis.serializer.RedisSerializer; |
| 5 | import org.springframework.data.redis.serializer.SerializationException; | 5 | import org.springframework.data.redis.serializer.SerializationException; |
| 6 | -import org.springframework.util.Assert; | ||
| 7 | import com.alibaba.fastjson2.JSON; | 6 | import com.alibaba.fastjson2.JSON; |
| 8 | import com.alibaba.fastjson2.JSONReader; | 7 | import com.alibaba.fastjson2.JSONReader; |
| 9 | import com.alibaba.fastjson2.JSONWriter; | 8 | import com.alibaba.fastjson2.JSONWriter; |
| 10 | -import com.fasterxml.jackson.databind.JavaType; | ||
| 11 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 12 | -import com.fasterxml.jackson.databind.type.TypeFactory; | ||
| 13 | 9 | ||
| 14 | /** | 10 | /** |
| 15 | * Redis使用FastJson序列化 | 11 | * Redis使用FastJson序列化 |
| @@ -18,9 +14,6 @@ import com.fasterxml.jackson.databind.type.TypeFactory; | @@ -18,9 +14,6 @@ import com.fasterxml.jackson.databind.type.TypeFactory; | ||
| 18 | */ | 14 | */ |
| 19 | public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> | 15 | public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> |
| 20 | { | 16 | { |
| 21 | - @SuppressWarnings("unused") | ||
| 22 | - private ObjectMapper objectMapper = new ObjectMapper(); | ||
| 23 | - | ||
| 24 | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); | 17 | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); |
| 25 | 18 | ||
| 26 | private Class<T> clazz; | 19 | private Class<T> clazz; |
| @@ -52,15 +45,4 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> | @@ -52,15 +45,4 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> | ||
| 52 | 45 | ||
| 53 | return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); | 46 | return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); |
| 54 | } | 47 | } |
| 55 | - | ||
| 56 | - public void setObjectMapper(ObjectMapper objectMapper) | ||
| 57 | - { | ||
| 58 | - Assert.notNull(objectMapper, "'objectMapper' must not be null"); | ||
| 59 | - this.objectMapper = objectMapper; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - protected JavaType getJavaType(Class<?> clazz) | ||
| 63 | - { | ||
| 64 | - return TypeFactory.defaultInstance().constructType(clazz); | ||
| 65 | - } | ||
| 66 | } | 48 | } |
| @@ -8,11 +8,6 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; | @@ -8,11 +8,6 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
| 8 | import org.springframework.data.redis.core.RedisTemplate; | 8 | import org.springframework.data.redis.core.RedisTemplate; |
| 9 | import org.springframework.data.redis.core.script.DefaultRedisScript; | 9 | import org.springframework.data.redis.core.script.DefaultRedisScript; |
| 10 | import org.springframework.data.redis.serializer.StringRedisSerializer; | 10 | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| 11 | -import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
| 12 | -import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
| 13 | -import com.fasterxml.jackson.annotation.PropertyAccessor; | ||
| 14 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 15 | -import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; | ||
| 16 | 11 | ||
| 17 | /** | 12 | /** |
| 18 | * redis配置 | 13 | * redis配置 |
| @@ -32,11 +27,6 @@ public class RedisConfig extends CachingConfigurerSupport | @@ -32,11 +27,6 @@ public class RedisConfig extends CachingConfigurerSupport | ||
| 32 | 27 | ||
| 33 | FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); | 28 | FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); |
| 34 | 29 | ||
| 35 | - ObjectMapper mapper = new ObjectMapper(); | ||
| 36 | - mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | ||
| 37 | - mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); | ||
| 38 | - serializer.setObjectMapper(mapper); | ||
| 39 | - | ||
| 40 | // 使用StringRedisSerializer来序列化和反序列化redis的key值 | 30 | // 使用StringRedisSerializer来序列化和反序列化redis的key值 |
| 41 | template.setKeySerializer(new StringRedisSerializer()); | 31 | template.setKeySerializer(new StringRedisSerializer()); |
| 42 | template.setValueSerializer(serializer); | 32 | template.setValueSerializer(serializer); |
| @@ -11,7 +11,7 @@ import DictOptions from './DictOptions' | @@ -11,7 +11,7 @@ import DictOptions from './DictOptions' | ||
| 11 | export default class DictMeta { | 11 | export default class DictMeta { |
| 12 | constructor(options) { | 12 | constructor(options) { |
| 13 | this.type = options.type | 13 | this.type = options.type |
| 14 | - this.request = options.request, | 14 | + this.request = options.request |
| 15 | this.responseConverter = options.responseConverter | 15 | this.responseConverter = options.responseConverter |
| 16 | this.labelField = options.labelField | 16 | this.labelField = options.labelField |
| 17 | this.valueField = options.valueField | 17 | this.valueField = options.valueField |
-
请 注册 或 登录 后发表评论