forked from github/dataease
Merge pull request #9772 from dataease/pr@dev-v2@sysvariable
Pr@dev v2@sysvariable
This commit is contained in:
commit
eebc94a739
@ -194,6 +194,26 @@ public class ApiUtils {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void previewNum(List<Map<String, Object>> field){
|
||||||
|
for (Map<String, Object> stringObjectMap : field) {
|
||||||
|
JSONArray newArray = new JSONArray();
|
||||||
|
if (stringObjectMap.get("value") != null) {
|
||||||
|
try {
|
||||||
|
TypeReference<JSONArray> listTypeReference = new TypeReference<JSONArray>() {
|
||||||
|
};
|
||||||
|
JSONArray array = objectMapper.readValue(stringObjectMap.get("value").toString(), listTypeReference);
|
||||||
|
if(array.size() > 100){
|
||||||
|
for (int i = 0; i < Math.min(100, array.size()); i++) {
|
||||||
|
newArray.add(array.get(i));
|
||||||
|
}
|
||||||
|
stringObjectMap.put("value", newArray);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static ApiDefinition checkApiDefinition(ApiDefinition apiDefinition, String response) throws DEException {
|
public static ApiDefinition checkApiDefinition(ApiDefinition apiDefinition, String response) throws DEException {
|
||||||
if (StringUtils.isEmpty(response)) {
|
if (StringUtils.isEmpty(response)) {
|
||||||
@ -217,6 +237,7 @@ public class ApiUtils {
|
|||||||
rootPath = "$";
|
rootPath = "$";
|
||||||
handleStr(apiDefinition, response, fields, rootPath);
|
handleStr(apiDefinition, response, fields, rootPath);
|
||||||
}
|
}
|
||||||
|
previewNum(fields);
|
||||||
apiDefinition.setJsonFields(fields);
|
apiDefinition.setJsonFields(fields);
|
||||||
return apiDefinition;
|
return apiDefinition;
|
||||||
} else {
|
} else {
|
||||||
|
@ -493,6 +493,9 @@ public class DatasourceServer implements DatasourceApi {
|
|||||||
public DatasourceDTO get(Long datasourceId) throws DEException {
|
public DatasourceDTO get(Long datasourceId) throws DEException {
|
||||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||||
CoreDatasource datasource = datasourceMapper.selectById(datasourceId);
|
CoreDatasource datasource = datasourceMapper.selectById(datasourceId);
|
||||||
|
if(datasource == null){
|
||||||
|
DEException.throwException("不存在的数据源!");
|
||||||
|
}
|
||||||
BeanUtils.copyBean(datasourceDTO, datasource);
|
BeanUtils.copyBean(datasourceDTO, datasource);
|
||||||
TypeReference<List<ApiDefinition>> listTypeReference = new TypeReference<List<ApiDefinition>>() {
|
TypeReference<List<ApiDefinition>> listTypeReference = new TypeReference<List<ApiDefinition>>() {
|
||||||
};
|
};
|
||||||
@ -838,6 +841,7 @@ public class DatasourceServer implements DatasourceApi {
|
|||||||
if (request.keySet().contains("type") && request.get("type").equals("apiStructure")) {
|
if (request.keySet().contains("type") && request.get("type").equals("apiStructure")) {
|
||||||
apiDefinition.setShowApiStructure(true);
|
apiDefinition.setShowApiStructure(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiUtils.checkApiDefinition(apiDefinition, response);
|
ApiUtils.checkApiDefinition(apiDefinition, response);
|
||||||
if (apiDefinition.getRequest().getAuthManager() != null && StringUtils.isNotBlank(apiDefinition.getRequest().getAuthManager().getUsername()) && StringUtils.isNotBlank(apiDefinition.getRequest().getAuthManager().getPassword()) && apiDefinition.getRequest().getAuthManager().getVerification().equals("Basic Auth")) {
|
if (apiDefinition.getRequest().getAuthManager() != null && StringUtils.isNotBlank(apiDefinition.getRequest().getAuthManager().getUsername()) && StringUtils.isNotBlank(apiDefinition.getRequest().getAuthManager().getPassword()) && apiDefinition.getRequest().getAuthManager().getVerification().equals("Basic Auth")) {
|
||||||
apiDefinition.getRequest().getAuthManager().setUsername(new String(Base64.getEncoder().encode(apiDefinition.getRequest().getAuthManager().getUsername().getBytes())));
|
apiDefinition.getRequest().getAuthManager().setUsername(new String(Base64.getEncoder().encode(apiDefinition.getRequest().getAuthManager().getUsername().getBytes())));
|
||||||
|
@ -293,8 +293,8 @@ const previewData = () => {
|
|||||||
for (let i = 0; i < apiItem.fields.length; i++) {
|
for (let i = 0; i < apiItem.fields.length; i++) {
|
||||||
for (let j = 0; j < apiItem.fields[i].value.length; j++) {
|
for (let j = 0; j < apiItem.fields[i].value.length; j++) {
|
||||||
data[j][apiItem.fields[i].name] = apiItem.fields[i].value[j]
|
data[j][apiItem.fields[i].name] = apiItem.fields[i].value[j]
|
||||||
data[j]['id'] = apiItem.fields[i].name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
columnTmp.push({
|
columnTmp.push({
|
||||||
key: apiItem.fields[i].name,
|
key: apiItem.fields[i].name,
|
||||||
dataKey: apiItem.fields[i].name,
|
dataKey: apiItem.fields[i].name,
|
||||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
|||||||
Subproject commit 2960fb1df000a7136b7dd627040da0b4c0f1cd26
|
Subproject commit 4ed3bd70e3ecd24fcc3db5dfd0218e72b0c2c18f
|
@ -20,8 +20,7 @@ public class ApiDefinition {
|
|||||||
private String status;
|
private String status;
|
||||||
private List<Map<String, Object>> data = new ArrayList<>();
|
private List<Map<String, Object>> data = new ArrayList<>();
|
||||||
private Integer apiQueryTimeout = 10;
|
private Integer apiQueryTimeout = 10;
|
||||||
private int previewNum = 10;
|
private int previewNum = 100;
|
||||||
private int maxPreviewNum = 10;
|
|
||||||
private int serialNumber;
|
private int serialNumber;
|
||||||
private boolean useJsonPath;
|
private boolean useJsonPath;
|
||||||
private String jsonPath;
|
private String jsonPath;
|
||||||
|
Loading…
Reference in New Issue
Block a user