diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index 842cad4825..33ca262ce5 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -95,7 +95,7 @@ public class APITestController { @PostMapping(value = "/import", consumes = {"multipart/form-data"}) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) - public ApiTest testCaseImport(@RequestPart(value = "file") MultipartFile file, @RequestPart("request") ApiTestImportRequest request) { + public ApiTest testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) { return apiTestService.apiTestImport(file, request); } diff --git a/backend/src/main/java/io/metersphere/api/parse/MsParser.java b/backend/src/main/java/io/metersphere/api/parse/MsParser.java index 19fbb002de..c562f6c2ca 100644 --- a/backend/src/main/java/io/metersphere/api/parse/MsParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/MsParser.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.metersphere.api.dto.ApiTestImportRequest; import io.metersphere.api.dto.parse.ApiImport; +import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.commons.constants.MsRequestBodyType; import org.apache.commons.lang3.StringUtils; import org.eclipse.jetty.http.HttpMethod; @@ -38,6 +39,7 @@ public class MsParser extends ApiImportAbstractParser { requestsObject.keySet().forEach(requestName -> { JSONObject requestObject = requestsObject.getJSONObject(requestName); requestObject.put("name", requestName); + requestObject.put("type", RequestType.HTTP); JSONArray bodies = requestObject.getJSONArray("body"); if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodies != null) { StringBuilder bodyStr = new StringBuilder(); diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 2d26e31555..1f7705a64a 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -36,6 +36,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java index 99220cbdcd..49c9cce4c5 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java @@ -5,6 +5,7 @@ import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs; import io.metersphere.base.mapper.ApiTestEnvironmentMapper; import io.metersphere.commons.exception.MSException; import io.metersphere.i18n.Translator; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -34,6 +35,7 @@ public class ApiTestEnvironmentService { } public void update(ApiTestEnvironmentWithBLOBs apiTestEnvironment) { + checkEnvironmentExist(apiTestEnvironment); apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment); } @@ -47,9 +49,12 @@ public class ApiTestEnvironmentService { private void checkEnvironmentExist (ApiTestEnvironmentWithBLOBs environment) { if (environment.getName() != null) { ApiTestEnvironmentExample example = new ApiTestEnvironmentExample(); - example.createCriteria() - .andNameEqualTo(environment.getName()) + ApiTestEnvironmentExample.Criteria criteria = example.createCriteria(); + criteria.andNameEqualTo(environment.getName()) .andProjectIdEqualTo(environment.getProjectId()); + if (StringUtils.isNotBlank(environment.getId())) { + criteria.andIdNotEqualTo(environment.getId()); + } if (apiTestEnvironmentMapper.selectByExample(example).size() > 0) { MSException.throwException(Translator.get("api_test_environment_already_exists")); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml index 3e0f0b57fb..d502c3aa90 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml @@ -1,6 +1,100 @@ + + + + like CONCAT('%', #{${object}.value},'%') + + + not like CONCAT('%', #{${object}.value},'%') + + + in + + #{v} + + + + not in + + #{v} + + + + between #{${object}.value[0]} and #{${object}.value[1]} + + + > #{${object}.value} + + + < #{${object}.value} + + + >= #{${object}.value} + + + <= #{${object}.value} + + + = '${@io.metersphere.commons.utils.SessionUtils@getUserId()}' + + + = #{${object}.value} + + + + + + + and test_case.name + + + + + + and test_case.node_path + + + + + + and test_case.priority + + + + + + and test_case.create_time + + + + + + and test_case.type + + + + + + and test_case.update_time + + + + + + and test_case.method + + + + + + and test_case.maintainer + + + + +