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

This commit is contained in:
chenjianxing 2022-01-26 16:24:41 +08:00 committed by shiziyuan9527
parent 4374f42aa3
commit 35d3330b14
1 changed files with 7 additions and 2 deletions

View File

@ -254,11 +254,16 @@ public class TestCaseService {
} }
private void checkCustomNumExist(TestCaseWithBLOBs testCase) { private void checkCustomNumExist(TestCaseWithBLOBs testCase) {
String id = testCase.getId();
TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(id);
TestCaseExample example = new TestCaseExample(); TestCaseExample example = new TestCaseExample();
example.createCriteria() TestCaseExample.Criteria criteria = example.createCriteria();
.andCustomNumEqualTo(testCase.getCustomNum()) criteria.andCustomNumEqualTo(testCase.getCustomNum())
.andProjectIdEqualTo(testCase.getProjectId()) .andProjectIdEqualTo(testCase.getProjectId())
.andIdNotEqualTo(testCase.getId()); .andIdNotEqualTo(testCase.getId());
if (testCaseWithBLOBs != null && StringUtils.isNotBlank(testCaseWithBLOBs.getRefId())) {
criteria.andRefIdNotEqualTo(testCaseWithBLOBs.getRefId());
}
List<TestCase> list = testCaseMapper.selectByExample(example); List<TestCase> list = testCaseMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
MSException.throwException(Translator.get("custom_num_is_exist")); MSException.throwException(Translator.get("custom_num_is_exist"));