forked from github/dataease
feat: API数据源支持输入jsonpath
This commit is contained in:
parent
cde7bae4a6
commit
444d7c52ac
@ -407,7 +407,7 @@ public class ApiProvider extends Provider {
|
|||||||
List<String[]> dataList = new LinkedList<>();
|
List<String[]> dataList = new LinkedList<>();
|
||||||
if(apiDefinition.isUseJsonPath()){
|
if(apiDefinition.isUseJsonPath()){
|
||||||
List<LinkedHashMap> currentData = new ArrayList<>();
|
List<LinkedHashMap> currentData = new ArrayList<>();
|
||||||
Object object = JsonPath.read(result, apiDefinition.getDataPath());
|
Object object = JsonPath.read(result, apiDefinition.getJsonPath());
|
||||||
if (object instanceof List) {
|
if (object instanceof List) {
|
||||||
currentData = (List<LinkedHashMap>) object;
|
currentData = (List<LinkedHashMap>) object;
|
||||||
} else {
|
} else {
|
||||||
|
@ -538,9 +538,9 @@
|
|||||||
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
:label="$t('datasource.isUseJsonPath')"
|
:label="$t('datasource.isUseJsonPath')"
|
||||||
prop="url"
|
|
||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
|
:disabled="!apiItem.useJsonPath"
|
||||||
v-model="apiItem.jsonPath"
|
v-model="apiItem.jsonPath"
|
||||||
:placeholder="$t('datasource.jsonpath_info')"
|
:placeholder="$t('datasource.jsonpath_info')"
|
||||||
class="input-with-select"
|
class="input-with-select"
|
||||||
@ -1103,6 +1103,10 @@ export default {
|
|||||||
this.$message.error(i18n.t('datasource.has_repeat_name'))
|
this.$message.error(i18n.t('datasource.has_repeat_name'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (this.apiItem.useJsonPath && !this.apiItem.jsonPath) {
|
||||||
|
this.$message.error(i18n.t('datasource.please_input_dataPath'))
|
||||||
|
return
|
||||||
|
}
|
||||||
this.$refs.apiItemBasicInfo.validate((valid) => {
|
this.$refs.apiItemBasicInfo.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
const data = Base64.encode(JSON.stringify(this.apiItem))
|
const data = Base64.encode(JSON.stringify(this.apiItem))
|
||||||
|
Loading…
Reference in New Issue
Block a user