fix(接口测试): 优化场景报告步骤的基础信息存储结构 (#12442)

优化场景报告步骤的基础信息存储结构

Co-authored-by: song-tianyang <tianyang.song@fit2cloud.com>
This commit is contained in:
MeterSphere Bot 2022-04-09 17:36:56 +08:00 committed by GitHub
parent 4be30f60c9
commit 2465587992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 123 additions and 593 deletions

View File

@ -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;
}

View File

@ -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());
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(requestResult.getRspCode());
responseResult.setResponseTime(requestResult.getRspTime());
responseResult.setResponseCode(dto.getRspCode());
responseResult.setResponseTime(dto.getRspTime());
this.setResponseResult(responseResult);
}catch (Exception e){
LogUtil.error("Parse report base-info error :"+ e.getMessage());
}
}
}
}

View File

@ -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) {
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) {

View File

@ -274,15 +274,15 @@ public class ApiScenarioReportStructureService {
}
}
public void reportFormatting(List<StepTreeDTO> dtoList, Map<String, List<ApiScenarioReportResult>> maps) {
public void reportFormatting(List<StepTreeDTO> dtoList, Map<String, List<ApiScenarioReportResultWithBLOBs>> maps) {
for (int index = 0; index < dtoList.size(); index++) {
StepTreeDTO dto = dtoList.get(index);
dto.setIndex((index + 1));
List<ApiScenarioReportResult> reportResults = maps.get(dto.getResourceId());
List<ApiScenarioReportResultWithBLOBs> 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<ApiScenarioReportResult> reportResults = null;
List<ApiScenarioReportResultWithBLOBs> 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<StepTreeDTO> stepList = JSONArray.parseArray(new String(scenarioReportStructure.getResourceTree(), StandardCharsets.UTF_8), StepTreeDTO.class);
// 匹配结果
Map<String, List<ApiScenarioReportResult>> maps = reportResults.stream().collect(Collectors.groupingBy(ApiScenarioReportResult::getResourceId));
Map<String, List<ApiScenarioReportResultWithBLOBs>> 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<ApiScenarioReportResult> selectBaseInfoResultByReportId(String reportId) {
private List<ApiScenarioReportResultWithBLOBs> selectBaseInfoResultByReportId(String reportId) {
return extApiScenarioReportResultMapper.selectBaseInfoResultByReportId(reportId);
}
@ -582,11 +582,11 @@ public class ApiScenarioReportStructureService {
*
* @param reportResults
*/
private void removeUiResultIfNotStep(List<ApiScenarioReportResult> reportResults) {
private void removeUiResultIfNotStep(List<ApiScenarioReportResultWithBLOBs> reportResults) {
if(CollectionUtils.isNotEmpty(reportResults)){
Iterator<ApiScenarioReportResult> iterator = reportResults.iterator();
Iterator<ApiScenarioReportResultWithBLOBs> 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;

View File

@ -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;
}

View File

@ -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<String> values) {
addCriterion("req_name in", values, "reqName");
return (Criteria) this;
}
public Criteria andReqNameNotIn(List<String> 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<Boolean> values) {
addCriterion("req_success in", values, "reqSuccess");
return (Criteria) this;
}
public Criteria andReqSuccessNotIn(List<Boolean> 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<Integer> values) {
addCriterion("req_error in", values, "reqError");
return (Criteria) this;
}
public Criteria andReqErrorNotIn(List<Integer> 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<Long> values) {
addCriterion("req_start_time in", values, "reqStartTime");
return (Criteria) this;
}
public Criteria andReqStartTimeNotIn(List<Long> 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<String> values) {
addCriterion("rsp_code in", values, "rspCode");
return (Criteria) this;
}
public Criteria andRspCodeNotIn(List<String> 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<Long> values) {
addCriterion("rsp_time in", values, "rspTime");
return (Criteria) this;
}
public Criteria andRspTimeNotIn(List<Long> 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 {

View File

@ -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;
}

View File

@ -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<ApiScenarioReportResult> selectByExampleWithBLOBs(ApiScenarioReportResultExample example);
List<ApiScenarioReportResultWithBLOBs> selectByExampleWithBLOBs(ApiScenarioReportResultExample example);
List<ApiScenarioReportResult> 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);
}

View File

@ -11,15 +11,10 @@
<result column="total_assertions" jdbcType="BIGINT" property="totalAssertions" />
<result column="pass_assertions" jdbcType="BIGINT" property="passAssertions" />
<result column="error_code" jdbcType="VARCHAR" property="errorCode" />
<result column="req_name" jdbcType="VARCHAR" property="reqName" />
<result column="req_success" jdbcType="BIT" property="reqSuccess" />
<result column="req_error" jdbcType="INTEGER" property="reqError" />
<result column="req_start_time" jdbcType="BIGINT" property="reqStartTime" />
<result column="rsp_code" jdbcType="VARCHAR" property="rspCode" />
<result column="rsp_time" jdbcType="BIGINT" property="rspTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioReportResult">
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs">
<result column="content" jdbcType="LONGVARBINARY" property="content" />
<result column="base_info" jdbcType="LONGVARCHAR" property="baseInfo" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -81,11 +76,10 @@
</sql>
<sql id="Base_Column_List">
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
</sql>
<sql id="Blob_Column_List">
content
content, base_info
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiScenarioReportResultExample" resultMap="ResultMapWithBLOBs">
select
@ -135,21 +129,17 @@
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.ApiScenarioReportResult">
<insert id="insert" parameterType="io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs">
insert into api_scenario_report_result (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,
content)
content, base_info)
values (#{id,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{requestTime,jdbcType=BIGINT},
#{totalAssertions,jdbcType=BIGINT}, #{passAssertions,jdbcType=BIGINT}, #{errorCode,jdbcType=VARCHAR},
#{reqName,jdbcType=VARCHAR}, #{reqSuccess,jdbcType=BIT}, #{reqError,jdbcType=INTEGER},
#{reqStartTime,jdbcType=BIGINT}, #{rspCode,jdbcType=VARCHAR}, #{rspTime,jdbcType=BIGINT},
#{content,jdbcType=LONGVARBINARY})
#{content,jdbcType=LONGVARBINARY}, #{baseInfo,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioReportResult">
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs">
insert into api_scenario_report_result
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -179,27 +169,12 @@
<if test="errorCode != null">
error_code,
</if>
<if test="reqName != null">
req_name,
</if>
<if test="reqSuccess != null">
req_success,
</if>
<if test="reqError != null">
req_error,
</if>
<if test="reqStartTime != null">
req_start_time,
</if>
<if test="rspCode != null">
rsp_code,
</if>
<if test="rspTime != null">
rsp_time,
</if>
<if test="content != null">
content,
</if>
<if test="baseInfo != null">
base_info,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -229,27 +204,12 @@
<if test="errorCode != null">
#{errorCode,jdbcType=VARCHAR},
</if>
<if test="reqName != null">
#{reqName,jdbcType=VARCHAR},
</if>
<if test="reqSuccess != null">
#{reqSuccess,jdbcType=BIT},
</if>
<if test="reqError != null">
#{reqError,jdbcType=INTEGER},
</if>
<if test="reqStartTime != null">
#{reqStartTime,jdbcType=BIGINT},
</if>
<if test="rspCode != null">
#{rspCode,jdbcType=VARCHAR},
</if>
<if test="rspTime != null">
#{rspTime,jdbcType=BIGINT},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARBINARY},
</if>
<if test="baseInfo != null">
#{baseInfo,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiScenarioReportResultExample" resultType="java.lang.Long">
@ -288,27 +248,12 @@
<if test="record.errorCode != null">
error_code = #{record.errorCode,jdbcType=VARCHAR},
</if>
<if test="record.reqName != null">
req_name = #{record.reqName,jdbcType=VARCHAR},
</if>
<if test="record.reqSuccess != null">
req_success = #{record.reqSuccess,jdbcType=BIT},
</if>
<if test="record.reqError != null">
req_error = #{record.reqError,jdbcType=INTEGER},
</if>
<if test="record.reqStartTime != null">
req_start_time = #{record.reqStartTime,jdbcType=BIGINT},
</if>
<if test="record.rspCode != null">
rsp_code = #{record.rspCode,jdbcType=VARCHAR},
</if>
<if test="record.rspTime != null">
rsp_time = #{record.rspTime,jdbcType=BIGINT},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARBINARY},
</if>
<if test="record.baseInfo != null">
base_info = #{record.baseInfo,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiScenarioReportResult">
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs">
update api_scenario_report_result
<set>
<if test="resourceId != null">
@ -384,31 +318,16 @@
<if test="errorCode != null">
error_code = #{errorCode,jdbcType=VARCHAR},
</if>
<if test="reqName != null">
req_name = #{reqName,jdbcType=VARCHAR},
</if>
<if test="reqSuccess != null">
req_success = #{reqSuccess,jdbcType=BIT},
</if>
<if test="reqError != null">
req_error = #{reqError,jdbcType=INTEGER},
</if>
<if test="reqStartTime != null">
req_start_time = #{reqStartTime,jdbcType=BIGINT},
</if>
<if test="rspCode != null">
rsp_code = #{rspCode,jdbcType=VARCHAR},
</if>
<if test="rspTime != null">
rsp_time = #{rspTime,jdbcType=BIGINT},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARBINARY},
</if>
<if test="baseInfo != null">
base_info = #{baseInfo,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiScenarioReportResult">
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs">
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}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiScenarioReportResult">
@ -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}
</update>
</mapper>

View File

@ -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<ApiScenarioReportResult> selectBaseInfoResultByReportId(String reportId);
List<ApiScenarioReportResultWithBLOBs> selectBaseInfoResultByReportId(String reportId);
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.ext.ExtApiScenarioReportResultMapper">
<select id="selectBaseInfoResultByReportId" resultType="io.metersphere.base.domain.ApiScenarioReportResult">
<select id="selectBaseInfoResultByReportId" resultType="io.metersphere.base.domain.ApiScenarioReportResultWithBLOBs">
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}
</select>

View File

@ -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
);
ALTER TABLE api_scenario_report_result ADD `base_info` LONGTEXT NULL;