mirror of
https://github.com/dataease/dataease.git
synced 2026-05-14 04:12:11 +08:00
fix: 【数据源】API数据源接口参数可以调用已创建接口参数 #16470
This commit is contained in:
@@ -218,10 +218,18 @@ public class ApiUtils {
|
||||
for (int i = 0; i < definition.getFields().size(); i++) {
|
||||
TableField field = definition.getFields().get(i);
|
||||
if (field.getName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), paramsList);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
if (dataList.size() > 0) {
|
||||
httpClientConfig.addHeader(header.get("name").toString(), dataList.get(0)[i]);
|
||||
if (dataList.size() == 1) {
|
||||
httpClientConfig.addHeader(header.get("name").toString(), dataList.get(0)[i]);
|
||||
} else {
|
||||
List<String> datas = new ArrayList<>();
|
||||
for (String[] data : dataList) {
|
||||
datas.add(data[i]);
|
||||
}
|
||||
httpClientConfig.addHeader(header.get("name").toString(), JsonUtil.toJSONString(datas).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,10 +248,18 @@ public class ApiUtils {
|
||||
for (int i = 0; i < definition.getFields().size(); i++) {
|
||||
TableField field = definition.getFields().get(i);
|
||||
if (field.getName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), paramsList);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
if (dataList.size() > 0) {
|
||||
result = result.replace("${" + param + "}", dataList.get(0)[i]);
|
||||
if (dataList.size() == 1) {
|
||||
result = result.replace("${" + param + "}", dataList.get(0)[i]);
|
||||
} else {
|
||||
List<String> datas = new ArrayList<>();
|
||||
for (String[] data : dataList) {
|
||||
datas.add(data[i]);
|
||||
}
|
||||
result = result.replace("${" + param + "}", JsonUtil.toJSONString(datas).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,7 +298,7 @@ public class ApiUtils {
|
||||
for (int i = 0; i < definition.getFields().size(); i++) {
|
||||
TableField field = definition.getFields().get(i);
|
||||
if (field.getOriginName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), paramsList);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
if (dataList.size() > 0) {
|
||||
params.add(argument.get("name") + "=" + dataList.get(0)[i]);
|
||||
@@ -304,7 +320,7 @@ public class ApiUtils {
|
||||
for (int i = 0; i < definition.getFields().size(); i++) {
|
||||
TableField field = definition.getFields().get(i);
|
||||
if (field.getName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
String resultStr = execHttpRequest(true, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), paramsList);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
if (dataList.size() > 0) {
|
||||
result = result.replace("${" + param + "}", dataList.get(0)[i]);
|
||||
@@ -357,10 +373,18 @@ public class ApiUtils {
|
||||
for (int i = 0; i < definition.getFields().size(); i++) {
|
||||
TableField field = definition.getFields().get(i);
|
||||
if (field.getOriginName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(false, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
String resultStr = execHttpRequest(false, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), paramsList);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
if (dataList.size() > 0) {
|
||||
raw = raw.replace("${" + param + "}", dataList.get(0)[i]);
|
||||
if (dataList.size() == 1) {
|
||||
raw = raw.replace("${" + param + "}", dataList.get(0)[i]);
|
||||
} else {
|
||||
List<String> datas = new ArrayList<>();
|
||||
for (String[] data : dataList) {
|
||||
datas.add(data[i]);
|
||||
}
|
||||
raw = raw.replace("${" + param + "}", JsonUtil.toJSONString(datas).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,10 +414,18 @@ public class ApiUtils {
|
||||
for (int i = 0; i < definition.getFields().size(); i++) {
|
||||
TableField field = definition.getFields().get(i);
|
||||
if (field.getOriginName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(false, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
String resultStr = execHttpRequest(false, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), paramsList);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
if (dataList.size() > 0) {
|
||||
body.put(jsonNode.get("name").asText(), dataList.get(0)[i]);
|
||||
if (dataList.size() == 1) {
|
||||
body.put(jsonNode.get("name").asText(), dataList.get(0)[i]);
|
||||
} else {
|
||||
List<String> datas = new ArrayList<>();
|
||||
for (String[] data : dataList) {
|
||||
datas.add(data[i]);
|
||||
}
|
||||
body.put(jsonNode.get("name").asText(), JsonUtil.toJSONString(datas).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,10 +444,18 @@ public class ApiUtils {
|
||||
for (int i = 0; i < definition.getFields().size(); i++) {
|
||||
TableField field = definition.getFields().get(i);
|
||||
if (field.getOriginName().equalsIgnoreCase(param)) {
|
||||
String resultStr = execHttpRequest(false, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null);
|
||||
String resultStr = execHttpRequest(false, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), paramsList);
|
||||
List<String[]> dataList = fetchResult(resultStr, definition);
|
||||
if (dataList.size() > 0) {
|
||||
result = result.replace("${" + param + "}", dataList.get(0)[i]);
|
||||
if (dataList.size() == 1) {
|
||||
result = result.replace("${" + param + "}", dataList.get(0)[i]);
|
||||
} else {
|
||||
List<String> datas = new ArrayList<>();
|
||||
for (String[] data : dataList) {
|
||||
datas.add(data[i]);
|
||||
}
|
||||
result = result.replace("${" + param + "}", JsonUtil.toJSONString(datas).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ const initApiItem = (
|
||||
jsName.value = getPluginStatic()
|
||||
}
|
||||
valueList.value = []
|
||||
if (val.type !== 'params' && paramsList) {
|
||||
if (paramsList) {
|
||||
for (let i = 0; i < paramsList.length; i++) {
|
||||
valueList.value = valueList.value.concat(paramsList[i].fields)
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ const timeFunLists = [
|
||||
<el-icon class="drag handle">
|
||||
<Icon name="icon_drag_outlined"><icon_drag_outlined class="svg-icon" /></Icon>
|
||||
</el-icon>
|
||||
<el-col :span="activeName === 'params' ? 8 : 6" v-if="!unShowSelect">
|
||||
<el-col :span="6" v-if="!unShowSelect">
|
||||
<el-input
|
||||
v-if="!suggestions"
|
||||
v-model="element.name"
|
||||
@@ -143,7 +143,7 @@ const timeFunLists = [
|
||||
show-word-limit
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="3" v-if="activeName === 'table'">
|
||||
<el-col :span="3">
|
||||
<el-select v-model="element.nameType" @change="changeNameType(element)">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
@@ -164,17 +164,10 @@ const timeFunLists = [
|
||||
/>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="activeName === 'params' ? 7 : 6">
|
||||
<el-input
|
||||
v-if="!needMock && activeName === 'params'"
|
||||
v-model="element.value"
|
||||
:disabled="isReadOnly"
|
||||
:placeholder="unShowSelect ? t('common.description') : valueText"
|
||||
show-word-limit
|
||||
/>
|
||||
<el-col :span="6">
|
||||
<el-select
|
||||
v-model="element.value"
|
||||
v-if="!needMock && activeName === 'table' && element.nameType === 'params'"
|
||||
v-if="!needMock && element.nameType === 'params'"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
@@ -186,7 +179,7 @@ const timeFunLists = [
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="element.value"
|
||||
v-if="!needMock && activeName === 'table' && element.nameType === 'timeFun'"
|
||||
v-if="!needMock && element.nameType === 'timeFun'"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
@@ -198,12 +191,7 @@ const timeFunLists = [
|
||||
</el-select>
|
||||
|
||||
<el-input
|
||||
v-if="
|
||||
!needMock &&
|
||||
activeName === 'table' &&
|
||||
element.nameType !== 'params' &&
|
||||
element.nameType !== 'timeFun'
|
||||
"
|
||||
v-if="!needMock && element.nameType !== 'params' && element.nameType !== 'timeFun'"
|
||||
v-model="element.value"
|
||||
:disabled="isReadOnly"
|
||||
:placeholder="
|
||||
|
||||
@@ -196,7 +196,7 @@ const timeFunLists = [
|
||||
show-word-limit
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="3" v-if="activeName === 'table'">
|
||||
<el-col :span="3">
|
||||
<el-select v-model="element.nameType" @change="changeNameType(element)">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
@@ -207,19 +207,9 @@ const timeFunLists = [
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col v-if="element.type !== 'file'" :span="6">
|
||||
<el-input
|
||||
v-if="activeName === 'params'"
|
||||
v-model="element.value"
|
||||
:disabled="isReadOnly"
|
||||
class="input-with-autocomplete"
|
||||
:placeholder="valueText"
|
||||
value-key="name"
|
||||
highlight-first-item
|
||||
/>
|
||||
|
||||
<el-select
|
||||
v-model="element.value"
|
||||
v-if="!needMock && activeName === 'table' && element.nameType === 'params'"
|
||||
v-if="!needMock && element.nameType === 'params'"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
@@ -231,7 +221,7 @@ const timeFunLists = [
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="element.value"
|
||||
v-if="!needMock && activeName === 'table' && element.nameType === 'timeFun'"
|
||||
v-if="!needMock && element.nameType === 'timeFun'"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
@@ -243,7 +233,7 @@ const timeFunLists = [
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="element.value"
|
||||
v-if="!needMock && activeName === 'table' && element.nameType === 'pageParams'"
|
||||
v-if="!needMock && element.nameType === 'pageParams'"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
@@ -255,7 +245,6 @@ const timeFunLists = [
|
||||
</el-select>
|
||||
<el-input
|
||||
v-if="
|
||||
activeName === 'table' &&
|
||||
element.nameType !== 'params' &&
|
||||
element.nameType !== 'timeFun' &&
|
||||
element.nameType !== 'pageParams'
|
||||
@@ -273,7 +262,7 @@ const timeFunLists = [
|
||||
/>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="activeName === 'params' ? 10 : 7">
|
||||
<el-col :span="7">
|
||||
<el-input
|
||||
v-model="element.description"
|
||||
maxlength="200"
|
||||
|
||||
Reference in New Issue
Block a user