fix: 优化RedisUtils中对象反序列化逻辑,支持非目标类型转换。close https://gitee.com/elunez/eladmin-mp/issues/IBSMO5
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.odboy.redis;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.slf4j.Logger;
|
||||
@@ -217,7 +218,10 @@ public class RedisHelper {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (clazz.isInstance(value)) {
|
||||
// 如果 value 不是目标类型,则尝试将其反序列化为 clazz 类型 by
|
||||
if (!clazz.isInstance(value)) {
|
||||
return JSON.parseObject(value.toString(), clazz);
|
||||
} else if (clazz.isInstance(value)) {
|
||||
return clazz.cast(value);
|
||||
} else {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user