Commit 0be404051cc89108daa0831a03bc8a7e7dce3303

Authored by zhangdaihao
1 parent e039c90b

继承实体,字典不翻译问题解决

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;
12 12 import org.aspectj.lang.annotation.Pointcut;
13 13 import org.jeecg.common.api.vo.Result;
14 14 import org.jeecg.common.aspect.annotation.Dict;
  15 +import org.jeecg.common.util.oConvertUtils;
15 16 import org.jeecg.modules.system.service.ISysDictService;
16 17 import org.springframework.beans.factory.annotation.Autowired;
17 18 import org.springframework.stereotype.Component;
... ... @@ -49,7 +50,7 @@ public class DictAspect {
49 50 long time2=System.currentTimeMillis();
50 51 log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms");
51 52 long start=System.currentTimeMillis();
52   - parseDictText(result);
  53 + this.parseDictText(result);
53 54 long end=System.currentTimeMillis();
54 55 log.debug("解析注入JSON数据 耗时"+(end-start)+"ms");
55 56 return result;
... ... @@ -91,18 +92,24 @@ public class DictAspect {
91 92 log.error("json解析失败"+e.getMessage(),e);
92 93 }
93 94 JSONObject item = JSONObject.parseObject(json);
94   - for (Field field : record.getClass().getDeclaredFields()) {
  95 + //update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
  96 + //for (Field field : record.getClass().getDeclaredFields()) {
  97 + for (Field field : oConvertUtils.getAllFields(record)) {
  98 + //update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
95 99 if (field.getAnnotation(Dict.class) != null) {
96 100 String code = field.getAnnotation(Dict.class).dicCode();
97 101 String text = field.getAnnotation(Dict.class).dicText();
98 102 String table = field.getAnnotation(Dict.class).dictTable();
99 103 String key = String.valueOf(item.get(field.getName()));
100 104 String textValue=null;
  105 + log.info(" 字典 key : "+ key);
101 106 if (!StringUtils.isEmpty(table)){
102 107 textValue= dictService.queryTableDictTextByKey(table,text,code,key);
103 108 }else {
104 109 textValue = dictService.queryDictTextByKey(code, key);
105 110 }
  111 + log.info(" 字典Val : "+ textValue);
  112 + log.info(" __翻译字典字段__ "+field.getName() + "_dictText: "+ textValue);
106 113 item.put(field.getName() + "_dictText", textValue);
107 114 }
108 115 //date类型默认转换string格式化日期
... ...