From 4c1f6bb985e82ce37ad8d17ce451ec4634af28d3 Mon Sep 17 00:00:00 2001 From: q4speed Date: Thu, 17 Dec 2020 16:27:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddubbo=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E4=B8=8D=E8=83=BD=E5=AE=8C=E6=88=90=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/service/APIReportService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/APIReportService.java b/backend/src/main/java/io/metersphere/api/service/APIReportService.java index 0e7e3d2926..20fd1834db 100644 --- a/backend/src/main/java/io/metersphere/api/service/APIReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/APIReportService.java @@ -25,6 +25,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; + import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.Instant; @@ -131,7 +132,7 @@ public class APIReportService { String startTime = jsonRequestResults.getJSONObject(j).getString("startTime"); String name = jsonRequestResults.getJSONObject(j).getString("name"); String url = jsonRequestResults.getJSONObject(j).getString("url"); - if (StringUtils.isBlank(url)){ + if (StringUtils.isBlank(url)) { //如果非http请求不入库 continue; } @@ -139,7 +140,7 @@ public class APIReportService { apiDataView.setId(UUID.randomUUID().toString()); apiDataView.setReportId(reportId); apiDataView.setApiName(name); - apiDataView.setUrl(StringUtils.substringBefore(url,"?")); + apiDataView.setUrl(StringUtils.substringBefore(url, "?")); apiDataView.setResponseTime(responseTime); apiDataView.setStartTime(sdf.format(new Date(Long.parseLong(startTime)))); apiDataView.setResponseCode(responseCode); @@ -149,8 +150,9 @@ public class APIReportService { } catch (Exception e) { LogUtil.error(e); } - apiDataViewMapper.insertListApiData(listApiDataView); - + if (listApiDataView.size() > 0) { + apiDataViewMapper.insertListApiData(listApiDataView); + } } public String create(ApiTest test, String triggerMode) {