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 createUser;
|
||||||
private String updateUser;
|
private String updateUser;
|
||||||
private String execResult;
|
private String execResult;
|
||||||
|
private String apiMethod;
|
||||||
private Long execTime;
|
private Long execTime;
|
||||||
private boolean active = false;
|
private boolean active = false;
|
||||||
private boolean responseActive = false;
|
private boolean responseActive = false;
|
||||||
|
|
|
@ -792,7 +792,7 @@ public class ApiDefinitionService {
|
||||||
res.setCaseStatus("-");
|
res.setCaseStatus("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.equals("ESB", res.getMethod())) {
|
if (StringUtils.equalsIgnoreCase("esb", res.getMethod())) {
|
||||||
esbApiParamService.handleApiEsbParams(res);
|
esbApiParamService.handleApiEsbParams(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,10 @@ public class ApiTestCaseService {
|
||||||
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
|
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
|
||||||
|
|
||||||
for (ApiTestCaseResult res : returnList) {
|
for (ApiTestCaseResult res : returnList) {
|
||||||
|
if(StringUtils.equalsIgnoreCase(res.getApiMethod(),"esb")){
|
||||||
esbApiParamService.handleApiEsbParams(res);
|
esbApiParamService.handleApiEsbParams(res);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,9 +147,13 @@ public class ApiTestCaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiTestCaseWithBLOBs get(String id) {
|
public ApiTestCaseWithBLOBs get(String id) {
|
||||||
ApiTestCaseWithBLOBs returnBlobs = apiTestCaseMapper.selectByPrimaryKey(id);
|
// ApiTestCaseWithBLOBs returnBlobs = apiTestCaseMapper.selectByPrimaryKey(id);
|
||||||
esbApiParamService.handleApiEsbParams(returnBlobs);
|
ApiTestCaseInfo model = extApiTestCaseMapper.selectApiCaseInfoByPrimaryKey(id);
|
||||||
return returnBlobs;
|
if(StringUtils.equalsIgnoreCase(model.getApiMethod(),"esb")){
|
||||||
|
esbApiParamService.handleApiEsbParams(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiTestCase create(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
|
public ApiTestCase create(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
|
||||||
|
@ -440,10 +446,12 @@ public class ApiTestCaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getRequest(ApiTestCaseRequest request) {
|
public Map<String, String> getRequest(ApiTestCaseRequest request) {
|
||||||
List<ApiTestCaseWithBLOBs> list = extApiTestCaseMapper.getRequest(request);
|
List<ApiTestCaseInfo> list = extApiTestCaseMapper.getRequest(request);
|
||||||
for (ApiTestCaseWithBLOBs model : list) {
|
for (ApiTestCaseInfo model : list) {
|
||||||
|
if(StringUtils.equalsIgnoreCase(model.getApiMethod(),"esb")){
|
||||||
esbApiParamService.handleApiEsbParams(model);
|
esbApiParamService.handleApiEsbParams(model);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return list.stream().collect(Collectors.toMap(ApiTestCaseWithBLOBs::getId, ApiTestCaseWithBLOBs::getRequest));
|
return list.stream().collect(Collectors.toMap(ApiTestCaseWithBLOBs::getId, ApiTestCaseWithBLOBs::getRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,9 @@ public class EsbApiParamService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleApiEsbParams(ApiDefinitionResult res) {
|
public void handleApiEsbParams(ApiDefinitionResult res) {
|
||||||
|
if(res == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
||||||
if (esbParamBlobs == null) {
|
if (esbParamBlobs == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -141,6 +144,9 @@ public class EsbApiParamService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleApiEsbParams(ApiTestCaseWithBLOBs res) {
|
public void handleApiEsbParams(ApiTestCaseWithBLOBs res) {
|
||||||
|
if(res==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
||||||
if (esbParamBlobs == null) {
|
if (esbParamBlobs == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -184,6 +190,9 @@ public class EsbApiParamService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleApiEsbParams(ApiTestCaseResult res) {
|
public void handleApiEsbParams(ApiTestCaseResult res) {
|
||||||
|
if(res == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
|
||||||
if (esbParamBlobs == null) {
|
if (esbParamBlobs == null) {
|
||||||
return;
|
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) {
|
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.datacount.ApiDataCountResult;
|
||||||
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
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.ApiTestCaseRequest;
|
||||||
import io.metersphere.api.dto.definition.ApiTestCaseResult;
|
import io.metersphere.api.dto.definition.ApiTestCaseResult;
|
||||||
import io.metersphere.base.domain.ApiTestCase;
|
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.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface ExtApiTestCaseMapper {
|
public interface ExtApiTestCaseMapper {
|
||||||
|
|
||||||
|
@ -27,7 +24,9 @@ public interface ExtApiTestCaseMapper {
|
||||||
|
|
||||||
long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
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);
|
ApiTestCase getNextNum(@Param("definitionId") String definitionId);
|
||||||
|
|
||||||
|
ApiTestCaseInfo selectApiCaseInfoByPrimaryKey(String id);
|
||||||
}
|
}
|
|
@ -196,13 +196,25 @@
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</sql>
|
</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 id="list" resultType="io.metersphere.api.dto.definition.ApiTestCaseResult">
|
||||||
SELECT
|
SELECT
|
||||||
t1.*,
|
t1.*,
|
||||||
t2.STATUS AS execResult,
|
t2.STATUS AS execResult,
|
||||||
t2.create_time AS execTime,
|
t2.create_time AS execTime,
|
||||||
u2.NAME AS createUser,
|
u2.NAME AS createUser,
|
||||||
u1.NAME AS updateUser
|
u1.NAME AS updateUser,
|
||||||
|
a.method AS apiMethod
|
||||||
FROM
|
FROM
|
||||||
api_test_case t1
|
api_test_case t1
|
||||||
LEFT JOIN api_definition_exec_result t2 ON t1.last_result_id = t2.id
|
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}
|
AND testCase.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getRequest" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
<select id="getRequest" resultType="io.metersphere.api.dto.definition.ApiTestCaseInfo">
|
||||||
select id, request
|
select t1.id, t1.request,a.method AS apiMethod
|
||||||
from api_test_case
|
from api_test_case t1
|
||||||
|
inner join api_definition a on t1.api_definition_id = a.id
|
||||||
where 1
|
where 1
|
||||||
<if test="request.id != null and request.id!=''">
|
<if test="request.id != null and request.id!=''">
|
||||||
and id = #{request.id}
|
and t1.id = #{request.id}
|
||||||
</if>
|
</if>
|
||||||
<if test="request.ids != null and request.ids.size() > 0">
|
<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=")">
|
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||||
#{caseId}
|
#{caseId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
Loading…
Reference in New Issue