forked from github/dataease
fix: API 数据源
This commit is contained in:
parent
a753e4e66c
commit
9333ea6e9a
@ -274,21 +274,19 @@ public class DatasourceService {
|
|||||||
|
|
||||||
List<LinkedHashMap> datas = JsonPath.read(response,apiDefinition.getDataPath());
|
List<LinkedHashMap> datas = JsonPath.read(response,apiDefinition.getDataPath());
|
||||||
List<JSONObject> dataList = new ArrayList<>();
|
List<JSONObject> dataList = new ArrayList<>();
|
||||||
|
List<DatasetTableField> fields = new ArrayList<>();
|
||||||
|
Boolean getFileds = true;
|
||||||
|
|
||||||
for (LinkedHashMap data : datas) {
|
for (LinkedHashMap data : datas) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
Iterator it = data.entrySet().iterator();
|
Iterator it = data.entrySet().iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()){
|
||||||
Map.Entry entry = (Map.Entry)it.next();
|
Map.Entry entry = (Map.Entry)it.next();
|
||||||
jsonObject.put((String) entry.getKey(), entry.getValue());
|
jsonObject.put((String) entry.getKey(), entry.getValue());
|
||||||
}
|
if(getFileds) {
|
||||||
dataList.add(jsonObject);
|
|
||||||
}
|
|
||||||
List<DatasetTableField> fields = new ArrayList<>();
|
|
||||||
if(CollectionUtils.isNotEmpty(dataList)){
|
|
||||||
for (Map.Entry<String, Object> stringObjectEntry : dataList.get(0).entrySet()) {
|
|
||||||
DatasetTableField tableField = new DatasetTableField();
|
DatasetTableField tableField = new DatasetTableField();
|
||||||
tableField.setOriginName(stringObjectEntry.getKey());
|
tableField.setOriginName((String) entry.getKey());
|
||||||
tableField.setName(stringObjectEntry.getKey());
|
tableField.setName((String) entry.getKey());
|
||||||
tableField.setSize(65535);
|
tableField.setSize(65535);
|
||||||
tableField.setDeExtractType(0);
|
tableField.setDeExtractType(0);
|
||||||
tableField.setDeType(0);
|
tableField.setDeType(0);
|
||||||
@ -296,6 +294,9 @@ public class DatasourceService {
|
|||||||
fields.add(tableField);
|
fields.add(tableField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getFileds = false;
|
||||||
|
dataList.add(jsonObject);
|
||||||
|
}
|
||||||
apiDefinition.setDatas(dataList);
|
apiDefinition.setDatas(dataList);
|
||||||
apiDefinition.setFields(fields);
|
apiDefinition.setFields(fields);
|
||||||
return apiDefinition;
|
return apiDefinition;
|
||||||
|
Loading…
Reference in New Issue
Block a user