From b3d462e87360b944bf39d626c498ff33ce7c45bd Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 29 May 2022 09:49:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=AF=86=E7=A0=81=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/system/api/domain/SysUser.java | 2 -- .../FastJson2JsonRedisSerializer.java | 18 ------------------ .../common/redis/configure/RedisConfig.java | 10 ---------- .../ruoyi/common/security/utils/DictUtils.java | 7 ++++--- .../resources/mapper/system/SysUserMapper.xml | 2 +- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java index f11f35fda..16619fbbe 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java @@ -5,7 +5,6 @@ import java.util.List; import javax.validation.constraints.*; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.fasterxml.jackson.annotation.JsonProperty; import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel.ColumnType; import com.ruoyi.common.core.annotation.Excel.Type; @@ -198,7 +197,6 @@ public class SysUser extends BaseEntity this.avatar = avatar; } - @JsonProperty public String getPassword() { return password; diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/FastJson2JsonRedisSerializer.java b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/FastJson2JsonRedisSerializer.java index e66369c01..76fe27513 100644 --- a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/FastJson2JsonRedisSerializer.java +++ b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/FastJson2JsonRedisSerializer.java @@ -3,13 +3,9 @@ package com.ruoyi.common.redis.configure; import java.nio.charset.Charset; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationException; -import org.springframework.util.Assert; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONReader; import com.alibaba.fastjson2.JSONWriter; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; /** * Redis使用FastJson序列化 @@ -18,9 +14,6 @@ import com.fasterxml.jackson.databind.type.TypeFactory; */ public class FastJson2JsonRedisSerializer implements RedisSerializer { - @SuppressWarnings("unused") - private ObjectMapper objectMapper = new ObjectMapper(); - public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); private Class clazz; @@ -53,15 +46,4 @@ public class FastJson2JsonRedisSerializer implements RedisSerializer return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); } - - public void setObjectMapper(ObjectMapper objectMapper) - { - Assert.notNull(objectMapper, "'objectMapper' must not be null"); - this.objectMapper = objectMapper; - } - - protected JavaType getJavaType(Class clazz) - { - return TypeFactory.defaultInstance().constructType(clazz); - } } diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java index 31238d63a..e0b96beed 100644 --- a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java +++ b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java @@ -7,11 +7,6 @@ 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.StringRedisSerializer; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.PropertyAccessor; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; /** * redis配置 @@ -31,11 +26,6 @@ public class RedisConfig extends CachingConfigurerSupport FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); - ObjectMapper mapper = new ObjectMapper(); - mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); - mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); - serializer.setObjectMapper(mapper); - // 使用StringRedisSerializer来序列化和反序列化redis的key值 template.setKeySerializer(new StringRedisSerializer()); template.setValueSerializer(serializer); diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java index 9768c6d82..29e52e61c 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java @@ -2,6 +2,7 @@ package com.ruoyi.common.security.utils; import java.util.Collection; import java.util.List; +import com.alibaba.fastjson2.JSONArray; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.utils.SpringUtils; import com.ruoyi.common.core.utils.StringUtils; @@ -34,10 +35,10 @@ public class DictUtils */ public static List getDictCache(String key) { - Object cacheObj = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key)); - if (StringUtils.isNotNull(cacheObj)) + JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key)); + if (StringUtils.isNotNull(arrayCache)) { - return StringUtils.cast(cacheObj); + return arrayCache.toList(SysDictData.class); } return null; } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 16a64c2a3..371c429ab 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"