fix(功能用例): 创建其他版本用例,提示ID已存在

This commit is contained in:
shiziyuan9527 2022-01-25 14:19:19 +08:00 committed by shiziyuan9527
parent 5257b536b7
commit 790cbcd0c3
1 changed files with 19 additions and 2 deletions

View File

@ -251,11 +251,16 @@ public class TestCaseService {
}
private void checkCustomNumExist(TestCaseWithBLOBs testCase) {
String id = testCase.getId();
TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(id);
TestCaseExample example = new TestCaseExample();
example.createCriteria()
.andCustomNumEqualTo(testCase.getCustomNum())
TestCaseExample.Criteria criteria = example.createCriteria();
criteria.andCustomNumEqualTo(testCase.getCustomNum())
.andProjectIdEqualTo(testCase.getProjectId())
.andIdNotEqualTo(testCase.getId());
if (testCaseWithBLOBs != null && StringUtils.isNotBlank(testCaseWithBLOBs.getRefId())) {
criteria.andRefIdNotEqualTo(testCaseWithBLOBs.getRefId());
}
List<TestCase> list = testCaseMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(list)) {
MSException.throwException(Translator.get("custom_num_is_exist"));
@ -282,6 +287,18 @@ public class TestCaseService {
example.getOredCriteria().get(0).andVersionIdEqualTo(testCase.getVersionId());
}
createNewVersionOrNot(testCase, example);
if (StringUtils.isNotBlank(testCase.getCustomNum()) && StringUtils.isNotBlank(testCase.getId())) {
TestCaseWithBLOBs caseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCase.getId());
if (caseWithBLOBs != null) {
example.clear();
example.createCriteria().andRefIdEqualTo(caseWithBLOBs.getRefId());
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
testCaseWithBLOBs.setCustomNum(testCase.getCustomNum());
testCaseMapper.updateByExampleSelective(testCaseWithBLOBs, example);
}
}
testCase.setLatest(null);
testCaseMapper.updateByPrimaryKeySelective(testCase);
return testCaseMapper.selectByPrimaryKey(testCase.getId());