fix(数据源): 抽取 api 数据集的字段

This commit is contained in:
taojinlong 2022-08-02 17:17:24 +08:00
parent d2b481c002
commit eabbf9a609
3 changed files with 17 additions and 10 deletions

View File

@ -318,27 +318,31 @@ public class ApiProvider extends Provider {
}
static void mergeValue(JSONObject field, ApiDefinition apiDefinition, JSONObject item) {
JSONArray array = field.getJSONArray("value");
if (array != null && item.getString("value") != null && array.size() < apiDefinition.getPreviewNum()) {
array.add(item.getJSONArray("value").get(0).toString());
field.put("value", array);
}
if(CollectionUtils.isNotEmpty(field.getJSONArray("children"))&& CollectionUtils.isNotEmpty(item.getJSONArray("children"))){
JSONArray objectChildren = field.getJSONArray("children");
JSONArray jsonArrayChildren = new JSONArray();
JSONArray fieldChildren = field.getJSONArray("children");
JSONArray itemChildren = item.getJSONArray("children");
for (Object objectChild : objectChildren) {
JSONObject jsonObject = JSONObject.parseObject(objectChild.toString());
JSONArray fieldArrayChildren = new JSONArray();
for (Object fieldChild : fieldChildren) {
JSONObject jsonObject = JSONObject.parseObject(fieldChild.toString());
JSONObject find = null;
for (Object itemChild : itemChildren) {
JSONObject itemObject = JSONObject.parseObject(itemChild.toString());
if(jsonObject.getString("jsonPath").equals(itemObject.getString("jsonPath"))){
mergeValue(jsonObject, apiDefinition, itemObject);
jsonArrayChildren.add(jsonObject);
find = itemObject;
}
}
if(find != null){
mergeValue(jsonObject, apiDefinition, find);
}
fieldArrayChildren.add(jsonObject);
}
field.put("children", jsonArrayChildren);
field.put("children", fieldArrayChildren);
}
}

View File

@ -932,7 +932,6 @@ export default {
return;
}
this.$refs.apiItem.validate((valid) => {
console.log(valid)
if (valid) {
const data = JSON.parse(JSON.stringify(this.apiItem));
this.loading = true;

View File

@ -316,7 +316,11 @@ export default {
this.form = JSON.parse(JSON.stringify(row))
this.originConfiguration = this.form.configuration
if (row.type === 'api') {
this.originConfiguration = JSON.parse(JSON.stringify(this.form.apiConfiguration))
this.originConfiguration.forEach(item => {
delete item.status
})
this.originConfiguration = JSON.stringify(this.originConfiguration)
} else {
this.form.configuration = JSON.parse(this.form.configuration)
}