fix(接口测试): 解决未选模块不覆盖时接口重复导入时用例导入报错问题以及接口导入查询重复数据时排除已删除状态
--user=郭雨琦 --bug=1014659 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014659 【接口测试】sql协议导入jmeter文件,接口删除后,再次导入相同的文件,提示格式错误 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014649 【接口测试】sql协议导入的文件删除后,再次导入文件导入失败
This commit is contained in:
parent
8c7a6652bd
commit
b9d96cf60c
|
@ -271,7 +271,7 @@ public class ApiScenarioImportUtil {
|
|||
apiTestCase.setUpdateTime(System.currentTimeMillis());
|
||||
apiTestCase.setVersionId(apiDefinition.getVersionId());
|
||||
apiTestCase.setPriority("P0");
|
||||
apiTestCase.setNum(testCaseService.getNextNum(apiTestCase.getApiDefinitionId(), apiDefinition.getNum() + i));
|
||||
apiTestCase.setNum(testCaseService.getNextNum(apiTestCase.getApiDefinitionId(), apiDefinition.getNum() + i, projectId));
|
||||
object.put("id", apiTestCase.getId());
|
||||
object.put("resourceId", apiTestCase.getId());
|
||||
object.put("projectId", projectId);
|
||||
|
|
|
@ -1113,7 +1113,7 @@ public class ApiDefinitionService {
|
|||
if (sameCase == null) {
|
||||
apiTestCase.setId(UUID.randomUUID().toString());
|
||||
apiTestCase.setStatus("");
|
||||
apiTestCase.setNum(apiTestCaseService.getNextNum(apiTestCase.getApiDefinitionId(), apiDefinition.getNum()));
|
||||
apiTestCase.setNum(apiTestCaseService.getNextNum(apiTestCase.getApiDefinitionId(), apiDefinition.getNum(), apiDefinition.getProjectId()));
|
||||
apiTestCase.setCreateTime(System.currentTimeMillis());
|
||||
apiTestCase.setUpdateTime(System.currentTimeMillis());
|
||||
apiTestCase.setCreateUserId(SessionUtils.getUserId());
|
||||
|
|
|
@ -111,6 +111,8 @@ public class ApiTestCaseService {
|
|||
private TcpApiParamService tcpApiParamService;
|
||||
@Resource
|
||||
private ObjectMapper mapper;
|
||||
@Resource
|
||||
private ExtApiDefinitionMapper extApiDefinitionMapper;
|
||||
|
||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||
|
||||
|
@ -471,25 +473,43 @@ public class ApiTestCaseService {
|
|||
|
||||
public int getNextNum(String definitionId) {
|
||||
ApiTestCase apiTestCase = extApiTestCaseMapper.getNextNum(definitionId);
|
||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(definitionId);
|
||||
if (apiTestCase == null) {
|
||||
int n = apiDefinitionMapper.selectByPrimaryKey(definitionId).getNum();
|
||||
int n = apiDefinitionWithBLOBs.getNum();
|
||||
return n * 1000 + 1;
|
||||
} else {
|
||||
return Optional.of(apiTestCase.getNum() + 1)
|
||||
.orElse(apiDefinitionMapper.selectByPrimaryKey(definitionId).getNum() * 1000 + 1);
|
||||
.orElse(apiDefinitionWithBLOBs.getNum() * 1000 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public int getNextNum(String definitionId, Integer definitionNum) {
|
||||
public int getNextNum(String definitionId, Integer definitionNum, String projectId) {
|
||||
ApiTestCase apiTestCase = extApiTestCaseMapper.getNextNum(definitionId);
|
||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(definitionId);
|
||||
int apiDefinitionNum;
|
||||
if (apiDefinitionWithBLOBs != null && apiDefinitionWithBLOBs.getNum() != null) {
|
||||
apiDefinitionNum = apiDefinitionWithBLOBs.getNum() * 1000 + 1;
|
||||
} else {
|
||||
apiDefinitionNum = getNextNumByProjectId(projectId);
|
||||
}
|
||||
if (apiTestCase == null) {
|
||||
if (definitionNum == null) {
|
||||
return apiDefinitionMapper.selectByPrimaryKey(definitionId).getNum() * 1000 + 1;
|
||||
return apiDefinitionNum;
|
||||
|
||||
}
|
||||
return definitionNum * 1000 + 1;
|
||||
} else {
|
||||
return Optional.of(apiTestCase.getNum() + 1)
|
||||
.orElse(apiDefinitionMapper.selectByPrimaryKey(definitionId).getNum() * 1000 + 1);
|
||||
.orElse(apiDefinitionNum);
|
||||
}
|
||||
}
|
||||
|
||||
public int getNextNumByProjectId(String projectId) {
|
||||
ApiDefinition apiDefinition = extApiDefinitionMapper.getNextNum(projectId);
|
||||
if (apiDefinition == null || apiDefinition.getNum() == null) {
|
||||
return 100001;
|
||||
} else {
|
||||
return Optional.of(apiDefinition.getNum() + 1).orElse(100001);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1022,6 +1022,7 @@
|
|||
#{versionId}
|
||||
</foreach>
|
||||
and protocol = #{protocol}
|
||||
and status != 'Trash'
|
||||
</select>
|
||||
<sql id="Same_Where_Clause">
|
||||
<where>
|
||||
|
|
Loading…
Reference in New Issue