Merge pull request #9772 from dataease/pr@dev-v2@sysvariable

Pr@dev v2@sysvariable
This commit is contained in:
taojinlong 2024-05-22 15:21:40 +08:00 committed by GitHub
commit eebc94a739
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 4 deletions

View File

@ -194,6 +194,26 @@ public class ApiUtils {
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 {
if (StringUtils.isEmpty(response)) {
@ -217,6 +237,7 @@ public class ApiUtils {
rootPath = "$";
handleStr(apiDefinition, response, fields, rootPath);
}
previewNum(fields);
apiDefinition.setJsonFields(fields);
return apiDefinition;
} else {

View File

@ -493,6 +493,9 @@ public class DatasourceServer implements DatasourceApi {
public DatasourceDTO get(Long datasourceId) throws DEException {
DatasourceDTO datasourceDTO = new DatasourceDTO();
CoreDatasource datasource = datasourceMapper.selectById(datasourceId);
if(datasource == null){
DEException.throwException("不存在的数据源!");
}
BeanUtils.copyBean(datasourceDTO, datasource);
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")) {
apiDefinition.setShowApiStructure(true);
}
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")) {
apiDefinition.getRequest().getAuthManager().setUsername(new String(Base64.getEncoder().encode(apiDefinition.getRequest().getAuthManager().getUsername().getBytes())));

View File

@ -293,8 +293,8 @@ const previewData = () => {
for (let i = 0; i < apiItem.fields.length; i++) {
for (let j = 0; j < apiItem.fields[i].value.length; j++) {
data[j][apiItem.fields[i].name] = apiItem.fields[i].value[j]
data[j]['id'] = apiItem.fields[i].name
}
columnTmp.push({
key: apiItem.fields[i].name,
dataKey: apiItem.fields[i].name,

@ -1 +1 @@
Subproject commit 2960fb1df000a7136b7dd627040da0b4c0f1cd26
Subproject commit 4ed3bd70e3ecd24fcc3db5dfd0218e72b0c2c18f

View File

@ -20,8 +20,7 @@ public class ApiDefinition {
private String status;
private List<Map<String, Object>> data = new ArrayList<>();
private Integer apiQueryTimeout = 10;
private int previewNum = 10;
private int maxPreviewNum = 10;
private int previewNum = 100;
private int serialNumber;
private boolean useJsonPath;
private String jsonPath;