fix: 导入用户不校验名称

This commit is contained in:
chenjianxing 2020-07-16 18:50:45 +08:00
parent c16f60e87d
commit b29a4f9109
2 changed files with 3 additions and 14 deletions

View File

@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
@ -39,8 +40,6 @@ import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Resource;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class APITestService { public class APITestService {
@ -76,6 +75,7 @@ public class APITestService {
if (files == null || files.isEmpty()) { if (files == null || files.isEmpty()) {
throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
} }
checkNameExist(request);
ApiTest test = createTest(request); ApiTest test = createTest(request);
saveFile(test.getId(), files); saveFile(test.getId(), files);
} }
@ -173,12 +173,6 @@ public class APITestService {
} }
} }
private Boolean isNameExist(SaveAPITestRequest request) {
ApiTestExample example = new ApiTestExample();
example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
return apiTestMapper.countByExample(example) > 0;
}
private ApiTest updateTest(SaveAPITestRequest request) { private ApiTest updateTest(SaveAPITestRequest request) {
checkNameExist(request); checkNameExist(request);
final ApiTest test = new ApiTest(); final ApiTest test = new ApiTest();
@ -193,7 +187,6 @@ public class APITestService {
} }
private ApiTest createTest(SaveAPITestRequest request) { private ApiTest createTest(SaveAPITestRequest request) {
checkNameExist(request);
final ApiTest test = new ApiTest(); final ApiTest test = new ApiTest();
test.setId(request.getId()); test.setId(request.getId());
test.setName(request.getName()); test.setName(request.getName());
@ -290,10 +283,6 @@ public class APITestService {
request.setName(name.substring(0, name.length() - suffix.length())); request.setName(name.substring(0, name.length() - suffix.length()));
} }
} }
if (isNameExist(request)) {
request.setName(request.getName() + "_" + request.getId().substring(0, 5));
}
return request; return request;
} }
} }

View File

@ -255,7 +255,7 @@
return this.test.isValid() && !this.change; return this.test.isValid() && !this.change;
}, },
isDisabled() { isDisabled() {
return !(this.test.isValid()) && !this.change; return !(this.test.isValid() && this.change);
} }
}, },