perf(utils): 优化字典工具类性能并移除重复依赖
- 在DictUtils中添加类型检查避免不必要的序列化反序列化操作 - 移除pom.xml中的重复jackson-databind依赖配置 - 提升字典数据获取的执行效率
This commit is contained in:
@@ -115,10 +115,6 @@
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>tools.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里JSONè§£æžÂÂ器 -->
|
||||
<!-- io常çâ€Â¨å·¥å…·ç±» -->
|
||||
|
||||
@@ -43,6 +43,12 @@ public class DictUtils {
|
||||
if (StringUtils.isNull(cached)) {
|
||||
return null;
|
||||
}
|
||||
// 如果已经是目标类型,直接返回
|
||||
if (cached instanceof List && ((List<?>) cached).stream().allMatch(e -> e instanceof SysDictData)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SysDictData> result = (List<SysDictData>) cached;
|
||||
return result;
|
||||
}
|
||||
com.fasterxml.jackson.core.type.TypeReference<List<SysDictData>> typeRef =
|
||||
new com.fasterxml.jackson.core.type.TypeReference<List<SysDictData>>() {};
|
||||
ObjectMapper mapper = new ObjectMapper()
|
||||
|
||||
Reference in New Issue
Block a user