This commit is contained in:
liqiang-fit2cloud 2022-12-22 16:22:38 +08:00
commit 1186b47aed
2 changed files with 11 additions and 12 deletions

View File

@ -43,7 +43,6 @@ public class SwaggerUrlImportJob extends MsScheduleJob {
request.setPlatform("Swagger2");
request.setUserId(jobDataMap.getString("userId"));
request.setType("schedule");
request.setUserId(jobDataMap.getString("userId"));
request.setResourceId(resourceId);
apiDefinitionService.apiTestImport(null, request);
}
@ -59,7 +58,7 @@ public class SwaggerUrlImportJob extends MsScheduleJob {
public void setAuthInfo(String config, ApiTestImportRequest request) {
// 获取鉴权设置
if (StringUtils.isNotBlank(config)) {
JSONObject configObj = JSON.parseObject(config, JSONObject.class);
JSONObject configObj = JSONUtil.parseObject(config);
List<KeyValue> headers = JSONUtil.parseArray(configObj.optString("headers"), KeyValue.class);
if (CollectionUtils.isNotEmpty(headers)) {
request.setHeaders(headers);

View File

@ -288,21 +288,21 @@ public class ApiJMeterFileService {
return listBytesToZip(files);
}
private byte[] listBytesToZip(Map<String, byte[]> mapReport) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
for (Map.Entry<String, byte[]> report : mapReport.entrySet()) {
ZipEntry entry = new ZipEntry(report.getKey());
entry.setSize(report.getValue().length);
private byte[] listBytesToZip(Map<String, byte[]> content) {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(byteArrayOutputStream)) {
for (String key : content.keySet()) {
ZipEntry entry = new ZipEntry(key);
entry.setSize(content.get(key).length);
zos.putNextEntry(entry);
zos.write(report.getValue());
zos.write(content.get(key));
}
zos.closeEntry();
zos.close();
return baos.toByteArray();
return byteArrayOutputStream.toByteArray();
} catch (Exception e) {
return null;
LogUtil.error(e);
return new byte[0];
}
}