mirror of https://github.com/jeecgboot/jeecg-boot
增加字典对Reslt中List的支持
parent
2af165b201
commit
1bff6013ef
|
@ -93,7 +93,7 @@ public class DictAspect {
|
||||||
*/
|
*/
|
||||||
private Object parseDictText(Object result) {
|
private Object parseDictText(Object result) {
|
||||||
if (result instanceof Result) {
|
if (result instanceof Result) {
|
||||||
if (((Result) result).getResult() instanceof IPage) {
|
if (((Result) result).getResult() instanceof IPage || ((Result) result).getResult() instanceof List) {
|
||||||
List<JSONObject> items = new ArrayList<>();
|
List<JSONObject> items = new ArrayList<>();
|
||||||
|
|
||||||
//step.1 筛选出加了 Dict 注解的字段列表
|
//step.1 筛选出加了 Dict 注解的字段列表
|
||||||
|
@ -101,7 +101,14 @@ public class DictAspect {
|
||||||
// 字典数据列表, key = 字典code,value=数据列表
|
// 字典数据列表, key = 字典code,value=数据列表
|
||||||
Map<String, List<String>> dataListMap = new HashMap<>(5);
|
Map<String, List<String>> dataListMap = new HashMap<>(5);
|
||||||
//取出结果集
|
//取出结果集
|
||||||
List<Object> records=((IPage) ((Result) result).getResult()).getRecords();
|
List<Object> records= null;
|
||||||
|
|
||||||
|
if (((Result) result).getResult() instanceof List) {
|
||||||
|
records= (List<Object>) ((Result) result).getResult();
|
||||||
|
} else {
|
||||||
|
records= ((IPage) ((Result) result).getResult()).getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
//update-begin--Author:zyf -- Date:20220606 ----for:【VUEN-1230】 判断是否含有字典注解,没有注解返回-----
|
//update-begin--Author:zyf -- Date:20220606 ----for:【VUEN-1230】 判断是否含有字典注解,没有注解返回-----
|
||||||
Boolean hasDict= checkHasDict(records);
|
Boolean hasDict= checkHasDict(records);
|
||||||
if(!hasDict){
|
if(!hasDict){
|
||||||
|
@ -206,7 +213,14 @@ public class DictAspect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((IPage) ((Result) result).getResult()).setRecords(items);
|
|
||||||
|
//List 处理
|
||||||
|
if (((Result) result).getResult() instanceof List) {
|
||||||
|
((Result) result).setResult(items);
|
||||||
|
} else {
|
||||||
|
((IPage) ((Result) result).getResult()).setRecords(items);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -386,9 +400,9 @@ public class DictAspect {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private String translateDictValue(String code, String text, String table, String key) {
|
private String translateDictValue(String code, String text, String table, String key) {
|
||||||
if(oConvertUtils.isEmpty(key)) {
|
if(oConvertUtils.isEmpty(key)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuffer textValue=new StringBuffer();
|
StringBuffer textValue=new StringBuffer();
|
||||||
String[] keys = key.split(",");
|
String[] keys = key.split(",");
|
||||||
for (String k : keys) {
|
for (String k : keys) {
|
||||||
|
@ -401,7 +415,7 @@ public class DictAspect {
|
||||||
if (!StringUtils.isEmpty(table)){
|
if (!StringUtils.isEmpty(table)){
|
||||||
log.debug("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code);
|
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());
|
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 {
|
try {
|
||||||
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -416,7 +430,7 @@ public class DictAspect {
|
||||||
try {
|
try {
|
||||||
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn(e.getMessage());
|
log.warn(e.getMessage());
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
tmpValue = commonApi.translateDict(code, k.trim());
|
tmpValue = commonApi.translateDict(code, k.trim());
|
||||||
|
|
Loading…
Reference in New Issue