fix: 接口定义导入用例id重复
This commit is contained in:
parent
bc12d5573d
commit
1260687c9f
|
@ -497,7 +497,14 @@ public class ApiDefinitionService {
|
|||
SaveApiTestCaseRequest checkRequest = new SaveApiTestCaseRequest();
|
||||
if (CollectionUtils.isNotEmpty(cases)) {
|
||||
int batchCount = 0;
|
||||
cases.forEach(item -> {
|
||||
int nextNum = 0;
|
||||
for (int i = 0; i < cases.size(); i++) {
|
||||
ApiTestCaseWithBLOBs item = cases.get(i);
|
||||
if (i == 0) {
|
||||
nextNum = apiTestCaseService.getNextNum(item.getApiDefinitionId());
|
||||
} else {
|
||||
nextNum ++;
|
||||
}
|
||||
checkRequest.setName(item.getName());
|
||||
checkRequest.setApiDefinitionId(item.getApiDefinitionId());
|
||||
if (!apiTestCaseService.hasSameCase(checkRequest)) {
|
||||
|
@ -507,10 +514,10 @@ public class ApiDefinitionService {
|
|||
item.setCreateUserId(SessionUtils.getUserId());
|
||||
item.setUpdateUserId(SessionUtils.getUserId());
|
||||
item.setProjectId(SessionUtils.getCurrentProjectId());
|
||||
item.setNum(getNextNum(item.getApiDefinitionId()));
|
||||
item.setNum(nextNum);
|
||||
apiTestCaseMapper.insert(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (batchCount % 300 == 0) {
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
|
|
@ -325,7 +325,7 @@ public class ApiTestCaseService {
|
|||
return test;
|
||||
}
|
||||
|
||||
private int getNextNum(String definitionId) {
|
||||
public int getNextNum(String definitionId) {
|
||||
ApiTestCase apiTestCase = extApiTestCaseMapper.getNextNum(definitionId);
|
||||
if (apiTestCase == null) {
|
||||
int n = apiDefinitionMapper.selectByPrimaryKey(definitionId).getNum();
|
||||
|
|
Loading…
Reference in New Issue