| | |
| | | private Object parseDictText(Object result) { |
| | | if (result instanceof Result) { |
| | | if (((Result) result).getResult() instanceof IPage) { |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | |
| | | //step.1 筛选出加了 Dict 注解的字段列表 |
| | | List<Field> dictFieldList = new ArrayList<>(); |
| | | // 字典数据列表, key = 字典code,value=数据列表 |
| | | Map<String, List<String>> dataListMap = new HashMap<>(5); |
| | | //取出结果集 |
| | | List<Object> records=((IPage) ((Result) result).getResult()).getRecords(); |
| | | //update-begin--Author:zyf -- Date:20220606 ----for:【VUEN-1230】 判断是否含有字典注解,没有注解返回----- |
| | |
| | | if(!hasDict){ |
| | | return result; |
| | | } |
| | | List<JSONObject> dictText = getDictText(records); |
| | | ((IPage) ((Result) result).getResult()).setRecords(dictText); |
| | | } |
| | | else { |
| | | //取出结果集 |
| | | Object object= (Object) ((Result) result).getResult(); |
| | | Class<?> aClass = ((Result) result).getResult().getClass(); |
| | | if ("java.util.HashMap".equals(aClass.getName())){ |
| | | //将map转换为集合在转换为map |
| | | Map<String, Object> mapset = new HashMap<>(); |
| | | Map<String,Object> map= (Map<String,Object>) object; |
| | | for (String s : map.keySet()) { |
| | | Object a1 = map.get(s); |
| | | List<Object> records=new ArrayList<>(); |
| | | Class<?> aClass1 = a1.getClass(); |
| | | if ("java.util.ArrayList".equals(aClass1.getName())){ |
| | | records = (ArrayList)map.get(s); |
| | | }else{ |
| | | records = oConvertUtils.castList(a1, Object.class); |
| | | } |
| | | Boolean hasDict= checkHasDict(records); |
| | | if(!hasDict){ |
| | | return result; |
| | | } |
| | | List<JSONObject> dictText = getDictText(records); |
| | | mapset.put(s,dictText); |
| | | } |
| | | ((Result) result).setResult(mapset); |
| | | }else { |
| | | List<Object> records = oConvertUtils.castList(object, Object.class); |
| | | //update-begin--Author:zyf -- Date:20220606 ----for:【VUEN-1230】 判断是否含有字典注解,没有注解返回----- |
| | | Boolean hasDict= checkHasDict(records); |
| | | if(!hasDict){ |
| | | return result; |
| | | } |
| | | List<JSONObject> dictText = getDictText(records); |
| | | ((Result) result).setResult(dictText); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | 传入集合 翻译字典值 |
| | | **/ |
| | | private List<JSONObject> getDictText(List<Object> records){ |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | //step.1 筛选出加了 Dict 注解的字段列表 |
| | | List<Field> dictFieldList = new ArrayList<>(); |
| | | // 字典数据列表, key = 字典code,value=数据列表 |
| | | Map<String, List<String>> dataListMap = new HashMap<>(5); |
| | | |
| | | |
| | | log.debug(" __ 进入字典翻译切面 DictAspect —— " ); |
| | | //update-end--Author:zyf -- Date:20220606 ----for:【VUEN-1230】 判断是否含有字典注解,没有注解返回----- |
| | |
| | | } |
| | | } |
| | | } |
| | | return items; |
| | | |
| | | ((IPage) ((Result) result).getResult()).setRecords(items); |
| | | } |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |