From 2465587992098df9d29cafccc0eb9cdbd972329b Mon Sep 17 00:00:00 2001 From: MeterSphere Bot <78466014+metersphere-bot@users.noreply.github.com> Date: Sat, 9 Apr 2022 17:36:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=BA=E6=99=AF=E6=8A=A5=E5=91=8A=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E7=9A=84=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E7=BB=93=E6=9E=84=20(#12442)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化场景报告步骤的基础信息存储结构 Co-authored-by: song-tianyang --- .../api/dto/ApiScenarioReportBaseInfoDTO.java | 19 + .../api/dto/RequestResultExpandDTO.java | 29 +- .../ApiScenarioReportResultService.java | 61 ++- .../ApiScenarioReportStructureService.java | 22 +- .../base/domain/ApiScenarioReportResult.java | 14 - .../ApiScenarioReportResultExample.java | 380 ------------------ .../ApiScenarioReportResultWithBLOBs.java | 4 +- .../mapper/ApiScenarioReportResultMapper.java | 17 +- .../mapper/ApiScenarioReportResultMapper.xml | 148 ++----- .../ext/ExtApiScenarioReportResultMapper.java | 4 +- .../ext/ExtApiScenarioReportResultMapper.xml | 9 +- .../db/migration/V115__1.20__release.sql | 9 +- 12 files changed, 123 insertions(+), 593 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java diff --git a/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java b/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java new file mode 100644 index 0000000000..e01bd72a6f --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/ApiScenarioReportBaseInfoDTO.java @@ -0,0 +1,19 @@ +package io.metersphere.api.dto; + +import lombok.Getter; +import lombok.Setter; + +/** + * @author song.tianyang + * @Date 2022/4/9 3:50 下午 + */ +@Getter +@Setter +public class ApiScenarioReportBaseInfoDTO { + private String reqName; + private boolean reqSuccess; + private int reqError; + private long reqStartTime; + private String rspCode; + private long rspTime; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/RequestResultExpandDTO.java b/backend/src/main/java/io/metersphere/api/dto/RequestResultExpandDTO.java index 27d41b8fd7..6c879d5921 100644 --- a/backend/src/main/java/io/metersphere/api/dto/RequestResultExpandDTO.java +++ b/backend/src/main/java/io/metersphere/api/dto/RequestResultExpandDTO.java @@ -1,6 +1,8 @@ package io.metersphere.api.dto; -import io.metersphere.base.domain.ApiScenarioReportResult; +import com.alibaba.fastjson.JSONObject; +import io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.RequestResult; import io.metersphere.dto.ResponseResult; import lombok.Getter; @@ -17,14 +19,21 @@ public class RequestResultExpandDTO extends RequestResult { public RequestResultExpandDTO() { } - public RequestResultExpandDTO(ApiScenarioReportResult requestResult) { - this.setName(requestResult.getReqName()); - this.setSuccess(requestResult.getReqSuccess()); - this.setError(requestResult.getReqError()); - this.setStartTime(requestResult.getReqStartTime()); - ResponseResult responseResult = this.getResponseResult(); - responseResult.setResponseCode(requestResult.getRspCode()); - responseResult.setResponseTime(requestResult.getRspTime()); - this.setResponseResult(responseResult); + public RequestResultExpandDTO(ApiScenarioReportResultWithBLOBs requestResult) { + if(requestResult.getBaseInfo() != null){ + try { + ApiScenarioReportBaseInfoDTO dto = JSONObject.parseObject(requestResult.getBaseInfo(),ApiScenarioReportBaseInfoDTO.class); + this.setName(dto.getReqName()); + this.setSuccess(dto.isReqSuccess()); + this.setError(dto.getReqError()); + this.setStartTime(dto.getReqStartTime()); + ResponseResult responseResult = this.getResponseResult(); + responseResult.setResponseCode(dto.getRspCode()); + responseResult.setResponseTime(dto.getRspTime()); + this.setResponseResult(responseResult); + }catch (Exception e){ + LogUtil.error("Parse report base-info error :"+ e.getMessage()); + } + } } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java index 5304005258..606470ed14 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportResultService.java @@ -2,8 +2,9 @@ package io.metersphere.api.service; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import io.metersphere.api.dto.ApiScenarioReportBaseInfoDTO; import io.metersphere.api.dto.ErrorReportLibraryParseDTO; -import io.metersphere.base.domain.ApiScenarioReportResult; +import io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs; import io.metersphere.base.mapper.ApiScenarioReportResultMapper; import io.metersphere.commons.constants.ExecuteResult; import io.metersphere.commons.utils.ErrorReportLibraryUtil; @@ -88,8 +89,8 @@ public class ApiScenarioReportResultService { } } - private ApiScenarioReportResult newUiScenarioReportResult(String reportId, String resourceId, JSONObject value) { - ApiScenarioReportResult report = new ApiScenarioReportResult(); + private ApiScenarioReportResultWithBLOBs newUiScenarioReportResult(String reportId, String resourceId, JSONObject value) { + ApiScenarioReportResultWithBLOBs report = new ApiScenarioReportResultWithBLOBs(); report.setId(UUID.randomUUID().toString()); report.setResourceId(resourceId); report.setReportId(reportId); @@ -102,8 +103,8 @@ public class ApiScenarioReportResultService { return report; } - private ApiScenarioReportResult newApiScenarioReportResult(String reportId, RequestResult baseResult) { - ApiScenarioReportResult report = new ApiScenarioReportResult(); + private ApiScenarioReportResultWithBLOBs newApiScenarioReportResult(String reportId, RequestResult baseResult) { + ApiScenarioReportResultWithBLOBs report = new ApiScenarioReportResultWithBLOBs(); //解析误报内容 ErrorReportLibraryParseDTO errorCodeDTO = ErrorReportLibraryUtil.parseAssertions(baseResult); RequestResult result = errorCodeDTO.getResult(); @@ -123,49 +124,45 @@ public class ApiScenarioReportResultService { report.setRequestTime(result.getEndTime() - result.getStartTime()); //记录基础信息 - report.setReqName(StringUtils.isEmpty(result.getName()) ? "" : result.getName()); - report.setReqSuccess(result.isSuccess()); - report.setReqError(result.getError()); - report.setReqStartTime(result.getStartTime()); + ApiScenarioReportBaseInfoDTO baseInfoDTO = new ApiScenarioReportBaseInfoDTO(); + baseInfoDTO.setReqName(result.getName()); + baseInfoDTO.setReqSuccess(result.isSuccess()); + baseInfoDTO.setReqError(result.getError()); + baseInfoDTO.setReqStartTime(result.getStartTime()); if (result.getResponseResult() != null) { - report.setRspCode(result.getResponseResult().getResponseCode()); - report.setRspTime(result.getResponseResult().getResponseTime()); - } else { - report.setRspCode(""); - report.setRspTime(Long.valueOf(0)); + baseInfoDTO.setRspCode(result.getResponseResult().getResponseCode()); + baseInfoDTO.setRspTime(result.getResponseResult().getResponseTime()); } - + report.setBaseInfo(JSONObject.toJSONString(baseInfoDTO)); report.setContent(JSON.toJSONString(result).getBytes(StandardCharsets.UTF_8)); return report; } - public boolean isResultFormat(ApiScenarioReportResult result) { - if (result != null) { - if (result.getReqName() == null && result.getReqStartTime() == null && result.getRspCode() == null && result.getRspTime() == null) { - return false; - } + public boolean isResultFormat(ApiScenarioReportResultWithBLOBs result) { + if (result != null && result.getBaseInfo() != null) { + return true; + }else { + return false; } - return true; } - public ApiScenarioReportResult formatScenarioResult(ApiScenarioReportResult result) { + public ApiScenarioReportResultWithBLOBs formatScenarioResult(ApiScenarioReportResultWithBLOBs result) { if (!this.isResultFormat(result)) { - ApiScenarioReportResult baseResult = apiScenarioReportResultMapper.selectByPrimaryKey(result.getId()); + ApiScenarioReportResultWithBLOBs baseResult = apiScenarioReportResultMapper.selectByPrimaryKey(result.getId()); if (baseResult != null) { try { RequestResult requestResult = JSON.parseObject(new String(baseResult.getContent(), StandardCharsets.UTF_8), RequestResult.class); //记录基础信息 - baseResult.setReqName(StringUtils.isEmpty(requestResult.getName()) ? "" : requestResult.getName()); - baseResult.setReqSuccess(requestResult.isSuccess()); - baseResult.setReqError(requestResult.getError()); - baseResult.setReqStartTime(requestResult.getStartTime()); + ApiScenarioReportBaseInfoDTO baseInfo = new ApiScenarioReportBaseInfoDTO(); + baseInfo.setReqName(StringUtils.isEmpty(requestResult.getName()) ? "" : requestResult.getName()); + baseInfo.setReqSuccess(requestResult.isSuccess()); + baseInfo.setReqError(requestResult.getError()); + baseInfo.setReqStartTime(requestResult.getStartTime()); if (requestResult.getResponseResult() != null) { - baseResult.setRspCode(requestResult.getResponseResult().getResponseCode()); - baseResult.setRspTime(requestResult.getResponseResult().getResponseTime()); - } else { - baseResult.setRspCode(""); - baseResult.setRspTime(Long.valueOf(0)); + baseInfo.setRspCode(requestResult.getResponseResult().getResponseCode()); + baseInfo.setRspTime(requestResult.getResponseResult().getResponseTime()); } + baseResult.setBaseInfo(JSONObject.toJSONString(baseInfo)); apiScenarioReportResultMapper.updateByPrimaryKeySelective(baseResult); return baseResult; } catch (Exception e) { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java index 9319681714..1d05e7fe7f 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java @@ -274,15 +274,15 @@ public class ApiScenarioReportStructureService { } } - public void reportFormatting(List dtoList, Map> maps) { + public void reportFormatting(List dtoList, Map> maps) { for (int index = 0; index < dtoList.size(); index++) { StepTreeDTO dto = dtoList.get(index); dto.setIndex((index + 1)); - List reportResults = maps.get(dto.getResourceId()); + List reportResults = maps.get(dto.getResourceId()); if (CollectionUtils.isNotEmpty(reportResults)) { if (reportResults.size() > 1) { for (int i = 0; i < reportResults.size(); i++) { - ApiScenarioReportResult reportResult = reportResults.get(i); + ApiScenarioReportResultWithBLOBs reportResult = reportResults.get(i); reportResult = apiScenarioReportResultService.formatScenarioResult(reportResult); if (i == 0) { RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult); @@ -298,7 +298,7 @@ public class ApiScenarioReportStructureService { } } } else { - ApiScenarioReportResult reportResult = reportResults.get(0); + ApiScenarioReportResultWithBLOBs reportResult = reportResults.get(0); reportResult = apiScenarioReportResultService.formatScenarioResult(reportResult); RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult); dto.setStepId(reportResults.get(0).getId()); @@ -516,7 +516,7 @@ public class ApiScenarioReportStructureService { } private ApiScenarioReportDTO getReport(String reportId) { - List reportResults = null; + List reportResults = null; ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId); if (report.getReportType() != null && report.getReportType().startsWith("UI")) { ApiScenarioReportResultExample example = new ApiScenarioReportResultExample(); @@ -542,7 +542,7 @@ public class ApiScenarioReportStructureService { ApiScenarioReportStructureWithBLOBs scenarioReportStructure = reportStructureWithBLOBs.get(0); List stepList = JSONArray.parseArray(new String(scenarioReportStructure.getResourceTree(), StandardCharsets.UTF_8), StepTreeDTO.class); // 匹配结果 - Map> maps = reportResults.stream().collect(Collectors.groupingBy(ApiScenarioReportResult::getResourceId)); + Map> maps = reportResults.stream().collect(Collectors.groupingBy(ApiScenarioReportResult::getResourceId)); this.reportFormatting(stepList, maps); reportDTO = this.countReportNum(stepList, reportDTO); @@ -573,7 +573,7 @@ public class ApiScenarioReportStructureService { return reportDTO; } - private List selectBaseInfoResultByReportId(String reportId) { + private List selectBaseInfoResultByReportId(String reportId) { return extApiScenarioReportResultMapper.selectBaseInfoResultByReportId(reportId); } @@ -582,11 +582,11 @@ public class ApiScenarioReportStructureService { * * @param reportResults */ - private void removeUiResultIfNotStep(List reportResults) { + private void removeUiResultIfNotStep(List reportResults) { if(CollectionUtils.isNotEmpty(reportResults)){ - Iterator iterator = reportResults.iterator(); + Iterator iterator = reportResults.iterator(); while (iterator.hasNext()) { - ApiScenarioReportResult item = iterator.next(); + ApiScenarioReportResultWithBLOBs item = iterator.next(); String result = new String(item.getContent(), StandardCharsets.UTF_8); if (StringUtils.isNotBlank(result)) { Boolean isNoStep = JSONObject.parseObject(result).getBoolean("isNotStep"); @@ -650,7 +650,7 @@ public class ApiScenarioReportStructureService { } public RequestResult selectReportContent(String stepId) { - ApiScenarioReportResult apiScenarioReportResult = reportResultMapper.selectByPrimaryKey(stepId); + ApiScenarioReportResultWithBLOBs apiScenarioReportResult = reportResultMapper.selectByPrimaryKey(stepId); if (apiScenarioReportResult != null) { RequestResult requestResult = JSON.parseObject(new String(apiScenarioReportResult.getContent(), StandardCharsets.UTF_8), RequestResult.class); return requestResult; diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResult.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResult.java index 3894048378..ab4dda0350 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResult.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResult.java @@ -23,19 +23,5 @@ public class ApiScenarioReportResult implements Serializable { private String errorCode; - private String reqName; - - private Boolean reqSuccess; - - private Integer reqError; - - private Long reqStartTime; - - private String rspCode; - - private Long rspTime; - - private byte[] content; - private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultExample.java index 622ec85db4..2c91c34509 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultExample.java @@ -693,386 +693,6 @@ public class ApiScenarioReportResultExample { addCriterion("error_code not between", value1, value2, "errorCode"); return (Criteria) this; } - - public Criteria andReqNameIsNull() { - addCriterion("req_name is null"); - return (Criteria) this; - } - - public Criteria andReqNameIsNotNull() { - addCriterion("req_name is not null"); - return (Criteria) this; - } - - public Criteria andReqNameEqualTo(String value) { - addCriterion("req_name =", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameNotEqualTo(String value) { - addCriterion("req_name <>", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameGreaterThan(String value) { - addCriterion("req_name >", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameGreaterThanOrEqualTo(String value) { - addCriterion("req_name >=", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameLessThan(String value) { - addCriterion("req_name <", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameLessThanOrEqualTo(String value) { - addCriterion("req_name <=", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameLike(String value) { - addCriterion("req_name like", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameNotLike(String value) { - addCriterion("req_name not like", value, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameIn(List values) { - addCriterion("req_name in", values, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameNotIn(List values) { - addCriterion("req_name not in", values, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameBetween(String value1, String value2) { - addCriterion("req_name between", value1, value2, "reqName"); - return (Criteria) this; - } - - public Criteria andReqNameNotBetween(String value1, String value2) { - addCriterion("req_name not between", value1, value2, "reqName"); - return (Criteria) this; - } - - public Criteria andReqSuccessIsNull() { - addCriterion("req_success is null"); - return (Criteria) this; - } - - public Criteria andReqSuccessIsNotNull() { - addCriterion("req_success is not null"); - return (Criteria) this; - } - - public Criteria andReqSuccessEqualTo(Boolean value) { - addCriterion("req_success =", value, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessNotEqualTo(Boolean value) { - addCriterion("req_success <>", value, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessGreaterThan(Boolean value) { - addCriterion("req_success >", value, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessGreaterThanOrEqualTo(Boolean value) { - addCriterion("req_success >=", value, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessLessThan(Boolean value) { - addCriterion("req_success <", value, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessLessThanOrEqualTo(Boolean value) { - addCriterion("req_success <=", value, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessIn(List values) { - addCriterion("req_success in", values, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessNotIn(List values) { - addCriterion("req_success not in", values, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessBetween(Boolean value1, Boolean value2) { - addCriterion("req_success between", value1, value2, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqSuccessNotBetween(Boolean value1, Boolean value2) { - addCriterion("req_success not between", value1, value2, "reqSuccess"); - return (Criteria) this; - } - - public Criteria andReqErrorIsNull() { - addCriterion("req_error is null"); - return (Criteria) this; - } - - public Criteria andReqErrorIsNotNull() { - addCriterion("req_error is not null"); - return (Criteria) this; - } - - public Criteria andReqErrorEqualTo(Integer value) { - addCriterion("req_error =", value, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorNotEqualTo(Integer value) { - addCriterion("req_error <>", value, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorGreaterThan(Integer value) { - addCriterion("req_error >", value, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorGreaterThanOrEqualTo(Integer value) { - addCriterion("req_error >=", value, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorLessThan(Integer value) { - addCriterion("req_error <", value, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorLessThanOrEqualTo(Integer value) { - addCriterion("req_error <=", value, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorIn(List values) { - addCriterion("req_error in", values, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorNotIn(List values) { - addCriterion("req_error not in", values, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorBetween(Integer value1, Integer value2) { - addCriterion("req_error between", value1, value2, "reqError"); - return (Criteria) this; - } - - public Criteria andReqErrorNotBetween(Integer value1, Integer value2) { - addCriterion("req_error not between", value1, value2, "reqError"); - return (Criteria) this; - } - - public Criteria andReqStartTimeIsNull() { - addCriterion("req_start_time is null"); - return (Criteria) this; - } - - public Criteria andReqStartTimeIsNotNull() { - addCriterion("req_start_time is not null"); - return (Criteria) this; - } - - public Criteria andReqStartTimeEqualTo(Long value) { - addCriterion("req_start_time =", value, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeNotEqualTo(Long value) { - addCriterion("req_start_time <>", value, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeGreaterThan(Long value) { - addCriterion("req_start_time >", value, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeGreaterThanOrEqualTo(Long value) { - addCriterion("req_start_time >=", value, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeLessThan(Long value) { - addCriterion("req_start_time <", value, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeLessThanOrEqualTo(Long value) { - addCriterion("req_start_time <=", value, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeIn(List values) { - addCriterion("req_start_time in", values, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeNotIn(List values) { - addCriterion("req_start_time not in", values, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeBetween(Long value1, Long value2) { - addCriterion("req_start_time between", value1, value2, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andReqStartTimeNotBetween(Long value1, Long value2) { - addCriterion("req_start_time not between", value1, value2, "reqStartTime"); - return (Criteria) this; - } - - public Criteria andRspCodeIsNull() { - addCriterion("rsp_code is null"); - return (Criteria) this; - } - - public Criteria andRspCodeIsNotNull() { - addCriterion("rsp_code is not null"); - return (Criteria) this; - } - - public Criteria andRspCodeEqualTo(String value) { - addCriterion("rsp_code =", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeNotEqualTo(String value) { - addCriterion("rsp_code <>", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeGreaterThan(String value) { - addCriterion("rsp_code >", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeGreaterThanOrEqualTo(String value) { - addCriterion("rsp_code >=", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeLessThan(String value) { - addCriterion("rsp_code <", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeLessThanOrEqualTo(String value) { - addCriterion("rsp_code <=", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeLike(String value) { - addCriterion("rsp_code like", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeNotLike(String value) { - addCriterion("rsp_code not like", value, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeIn(List values) { - addCriterion("rsp_code in", values, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeNotIn(List values) { - addCriterion("rsp_code not in", values, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeBetween(String value1, String value2) { - addCriterion("rsp_code between", value1, value2, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspCodeNotBetween(String value1, String value2) { - addCriterion("rsp_code not between", value1, value2, "rspCode"); - return (Criteria) this; - } - - public Criteria andRspTimeIsNull() { - addCriterion("rsp_time is null"); - return (Criteria) this; - } - - public Criteria andRspTimeIsNotNull() { - addCriterion("rsp_time is not null"); - return (Criteria) this; - } - - public Criteria andRspTimeEqualTo(Long value) { - addCriterion("rsp_time =", value, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeNotEqualTo(Long value) { - addCriterion("rsp_time <>", value, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeGreaterThan(Long value) { - addCriterion("rsp_time >", value, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeGreaterThanOrEqualTo(Long value) { - addCriterion("rsp_time >=", value, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeLessThan(Long value) { - addCriterion("rsp_time <", value, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeLessThanOrEqualTo(Long value) { - addCriterion("rsp_time <=", value, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeIn(List values) { - addCriterion("rsp_time in", values, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeNotIn(List values) { - addCriterion("rsp_time not in", values, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeBetween(Long value1, Long value2) { - addCriterion("rsp_time between", value1, value2, "rspTime"); - return (Criteria) this; - } - - public Criteria andRspTimeNotBetween(Long value1, Long value2) { - addCriterion("rsp_time not between", value1, value2, "rspTime"); - return (Criteria) this; - } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultWithBLOBs.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultWithBLOBs.java index 5e1de055b9..e0e1809039 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultWithBLOBs.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportResultWithBLOBs.java @@ -9,7 +9,9 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ApiScenarioReportResultWithBLOBs extends ApiScenarioReportResult implements Serializable { - private String errorCode; + private byte[] content; + + private String baseInfo; private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.java index 5516e30009..4fd93eab78 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.java @@ -2,6 +2,7 @@ package io.metersphere.base.mapper; import io.metersphere.base.domain.ApiScenarioReportResult; import io.metersphere.base.domain.ApiScenarioReportResultExample; +import io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs; import java.util.List; import org.apache.ibatis.annotations.Param; @@ -12,25 +13,25 @@ public interface ApiScenarioReportResultMapper { int deleteByPrimaryKey(String id); - int insert(ApiScenarioReportResult record); + int insert(ApiScenarioReportResultWithBLOBs record); - int insertSelective(ApiScenarioReportResult record); + int insertSelective(ApiScenarioReportResultWithBLOBs record); - List selectByExampleWithBLOBs(ApiScenarioReportResultExample example); + List selectByExampleWithBLOBs(ApiScenarioReportResultExample example); List selectByExample(ApiScenarioReportResultExample example); - ApiScenarioReportResult selectByPrimaryKey(String id); + ApiScenarioReportResultWithBLOBs selectByPrimaryKey(String id); - int updateByExampleSelective(@Param("record") ApiScenarioReportResult record, @Param("example") ApiScenarioReportResultExample example); + int updateByExampleSelective(@Param("record") ApiScenarioReportResultWithBLOBs record, @Param("example") ApiScenarioReportResultExample example); - int updateByExampleWithBLOBs(@Param("record") ApiScenarioReportResult record, @Param("example") ApiScenarioReportResultExample example); + int updateByExampleWithBLOBs(@Param("record") ApiScenarioReportResultWithBLOBs record, @Param("example") ApiScenarioReportResultExample example); int updateByExample(@Param("record") ApiScenarioReportResult record, @Param("example") ApiScenarioReportResultExample example); - int updateByPrimaryKeySelective(ApiScenarioReportResult record); + int updateByPrimaryKeySelective(ApiScenarioReportResultWithBLOBs record); - int updateByPrimaryKeyWithBLOBs(ApiScenarioReportResult record); + int updateByPrimaryKeyWithBLOBs(ApiScenarioReportResultWithBLOBs record); int updateByPrimaryKey(ApiScenarioReportResult record); } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.xml index 4a2c78e7f5..541a9cb122 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportResultMapper.xml @@ -11,15 +11,10 @@ - - - - - - - + + @@ -81,11 +76,10 @@ id, resource_id, report_id, create_time, `status`, request_time, total_assertions, - pass_assertions, error_code, req_name, req_success, req_error, req_start_time, rsp_code, - rsp_time + pass_assertions, error_code - content + content, base_info @@ -288,27 +248,12 @@ error_code = #{record.errorCode,jdbcType=VARCHAR}, - - req_name = #{record.reqName,jdbcType=VARCHAR}, - - - req_success = #{record.reqSuccess,jdbcType=BIT}, - - - req_error = #{record.reqError,jdbcType=INTEGER}, - - - req_start_time = #{record.reqStartTime,jdbcType=BIGINT}, - - - rsp_code = #{record.rspCode,jdbcType=VARCHAR}, - - - rsp_time = #{record.rspTime,jdbcType=BIGINT}, - content = #{record.content,jdbcType=LONGVARBINARY}, + + base_info = #{record.baseInfo,jdbcType=LONGVARCHAR}, + @@ -325,13 +270,8 @@ total_assertions = #{record.totalAssertions,jdbcType=BIGINT}, pass_assertions = #{record.passAssertions,jdbcType=BIGINT}, error_code = #{record.errorCode,jdbcType=VARCHAR}, - req_name = #{record.reqName,jdbcType=VARCHAR}, - req_success = #{record.reqSuccess,jdbcType=BIT}, - req_error = #{record.reqError,jdbcType=INTEGER}, - req_start_time = #{record.reqStartTime,jdbcType=BIGINT}, - rsp_code = #{record.rspCode,jdbcType=VARCHAR}, - rsp_time = #{record.rspTime,jdbcType=BIGINT}, - content = #{record.content,jdbcType=LONGVARBINARY} + content = #{record.content,jdbcType=LONGVARBINARY}, + base_info = #{record.baseInfo,jdbcType=LONGVARCHAR} @@ -346,18 +286,12 @@ request_time = #{record.requestTime,jdbcType=BIGINT}, total_assertions = #{record.totalAssertions,jdbcType=BIGINT}, pass_assertions = #{record.passAssertions,jdbcType=BIGINT}, - error_code = #{record.errorCode,jdbcType=VARCHAR}, - req_name = #{record.reqName,jdbcType=VARCHAR}, - req_success = #{record.reqSuccess,jdbcType=BIT}, - req_error = #{record.reqError,jdbcType=INTEGER}, - req_start_time = #{record.reqStartTime,jdbcType=BIGINT}, - rsp_code = #{record.rspCode,jdbcType=VARCHAR}, - rsp_time = #{record.rspTime,jdbcType=BIGINT} + error_code = #{record.errorCode,jdbcType=VARCHAR} - + update api_scenario_report_result @@ -384,31 +318,16 @@ error_code = #{errorCode,jdbcType=VARCHAR}, - - req_name = #{reqName,jdbcType=VARCHAR}, - - - req_success = #{reqSuccess,jdbcType=BIT}, - - - req_error = #{reqError,jdbcType=INTEGER}, - - - req_start_time = #{reqStartTime,jdbcType=BIGINT}, - - - rsp_code = #{rspCode,jdbcType=VARCHAR}, - - - rsp_time = #{rspTime,jdbcType=BIGINT}, - content = #{content,jdbcType=LONGVARBINARY}, + + base_info = #{baseInfo,jdbcType=LONGVARCHAR}, + where id = #{id,jdbcType=VARCHAR} - + update api_scenario_report_result set resource_id = #{resourceId,jdbcType=VARCHAR}, report_id = #{reportId,jdbcType=VARCHAR}, @@ -418,13 +337,8 @@ total_assertions = #{totalAssertions,jdbcType=BIGINT}, pass_assertions = #{passAssertions,jdbcType=BIGINT}, error_code = #{errorCode,jdbcType=VARCHAR}, - req_name = #{reqName,jdbcType=VARCHAR}, - req_success = #{reqSuccess,jdbcType=BIT}, - req_error = #{reqError,jdbcType=INTEGER}, - req_start_time = #{reqStartTime,jdbcType=BIGINT}, - rsp_code = #{rspCode,jdbcType=VARCHAR}, - rsp_time = #{rspTime,jdbcType=BIGINT}, - content = #{content,jdbcType=LONGVARBINARY} + content = #{content,jdbcType=LONGVARBINARY}, + base_info = #{baseInfo,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -436,13 +350,7 @@ request_time = #{requestTime,jdbcType=BIGINT}, total_assertions = #{totalAssertions,jdbcType=BIGINT}, pass_assertions = #{passAssertions,jdbcType=BIGINT}, - error_code = #{errorCode,jdbcType=VARCHAR}, - req_name = #{reqName,jdbcType=VARCHAR}, - req_success = #{reqSuccess,jdbcType=BIT}, - req_error = #{reqError,jdbcType=INTEGER}, - req_start_time = #{reqStartTime,jdbcType=BIGINT}, - rsp_code = #{rspCode,jdbcType=VARCHAR}, - rsp_time = #{rspTime,jdbcType=BIGINT} + error_code = #{errorCode,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java index eb95cd8d36..ed558a650a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java @@ -1,9 +1,9 @@ package io.metersphere.base.mapper.ext; -import io.metersphere.base.domain.ApiScenarioReportResult; +import io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs; import java.util.List; public interface ExtApiScenarioReportResultMapper { - List selectBaseInfoResultByReportId(String reportId); + List selectBaseInfoResultByReportId(String reportId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml index 2368baa683..9962cbab21 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml @@ -1,7 +1,7 @@ - SELECT id, resource_id, report_id, @@ -11,12 +11,7 @@ total_assertions, pass_assertions, error_code, - req_name, - req_success, - req_error, - req_start_time, - rsp_code, - rsp_time + base_info FROM api_scenario_report_result WHERE report_id = #{0} diff --git a/backend/src/main/resources/db/migration/V115__1.20__release.sql b/backend/src/main/resources/db/migration/V115__1.20__release.sql index 76ff14e120..b810c710d8 100644 --- a/backend/src/main/resources/db/migration/V115__1.20__release.sql +++ b/backend/src/main/resources/db/migration/V115__1.20__release.sql @@ -179,11 +179,4 @@ CREATE TABLE IF NOT EXISTS `test_plan_execution_queue` ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; -- 场景步骤结果增加简要信息 -ALTER TABLE api_scenario_report_result ADD ( - `req_name` VARCHAR(255) NULL, - `req_success` tinyint(1) NULL DEFAULT 0, - `req_error` int(11) NULL DEFAULT 0, - `req_start_time` bigint(13) NULL DEFAULT NULL, - `rsp_code` VARCHAR(255) NULL, - `rsp_time` bigint(13) NULL DEFAULT NULL -); \ No newline at end of file +ALTER TABLE api_scenario_report_result ADD `base_info` LONGTEXT NULL; \ No newline at end of file