From 1bff6013ef5c38b939b7de12cbb32da9993f3119 Mon Sep 17 00:00:00 2001 From: fanwenhao Date: Thu, 7 Mar 2024 18:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=97=E5=85=B8=E5=AF=B9Re?= =?UTF-8?q?slt=E4=B8=ADList=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/aspect/DictAspect.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/DictAspect.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/DictAspect.java index 5a736bda21..c42ee86b60 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/DictAspect.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/aspect/DictAspect.java @@ -58,7 +58,7 @@ public void excudeService() { @Around("excudeService()") public Object doAround(ProceedingJoinPoint pjp) throws Throwable { - long time1=System.currentTimeMillis(); + long time1=System.currentTimeMillis(); Object result = pjp.proceed(); long time2=System.currentTimeMillis(); log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms"); @@ -93,7 +93,7 @@ public Object doAround(ProceedingJoinPoint pjp) throws Throwable { */ private Object parseDictText(Object result) { if (result instanceof Result) { - if (((Result) result).getResult() instanceof IPage) { + if (((Result) result).getResult() instanceof IPage || ((Result) result).getResult() instanceof List) { List items = new ArrayList<>(); //step.1 筛选出加了 Dict 注解的字段列表 @@ -101,7 +101,14 @@ private Object parseDictText(Object result) { // 字典数据列表, key = 字典code,value=数据列表 Map> dataListMap = new HashMap<>(5); //取出结果集 - List records=((IPage) ((Result) result).getResult()).getRecords(); + List records= null; + + if (((Result) result).getResult() instanceof List) { + records= (List) ((Result) result).getResult(); + } else { + records= ((IPage) ((Result) result).getResult()).getRecords(); + } + //update-begin--Author:zyf -- Date:20220606 ----for:【VUEN-1230】 判断是否含有字典注解,没有注解返回----- Boolean hasDict= checkHasDict(records); if(!hasDict){ @@ -206,7 +213,14 @@ private Object parseDictText(Object result) { } } - ((IPage) ((Result) result).getResult()).setRecords(items); + + //List 处理 + if (((Result) result).getResult() instanceof List) { + ((Result) result).setResult(items); + } else { + ((IPage) ((Result) result).getResult()).setRecords(items); + } + } } @@ -293,13 +307,13 @@ private Map> translateAllDict(Map> log.debug("translateDictFromTableByKeys.dictCode:" + dictCode); log.debug("translateDictFromTableByKeys.values:" + values); //update-begin---author:chenrui ---date:20231221 for:[issues/#5643]解决分布式下表字典跨库无法查询问题------------ - + //update-begin---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串--- if(null == dataSource){ dataSource = ""; } //update-end---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串--- - + List texts = commonApi.translateDictFromTableByKeys(table, text, code, values, dataSource); //update-end---author:chenrui ---date:20231221 for:[issues/#5643]解决分布式下表字典跨库无法查询问题------------ log.debug("translateDictFromTableByKeys.result:" + texts); @@ -386,9 +400,9 @@ private String translDictText(List dictModels, String values) { */ @Deprecated private String translateDictValue(String code, String text, String table, String key) { - if(oConvertUtils.isEmpty(key)) { - return null; - } + if(oConvertUtils.isEmpty(key)) { + return null; + } StringBuffer textValue=new StringBuffer(); String[] keys = key.split(","); for (String k : keys) { @@ -401,7 +415,7 @@ private String translateDictValue(String code, String text, String table, String if (!StringUtils.isEmpty(table)){ log.debug("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code); String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]",table,text,code,k.trim()); - if (redisTemplate.hasKey(keyString)){ + if (redisTemplate.hasKey(keyString)){ try { tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString)); } catch (Exception e) { @@ -416,7 +430,7 @@ private String translateDictValue(String code, String text, String table, String try { tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString)); } catch (Exception e) { - log.warn(e.getMessage()); + log.warn(e.getMessage()); } }else { tmpValue = commonApi.translateDict(code, k.trim());