From 8d36cd326ca071fb1f47acac6c2c1ca322678852 Mon Sep 17 00:00:00 2001 From: zhangdaihao Date: Tue, 4 Jun 2019 18:16:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BB=A7=E6=89=BF=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=EF=BC=8C=E5=AD=97=E5=85=B8=E4=B8=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=BF=BB=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/modules/system/aspect/DictAspect.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/aspect/DictAspect.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/aspect/DictAspect.java index 550d80fa..0d12e4db 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/aspect/DictAspect.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/aspect/DictAspect.java @@ -12,6 +12,7 @@ import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.Dict; +import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.system.service.ISysDictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -49,7 +50,7 @@ public class DictAspect { long time2=System.currentTimeMillis(); log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms"); long start=System.currentTimeMillis(); - parseDictText(result); + this.parseDictText(result); long end=System.currentTimeMillis(); log.debug("解析注入JSON数据 耗时"+(end-start)+"ms"); return result; @@ -91,18 +92,24 @@ public class DictAspect { log.error("json解析失败"+e.getMessage(),e); } JSONObject item = JSONObject.parseObject(json); - for (Field field : record.getClass().getDeclaredFields()) { + //update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------ + //for (Field field : record.getClass().getDeclaredFields()) { + for (Field field : oConvertUtils.getAllFields(record)) { + //update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------ if (field.getAnnotation(Dict.class) != null) { String code = field.getAnnotation(Dict.class).dicCode(); String text = field.getAnnotation(Dict.class).dicText(); String table = field.getAnnotation(Dict.class).dictTable(); String key = String.valueOf(item.get(field.getName())); String textValue=null; + log.info(" 字典 key : "+ key); if (!StringUtils.isEmpty(table)){ textValue= dictService.queryTableDictTextByKey(table,text,code,key); }else { textValue = dictService.queryDictTextByKey(code, key); } + log.info(" 字典Val : "+ textValue); + log.info(" __翻译字典字段__ "+field.getName() + "_dictText: "+ textValue); item.put(field.getName() + "_dictText", textValue); } //date类型默认转换string格式化日期