Skip to content

Commit

Permalink
http数据源查询失败问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
ekko.wang authored and YouYe committed Aug 9, 2022
1 parent 7fa772c commit 55d4705
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ public Object checkAndPerformance(ProceedingJoinPoint point) throws Throwable {
log.info("<=============================");
log.info("Request method:{}, url:{}, param:{}", method, url, bodyStr);

String cookieValue = CookieUtils.getCookieValue(request, cookieName);
if (StringUtils.isEmpty(cookieValue)){
log.error("本地获取cookie为空,cookieName=aops-sessionId不存在");
throw new UnAuthorizedException();
}

Object response = point.proceed();
int status = 0;
HttpServletResponse response1 = attributes.getResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static List<Object[]> buildResponseData(Object object, List<Map<String, O
String fieldName = (String) field.get("fieldName");
String fieldType = (String) field.get("fieldType");
collect.put(fieldName, sort, fieldType);
collect2.put(sort,fieldName);
collect2.put(sort, fieldName);
}


Expand All @@ -150,16 +150,13 @@ public static List<Object[]> buildResponseData(Object object, List<Map<String, O
for (Map<String, Object> field : fields) {
int sort = (int) field.get("sort");
Object jsonpath = field.get("jsonpath");
String fieldType = (String)field.get("fieldType");
if (null != jsonpath) {
try {
//对其中一个字段进行jsonpath解析,将当前这个字段的解析结果 作为解析类型
Object transferFieldData = JsonPathUtil.transfer(documentStr, jsonpath.toString());
if (null == transferType && null != transferFieldData) {
transferType = transferFieldData;
}
Class javaClassByName = getJavaClassByName(fieldType);
transferFieldData = getValue(javaClassByName,transferFieldData.toString());
fieldsData.put(sort, transferFieldData);
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -187,29 +184,36 @@ public static List<Object[]> buildResponseData(Object object, List<Map<String, O
int fieldSort = 0;
Object[] rowData = new Object[fieldsSize];
for (Integer sort : sorts) {
String fieldName = collect2.get(sort);
String fieldType = collect.get(fieldName, sort);

Object[] columnData = ((net.minidev.json.JSONArray) fieldsData.get(sort)).toArray();
Object fieldData = null;
Object o = fieldsData.get(sort);
if (o instanceof Collection) {
Object[] columnData = ((net.minidev.json.JSONArray) o).toArray();
fieldData = columnData[rowNum];
} else {
fieldData = o;
}
//需要将 fieldData 转换为 fieldType 需要的类型
Object fieldData = columnData[rowNum];
if (null == fieldData){
rowData[fieldSort++] = null;
}else {
Class javaClassByName = getJavaClassByName(fieldType);
rowData[fieldSort++] = getValue(javaClassByName,fieldData.toString());
int i = fieldSort++;
if (null != fieldData) {
String fieldName = collect2.get(sort);
String fieldType = collect.get(fieldName, sort);
try {
Class javaClassByName = getJavaClassByName(fieldType);
rowData[i] = getValue(javaClassByName, fieldData.toString());
} catch (Exception e) {
log.error("数据fieldData:" + fieldData + " 转换类型:" + fieldType + " 异常");
}
}
}
totalRowData.add(rowData);
}
}
} catch (Exception e) {
log.error("http返回值数据解析异常");
log.error("http返回值数据解析异常" + e);
throw new BizException("http返回值数据解析异常");
}
return totalRowData;
}



}

0 comments on commit 55d4705

Please sign in to comment.