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

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

View File

@ -254,11 +254,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"));