fix api测试保存

This commit is contained in:
chenjianxing 2020-06-03 11:44:27 +08:00
parent 572f53d1d4
commit 0a0b048b67
1 changed files with 3 additions and 13 deletions

View File

@ -139,7 +139,9 @@ public class APITestService {
if (apiTest.getName() != null) {
ApiTestExample example = new ApiTestExample();
example.createCriteria()
.andNameEqualTo(apiTest.getName());
.andNameEqualTo(apiTest.getName())
.andProjectIdEqualTo(apiTest.getProjectId())
.andIdNotEqualTo(apiTest.getId());
if (apiTestMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("api_test_name_already_exists"));
}
@ -162,22 +164,10 @@ public class APITestService {
test.setUpdateTime(System.currentTimeMillis());
test.setStatus(APITestStatus.Saved.name());
test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
checkApiTestPlanExist(test);
apiTestMapper.insert(test);
return test;
}
private void checkApiTestPlanExist(ApiTest apiTest) {
if (apiTest.getName() != null) {
ApiTestExample example = new ApiTestExample();
example.createCriteria()
.andNameEqualTo(apiTest.getName());
if (apiTestMapper.selectByExample(example).size() > 0) {
MSException.throwException(Translator.get("api_test_name_already_exists"));
}
}
}
private void saveFile(String testId, List<MultipartFile> files) {
files.forEach(file -> {
final FileMetadata fileMetadata = fileService.saveFile(file);