fix(接口测试): 修复case列表重复数据的缺陷

--bug=1013292 --user=王孝刚 【接口测试】接口CASE列重复显示CASE
https://www.tapd.cn/55049933/s/1170470
This commit is contained in:
wxg0103 2022-05-31 18:31:05 +08:00 committed by f2c-ci-robot[bot]
parent a1e7520c0d
commit 8feab21acd
3 changed files with 25 additions and 11 deletions

View File

@ -350,16 +350,7 @@ public class ApiTestCaseService {
}
public ApiTestCase getSameCase(SaveApiTestCaseRequest request) {
ApiTestCaseExample example = new ApiTestCaseExample();
ApiTestCaseExample.Criteria criteria = example.createCriteria();
criteria.andStatusNotEqualTo("Trash").andNameEqualTo(request.getName()).andApiDefinitionIdEqualTo(request.getApiDefinitionId());
if (StringUtils.isNotBlank(request.getId())) {
criteria.andIdNotEqualTo(request.getId());
}
if (StringUtils.isNotBlank(request.getVersionId())) {
criteria.andVersionIdEqualTo(request.getVersionId());
}
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
List<ApiTestCase> apiTestCases = extApiTestCaseMapper.checkName(request);
if (CollectionUtils.isNotEmpty(apiTestCases)) {
return apiTestCases.get(0);
}

View File

@ -74,4 +74,6 @@ public interface ExtApiTestCaseMapper {
List<ParamsDTO> getApiCaseEnvironments(@Param("caseIds") List<String> caseIds);
void insertNewVersionCases(@Param("api") ApiDefinition apiDefinition, @Param("old") ApiDefinition old);
List<ApiTestCase> checkName(@Param("request") SaveApiTestCaseRequest request);
}

View File

@ -780,7 +780,28 @@
</foreach>
</select>
<select id="getApiCaseEnvironment" resultType="java.lang.String">
select JSON_UNQUOTE(JSON_EXTRACT(request, '$.useEnvironment')) from api_test_case where id = #{caseId}
select JSON_UNQUOTE(JSON_EXTRACT(request, '$.useEnvironment'))
from api_test_case
where id = #{caseId}
</select>
<select id="checkName" resultType="io.metersphere.base.domain.ApiTestCase">
select * from api_test_case
<where>
(api_test_case.status is null or api_test_case.status != 'Trash')
<if test="request.name !='' || request.name != null">
and name =#{request.name}
</if>
<if test="request.apiDefinitionId !='' || request.apiDefinitionId != null">
and api_definition_id =#{request.apiDefinitionId}
</if>
<if test="request.id !='' || request.id != null">
and id !=#{request.id}
</if>
<if test="request.versionId !='' || request.versionId != null">
and version_id =#{request.versionId}
</if>
</where>
</select>
<update id="deleteToGc" parameterType="io.metersphere.api.dto.definition.ApiTestCaseRequest">
update api_test_case