fix: 场景性能优化:针对案例进行请求方式查询,如果是ESB的案例,便加载tree结构数据
场景性能优化:针对案例进行请求方式查询,如果是ESB的案例,便加载tree结构数据
This commit is contained in:
parent
955e911dd9
commit
1c8afc7f55
|
@ -11,6 +11,7 @@ public class ApiTestCaseResult extends ApiTestCaseWithBLOBs {
|
|||
private String createUser;
|
||||
private String updateUser;
|
||||
private String execResult;
|
||||
private String apiMethod;
|
||||
private Long execTime;
|
||||
private boolean active = false;
|
||||
private boolean responseActive = false;
|
||||
|
|
|
@ -792,7 +792,7 @@ public class ApiDefinitionService {
|
|||
res.setCaseStatus("-");
|
||||
}
|
||||
|
||||
if (StringUtils.equals("ESB", res.getMethod())) {
|
||||
if (StringUtils.equalsIgnoreCase("esb", res.getMethod())) {
|
||||
esbApiParamService.handleApiEsbParams(res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,8 +85,10 @@ public class ApiTestCaseService {
|
|||
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
|
||||
|
||||
for (ApiTestCaseResult res : returnList) {
|
||||
if(StringUtils.equalsIgnoreCase(res.getApiMethod(),"esb")){
|
||||
esbApiParamService.handleApiEsbParams(res);
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
|
@ -145,9 +147,13 @@ public class ApiTestCaseService {
|
|||
}
|
||||
|
||||
public ApiTestCaseWithBLOBs get(String id) {
|
||||
ApiTestCaseWithBLOBs returnBlobs = apiTestCaseMapper.selectByPrimaryKey(id);
|
||||
esbApiParamService.handleApiEsbParams(returnBlobs);
|
||||
return returnBlobs;
|
||||
// ApiTestCaseWithBLOBs returnBlobs = apiTestCaseMapper.selectByPrimaryKey(id);
|
||||
ApiTestCaseInfo model = extApiTestCaseMapper.selectApiCaseInfoByPrimaryKey(id);
|
||||
if(StringUtils.equalsIgnoreCase(model.getApiMethod(),"esb")){
|
||||
esbApiParamService.handleApiEsbParams(model);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public ApiTestCase create(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
|
||||
|
@ -440,10 +446,12 @@ public class ApiTestCaseService {
|
|||
}
|
||||
|
||||
public Map<String, String> getRequest(ApiTestCaseRequest request) {
|
||||
List<ApiTestCaseWithBLOBs> list = extApiTestCaseMapper.getRequest(request);
|
||||
for (ApiTestCaseWithBLOBs model : list) {
|
||||
List<ApiTestCaseInfo> list = extApiTestCaseMapper.getRequest(request);
|
||||
for (ApiTestCaseInfo model : list) {
|
||||
if(StringUtils.equalsIgnoreCase(model.getApiMethod(),"esb")){
|
||||
esbApiParamService.handleApiEsbParams(model);
|
||||
}
|
||||
}
|
||||
return list.stream().collect(Collectors.toMap(ApiTestCaseWithBLOBs::getId, ApiTestCaseWithBLOBs::getRequest));
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,9 @@ public class EsbApiParamService {
|
|||
}
|
||||
|
||||
public void handleApiEsbParams(ApiDefinitionResult res) {
|
||||
if(res == null){
|
||||
return;
|
||||
}
|
||||
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
||||
if (esbParamBlobs == null) {
|
||||
return;
|
||||
|
@ -141,6 +144,9 @@ public class EsbApiParamService {
|
|||
}
|
||||
|
||||
public void handleApiEsbParams(ApiTestCaseWithBLOBs res) {
|
||||
if(res==null){
|
||||
return;
|
||||
}
|
||||
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
||||
if (esbParamBlobs == null) {
|
||||
return;
|
||||
|
@ -184,6 +190,9 @@ public class EsbApiParamService {
|
|||
}
|
||||
|
||||
public void handleApiEsbParams(ApiTestCaseResult res) {
|
||||
if(res == null){
|
||||
return;
|
||||
}
|
||||
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
||||
if (esbParamBlobs == null) {
|
||||
return;
|
||||
|
@ -195,20 +204,6 @@ public class EsbApiParamService {
|
|||
}
|
||||
|
||||
}
|
||||
// try {
|
||||
// if (StringUtils.isNotEmpty(res.getRequest())) {
|
||||
// JSONObject jsonObj = JSONObject.parseObject(res.getRequest());
|
||||
// JSONArray esbDataArray = JSONArray.parseArray(esbParamBlobs.getDataStruct());
|
||||
// jsonObj.put("esbDataStruct", esbDataArray);
|
||||
// jsonObj.put("esbFrontedScript", esbParamBlobs.getFrontedScript());
|
||||
//
|
||||
// JSONArray responseDataArray = JSONArray.parseArray(esbParamBlobs.getResponseDataStruct());
|
||||
// jsonObj.put("backEsbDataStruct", responseDataArray);
|
||||
//
|
||||
// res.setRequest(jsonObj.toJSONString());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// }
|
||||
}
|
||||
|
||||
public SaveApiDefinitionRequest updateEsbRequest(SaveApiDefinitionRequest request) {
|
||||
|
|
|
@ -2,16 +2,13 @@ package io.metersphere.base.mapper.ext;
|
|||
|
||||
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseInfo;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseResult;
|
||||
import io.metersphere.base.domain.ApiTestCase;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExtApiTestCaseMapper {
|
||||
|
||||
|
@ -27,7 +24,9 @@ public interface ExtApiTestCaseMapper {
|
|||
|
||||
long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
|
||||
List<ApiTestCaseWithBLOBs> getRequest(@Param("request") ApiTestCaseRequest request);
|
||||
List<ApiTestCaseInfo> getRequest(@Param("request") ApiTestCaseRequest request);
|
||||
|
||||
ApiTestCase getNextNum(@Param("definitionId") String definitionId);
|
||||
|
||||
ApiTestCaseInfo selectApiCaseInfoByPrimaryKey(String id);
|
||||
}
|
|
@ -196,13 +196,25 @@
|
|||
</if>
|
||||
|
||||
</sql>
|
||||
|
||||
<select id="selectApiCaseInfoByPrimaryKey" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
||||
SELECT
|
||||
t1.*,
|
||||
a.method AS apiMethod
|
||||
FROM
|
||||
api_test_case t1
|
||||
inner join api_definition a on t1.api_definition_id = a.id
|
||||
WHERE t1.id = #{0}
|
||||
</select>
|
||||
|
||||
<select id="list" resultType="io.metersphere.api.dto.definition.ApiTestCaseResult">
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.STATUS AS execResult,
|
||||
t2.create_time AS execTime,
|
||||
u2.NAME AS createUser,
|
||||
u1.NAME AS updateUser
|
||||
u1.NAME AS updateUser,
|
||||
a.method AS apiMethod
|
||||
FROM
|
||||
api_test_case t1
|
||||
LEFT JOIN api_definition_exec_result t2 ON t1.last_result_id = t2.id
|
||||
|
@ -361,15 +373,16 @@
|
|||
AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
|
||||
</select>
|
||||
|
||||
<select id="getRequest" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
||||
select id, request
|
||||
from api_test_case
|
||||
<select id="getRequest" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
||||
select t1.id, t1.request,a.method AS apiMethod
|
||||
from api_test_case t1
|
||||
inner join api_definition a on t1.api_definition_id = a.id
|
||||
where 1
|
||||
<if test="request.id != null and request.id!=''">
|
||||
and id = #{request.id}
|
||||
and t1.id = #{request.id}
|
||||
</if>
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
and id in
|
||||
and t1.id in
|
||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
|
|
Loading…
Reference in New Issue