From b8b5d7d1d31cadf8c07b1ea16f21d28471653d87 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 6 Nov 2020 18:24:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E7=89=88=E6=9C=AC=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/ApiDelimitController.java | 57 ++ .../api/controller/ApiModuleController.java | 4 +- .../api/controller/ApiTestCaseController.java | 46 ++ .../api/dto/delimit/ApiComputeResult.java | 13 + .../api/dto/delimit/ApiDelimitRequest.java | 27 + .../api/dto/delimit/ApiDelimitResult.java | 23 + .../api/dto/delimit/ApiTestCaseRequest.java | 21 + .../api/dto/delimit/ApiTestCaseResult.java | 15 + .../dto/delimit/SaveApiDelimitRequest.java | 41 + .../dto/delimit/SaveApiTestCaseRequest.java | 38 + .../api/dto/scenario/AuthConfig.java | 11 + .../api/dto/scenario/request/HttpRequest.java | 5 + .../api/service/ApiDelimitService.java | 223 ++++++ .../api/service/ApiModuleService.java | 101 +-- .../api/service/ApiTestCaseService.java | 208 +++++ .../metersphere/base/domain/ApiDelimit.java | 36 + .../base/domain/ApiDelimitExample.java | 745 +++++++++++++++++ .../base/domain/ApiModuleExample.java | 6 + .../metersphere/base/domain/ApiTestCase.java | 34 + .../base/domain/ApiTestCaseExample.java | 751 ++++++++++++++++++ .../base/mapper/ApiDelimitMapper.java | 45 ++ .../base/mapper/ApiDelimitMapper.xml | 557 +++++++++++++ .../base/mapper/ApiTestCaseMapper.java | 32 + .../base/mapper/ApiTestCaseMapper.xml | 281 +++++++ .../commons/constants/APITestStatus.java | 2 +- .../components/api/delimit/ApiDelimit.vue | 99 +-- .../api/delimit/components/ApiCaseList.vue | 271 +++++-- .../api/delimit/components/ApiConfig.vue | 70 +- .../api/delimit/components/ApiList.vue | 110 ++- .../api/delimit/components/ApiModule.vue | 354 +++++---- .../api/delimit/components/ApiVariable.vue | 3 +- .../delimit/components/ApiVariableAdvance.vue | 282 +++++++ .../delimit/components/auth/ApiAuthConfig.vue | 88 ++ .../components/basis/AddBasisHttpApi.vue | 136 +++- .../api/delimit/components/body/ApiBody.vue | 147 ++-- .../complete/AddCompleteHttpApi.vue | 148 +++- .../components/request/ApiHttpRequestForm.vue | 250 +++--- .../components/request/ApiRequestForm.vue | 40 +- .../api/delimit/model/ScenarioModel.js | 130 +-- .../api/report/components/ResponseText.vue | 6 - frontend/src/i18n/en-US.js | 17 +- frontend/src/i18n/zh-CN.js | 15 +- frontend/src/i18n/zh-TW.js | 15 +- 43 files changed, 4758 insertions(+), 745 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/api/controller/ApiDelimitController.java create mode 100644 backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/delimit/ApiComputeResult.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitRequest.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitResult.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseRequest.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseResult.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiDelimitRequest.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiTestCaseRequest.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/scenario/AuthConfig.java create mode 100644 backend/src/main/java/io/metersphere/api/service/ApiDelimitService.java create mode 100644 backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiDelimit.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiDelimitExample.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.xml create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml create mode 100644 frontend/src/business/components/api/delimit/components/ApiVariableAdvance.vue create mode 100644 frontend/src/business/components/api/delimit/components/auth/ApiAuthConfig.vue diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDelimitController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDelimitController.java new file mode 100644 index 0000000000..388287b78a --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDelimitController.java @@ -0,0 +1,57 @@ +package io.metersphere.api.controller; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import io.metersphere.api.dto.delimit.ApiDelimitRequest; +import io.metersphere.api.dto.delimit.ApiDelimitResult; +import io.metersphere.api.dto.delimit.SaveApiDelimitRequest; +import io.metersphere.api.service.ApiDelimitService; +import io.metersphere.base.domain.ApiDelimit; +import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; +import io.metersphere.commons.utils.SessionUtils; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.util.List; + + +@RestController +@RequestMapping(value = "/api/delimit") +@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) +public class ApiDelimitController { + @Resource + private ApiDelimitService apiDelimitService; + + @PostMapping("/list/{goPage}/{pageSize}") + public Pager> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDelimitRequest request) { + Page page = PageHelper.startPage(goPage, pageSize, true); + request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + return PageUtils.setPageInfo(page, apiDelimitService.list(request)); + } + + @PostMapping(value = "/create", consumes = {"multipart/form-data"}) + public void create(@RequestPart("request") SaveApiDelimitRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List bodyFiles) { + apiDelimitService.create(request, file, bodyFiles); + } + + @PostMapping(value = "/update", consumes = {"multipart/form-data"}) + public void update(@RequestPart("request") SaveApiDelimitRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List bodyFiles) { + apiDelimitService.update(request, file, bodyFiles); + } + + @GetMapping("/delete/{id}") + public void delete(@PathVariable String id) { + apiDelimitService.delete(id); + } + + @GetMapping("/get/{id}") + public ApiDelimit get(@PathVariable String id) { + return apiDelimitService.get(id); + } + +} diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java b/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java index cf07d0078b..8f385bab8a 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiModuleController.java @@ -23,10 +23,10 @@ public class ApiModuleController { @Resource private CheckOwnerService checkOwnerService; - @GetMapping("/list/{projectId}") + @GetMapping("/list/{projectId}/{protocol}") public List getNodeByProjectId(@PathVariable String projectId,@PathVariable String protocol) { checkOwnerService.checkProjectOwner(projectId); - return apiModuleService.getNodeTreeByProjectId(projectId); + return apiModuleService.getNodeTreeByProjectId(projectId,protocol); } @PostMapping("/add") diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java new file mode 100644 index 0000000000..534751a40d --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -0,0 +1,46 @@ +package io.metersphere.api.controller; + +import io.metersphere.api.dto.delimit.ApiTestCaseRequest; +import io.metersphere.api.dto.delimit.ApiTestCaseResult; +import io.metersphere.api.dto.delimit.SaveApiTestCaseRequest; +import io.metersphere.api.service.ApiTestCaseService; +import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.commons.utils.SessionUtils; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping(value = "/api/testcase") +@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) +public class ApiTestCaseController { + + @Resource + private ApiTestCaseService apiTestCaseService; + + @PostMapping("/list") + public List list(@RequestBody ApiTestCaseRequest request) { + request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + return apiTestCaseService.list(request); + } + + @PostMapping(value = "/create", consumes = {"multipart/form-data"}) + public void create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List bodyFiles) { + apiTestCaseService.create(request, file, bodyFiles); + } + + @PostMapping(value = "/update", consumes = {"multipart/form-data"}) + public void update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List bodyFiles) { + apiTestCaseService.update(request, file, bodyFiles); + } + + @GetMapping("/delete/{id}") + public void delete(@PathVariable String id) { + apiTestCaseService.delete(id); + } + +} diff --git a/backend/src/main/java/io/metersphere/api/dto/delimit/ApiComputeResult.java b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiComputeResult.java new file mode 100644 index 0000000000..c695b664cf --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiComputeResult.java @@ -0,0 +1,13 @@ +package io.metersphere.api.dto.delimit; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ApiComputeResult { + private String apiDelimitId; + private String caseTotal; + private String status; + private String passRate; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitRequest.java b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitRequest.java new file mode 100644 index 0000000000..def1d45629 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitRequest.java @@ -0,0 +1,27 @@ +package io.metersphere.api.dto.delimit; + +import io.metersphere.controller.request.OrderRequest; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; +import java.util.Map; + +@Getter +@Setter +public class ApiDelimitRequest { + + private String id; + private String excludeId; + private String projectId; + private String moduleId; + private List moduleIds; + private String name; + private String workspaceId; + private String userId; + private boolean recent = false; + private List orders; + private Map> filters; + private Map combine; + private List ids; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitResult.java b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitResult.java new file mode 100644 index 0000000000..1cf1a10362 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiDelimitResult.java @@ -0,0 +1,23 @@ +package io.metersphere.api.dto.delimit; + +import io.metersphere.base.domain.ApiDelimit; +import io.metersphere.base.domain.Schedule; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class ApiDelimitResult extends ApiDelimit { + + private String projectName; + + private String userName; + + private String caseTotal; + + private String caseStatus; + + private String casePassingRate; + + private Schedule schedule; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseRequest.java b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseRequest.java new file mode 100644 index 0000000000..34e375d56e --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseRequest.java @@ -0,0 +1,21 @@ +package io.metersphere.api.dto.delimit; + +import io.metersphere.controller.request.OrderRequest; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class ApiTestCaseRequest { + + private String id; + private String projectId; + private String priority; + private String name; + private String environmentId; + private String workspaceId; + private String apiDelimitId; + private List orders; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseResult.java b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseResult.java new file mode 100644 index 0000000000..4c064806a2 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/delimit/ApiTestCaseResult.java @@ -0,0 +1,15 @@ +package io.metersphere.api.dto.delimit; + +import io.metersphere.base.domain.ApiTestCase; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class ApiTestCaseResult extends ApiTestCase { + private String projectName; + private String createUser; + private String updateUser; + private String execResult; + private boolean active = false; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiDelimitRequest.java b/backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiDelimitRequest.java new file mode 100644 index 0000000000..ed9f0cf66e --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiDelimitRequest.java @@ -0,0 +1,41 @@ +package io.metersphere.api.dto.delimit; + +import io.metersphere.api.dto.scenario.request.Request; +import io.metersphere.base.domain.Schedule; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Setter +@Getter +public class SaveApiDelimitRequest { + + private String id; + + private String projectId; + + private String name; + + private String url; + + private String moduleId; + + private String status; + + private String description; + + private String modulePath; + + private String path; + + private Request request; + + private String userId; + + private Schedule schedule; + + private String triggerMode; + + private List bodyUploadIds; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiTestCaseRequest.java b/backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiTestCaseRequest.java new file mode 100644 index 0000000000..7d0456b58a --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/delimit/SaveApiTestCaseRequest.java @@ -0,0 +1,38 @@ +package io.metersphere.api.dto.delimit; + +import io.metersphere.api.dto.scenario.request.Request; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Setter +@Getter +public class SaveApiTestCaseRequest { + + private String id; + + private String projectId; + + private String name; + + private String priority; + + private String apiDelimitId; + + private String description; + + private Request request; + + private String response; + + private String crateUserId; + + private String updateUserId; + + private Long createTime; + + private Long updateTime; + + private List bodyUploadIds; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/AuthConfig.java b/backend/src/main/java/io/metersphere/api/dto/scenario/AuthConfig.java new file mode 100644 index 0000000000..a69c11b715 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/AuthConfig.java @@ -0,0 +1,11 @@ +package io.metersphere.api.dto.scenario; + +import lombok.Data; + +@Data +public class AuthConfig { + private String verification; + private String username; + private String password; + +} diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java index 74b497d07c..537a41de6b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/HttpRequest.java @@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario.request; import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONType; +import io.metersphere.api.dto.scenario.AuthConfig; import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.KeyValue; import lombok.Data; @@ -37,4 +38,8 @@ public class HttpRequest extends Request { private Boolean followRedirects; @JSONField(ordinal = 17) private Boolean doMultipartPost; + @JSONField(ordinal = 18) + private List rest; + @JSONField(ordinal = 19) + private AuthConfig authConfig; } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDelimitService.java b/backend/src/main/java/io/metersphere/api/service/ApiDelimitService.java new file mode 100644 index 0000000000..81018dd940 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/service/ApiDelimitService.java @@ -0,0 +1,223 @@ +package io.metersphere.api.service; + +import com.alibaba.fastjson.JSONObject; +import io.metersphere.api.dto.delimit.ApiComputeResult; +import io.metersphere.api.dto.delimit.ApiDelimitRequest; +import io.metersphere.api.dto.delimit.ApiDelimitResult; +import io.metersphere.api.dto.delimit.SaveApiDelimitRequest; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.ApiDelimitMapper; +import io.metersphere.base.mapper.ApiTestFileMapper; +import io.metersphere.commons.constants.APITestStatus; +import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.CommonBeanFactory; +import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.ServiceUtils; +import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.i18n.Translator; +import io.metersphere.service.FileService; +import io.metersphere.service.QuotaService; +import org.aspectj.util.FileUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +@Transactional(rollbackFor = Exception.class) +public class ApiDelimitService { + @Resource + private ApiDelimitMapper apiDelimitMapper; + @Resource + private ApiTestFileMapper apiTestFileMapper; + @Resource + private FileService fileService; + @Resource + private ApiTestCaseService apiTestCaseService; + + private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; + + public List list(ApiDelimitRequest request) { + request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); + List resList = apiDelimitMapper.list(request); + if (!resList.isEmpty()) { + List ids = resList.stream().map(ApiDelimitResult::getId).collect(Collectors.toList()); + List results = apiDelimitMapper.selectByIds(ids); + Map resultMap = results.stream().collect(Collectors.toMap(ApiComputeResult::getApiDelimitId, Function.identity())); + for (ApiDelimitResult res : resList) { + ApiComputeResult compRes = resultMap.get(res.getId()); + if (compRes != null) { + res.setCaseTotal(compRes.getCaseTotal()); + res.setCasePassingRate(compRes.getPassRate()); + res.setCaseStatus(compRes.getStatus()); + } else { + res.setCaseTotal("-"); + res.setCasePassingRate("-"); + res.setCaseStatus("-"); + } + } + } + return resList; + } + + public ApiDelimit get(String id) { + return apiDelimitMapper.selectByPrimaryKey(id); + } + + public void create(SaveApiDelimitRequest request, MultipartFile file, List bodyFiles) { + List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); + ApiDelimit test = createTest(request, file); + createBodyFiles(test, bodyUploadIds, bodyFiles); + } + + private ApiDelimit createTest(SaveApiDelimitRequest request, MultipartFile file) { + if (file == null) { + throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); + } + checkQuota(); + request.setBodyUploadIds(null); + ApiDelimit test = createTest(request); + saveFile(test.getId(), file); + return test; + } + + private void checkQuota() { + QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); + if (quotaService != null) { + quotaService.checkAPITestQuota(); + } + } + + public void update(SaveApiDelimitRequest request, MultipartFile file, List bodyFiles) { + if (file == null) { + throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); + } + deleteFileByTestId(request.getId()); + + List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); + request.setBodyUploadIds(null); + ApiDelimit test = updateTest(request); + createBodyFiles(test, bodyUploadIds, bodyFiles); + saveFile(test.getId(), file); + } + + private void createBodyFiles(ApiDelimit test, List bodyUploadIds, List bodyFiles) { + if (bodyUploadIds.size() > 0) { + String dir = BODY_FILE_DIR + "/" + test.getId(); + File testDir = new File(dir); + if (!testDir.exists()) { + testDir.mkdirs(); + } + for (int i = 0; i < bodyUploadIds.size(); i++) { + MultipartFile item = bodyFiles.get(i); + File file = new File(testDir + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename()); + try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) { + file.createNewFile(); + FileUtil.copyStream(in, out); + } catch (IOException e) { + LogUtil.error(e); + MSException.throwException(Translator.get("upload_fail")); + } + } + } + } + + public void delete(String apiId) { + apiTestCaseService.checkIsRelateTest(apiId); + deleteFileByTestId(apiId); + //apiReportService.deleteByTestId(apiId); + apiDelimitMapper.deleteByPrimaryKey(apiId); + deleteBodyFiles(apiId); + } + + public void deleteBodyFiles(String apiId) { + File file = new File(BODY_FILE_DIR + "/" + apiId); + FileUtil.deleteContents(file); + if (file.exists()) { + file.delete(); + } + } + + private void checkNameExist(SaveApiDelimitRequest request) { + ApiDelimitExample example = new ApiDelimitExample(); + example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId()); + if (apiDelimitMapper.countByExample(example) > 0) { + MSException.throwException(Translator.get("load_test_already_exists")); + } + } + + + private ApiDelimit updateTest(SaveApiDelimitRequest request) { + checkNameExist(request); + final ApiDelimit test = new ApiDelimit(); + test.setId(request.getId()); + test.setName(request.getName()); + test.setProjectId(request.getProjectId()); + test.setRequest(JSONObject.toJSONString(request.getRequest())); + test.setUpdateTime(System.currentTimeMillis()); + test.setStatus(request.getStatus()); + test.setModulePath(request.getModulePath()); + test.setModuleId(request.getModuleId()); + test.setPath(request.getPath()); + test.setUrl(request.getUrl()); + test.setDescription(request.getDescription()); + test.setUserId(request.getUserId()); + + apiDelimitMapper.updateByPrimaryKeySelective(test); + return test; + } + + private ApiDelimit createTest(SaveApiDelimitRequest request) { + checkNameExist(request); + final ApiDelimit test = new ApiDelimit(); + test.setId(request.getId()); + test.setName(request.getName()); + test.setUrl(request.getUrl()); + test.setPath(request.getPath()); + test.setModuleId(request.getModuleId()); + test.setProjectId(request.getProjectId()); + test.setRequest(JSONObject.toJSONString(request.getRequest())); + test.setCreateTime(System.currentTimeMillis()); + test.setUpdateTime(System.currentTimeMillis()); + test.setStatus(APITestStatus.Underway.name()); + test.setModulePath(request.getModulePath()); + if (request.getUserId() == null) { + test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); + } else { + test.setUserId(request.getUserId()); + } + test.setDescription(request.getDescription()); + apiDelimitMapper.insert(test); + return test; + } + + private void saveFile(String apiId, MultipartFile file) { + final FileMetadata fileMetadata = fileService.saveFile(file); + ApiTestFile apiTestFile = new ApiTestFile(); + apiTestFile.setTestId(apiId); + apiTestFile.setFileId(fileMetadata.getId()); + apiTestFileMapper.insert(apiTestFile); + } + + private void deleteFileByTestId(String apiId) { + ApiTestFileExample ApiTestFileExample = new ApiTestFileExample(); + ApiTestFileExample.createCriteria().andTestIdEqualTo(apiId); + final List ApiTestFiles = apiTestFileMapper.selectByExample(ApiTestFileExample); + apiTestFileMapper.deleteByExample(ApiTestFileExample); + + if (!CollectionUtils.isEmpty(ApiTestFiles)) { + final List fileIds = ApiTestFiles.stream().map(ApiTestFile::getFileId).collect(Collectors.toList()); + fileService.deleteFileByIds(fileIds); + } + } + +} diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index f1e5550408..5aa8a23a93 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -1,20 +1,19 @@ package io.metersphere.api.service; +import io.metersphere.api.dto.delimit.ApiDelimitRequest; +import io.metersphere.api.dto.delimit.ApiDelimitResult; import io.metersphere.api.dto.delimit.ApiModuleDTO; import io.metersphere.api.dto.delimit.DragModuleRequest; +import io.metersphere.base.domain.ApiDelimitExample; import io.metersphere.base.domain.ApiModule; import io.metersphere.base.domain.ApiModuleExample; -import io.metersphere.base.domain.TestCaseExample; +import io.metersphere.base.mapper.ApiDelimitMapper; import io.metersphere.base.mapper.ApiModuleMapper; -import io.metersphere.base.mapper.TestCaseMapper; -import io.metersphere.base.mapper.ext.ExtTestCaseMapper; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.i18n.Translator; -import io.metersphere.track.dto.TestCaseDTO; -import io.metersphere.track.request.testcase.QueryTestCaseRequest; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -33,15 +32,16 @@ public class ApiModuleService { @Resource ApiModuleMapper apiModuleMapper; @Resource - ExtTestCaseMapper extTestCaseMapper; + private ApiDelimitMapper apiDelimitMapper; @Resource SqlSessionFactory sqlSessionFactory; - public List getNodeTreeByProjectId(String projectId) { - ApiModuleExample testCaseNodeExample = new ApiModuleExample(); - testCaseNodeExample.createCriteria().andProjectIdEqualTo(projectId); - testCaseNodeExample.setOrderByClause("create_time asc"); - List nodes = apiModuleMapper.selectByExample(testCaseNodeExample); + public List getNodeTreeByProjectId(String projectId, String protocol) { + ApiModuleExample apiDelimitNodeExample = new ApiModuleExample(); + apiDelimitNodeExample.createCriteria().andProjectIdEqualTo(projectId); + apiDelimitNodeExample.createCriteria().andProtocolEqualTo(protocol); + apiDelimitNodeExample.setOrderByClause("create_time asc"); + List nodes = apiModuleMapper.selectByExample(apiDelimitNodeExample); return getNodeTrees(nodes); } @@ -107,10 +107,10 @@ public class ApiModuleService { throw new RuntimeException(Translator.get("test_case_node_level_tip") + TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level")); } - checkTestCaseNodeExist(node); + checkApiModuleExist(node); } - private void checkTestCaseNodeExist(ApiModule node) { + private void checkApiModuleExist(ApiModule node) { if (node.getName() != null) { ApiModuleExample example = new ApiModuleExample(); ApiModuleExample.Criteria criteria = example.createCriteria(); @@ -130,104 +130,107 @@ public class ApiModuleService { } } - private List QueryTestCaseByNodeIds(List nodeIds) { - QueryTestCaseRequest testCaseRequest = new QueryTestCaseRequest(); - testCaseRequest.setNodeIds(nodeIds); - return extTestCaseMapper.list(testCaseRequest); + private List queryByModuleIds(List nodeIds) { + ApiDelimitRequest apiDelimitRequest = new ApiDelimitRequest(); + apiDelimitRequest.setModuleIds(nodeIds); + return apiDelimitMapper.list(apiDelimitRequest); } public int editNode(DragModuleRequest request) { request.setUpdateTime(System.currentTimeMillis()); - checkTestCaseNodeExist(request); - List apiModule = QueryTestCaseByNodeIds(request.getNodeIds()); + checkApiModuleExist(request); + List apiModule = queryByModuleIds(request.getNodeIds()); - apiModule.forEach(testCase -> { - StringBuilder path = new StringBuilder(testCase.getNodePath()); + apiModule.forEach(apiDelimit -> { + StringBuilder path = new StringBuilder(apiDelimit.getModulePath()); List pathLists = Arrays.asList(path.toString().split("/")); pathLists.set(request.getLevel(), request.getName()); path.delete(0, path.length()); for (int i = 1; i < pathLists.size(); i++) { path = path.append("/").append(pathLists.get(i)); } - testCase.setNodePath(path.toString()); + apiDelimit.setModulePath(path.toString()); }); - batchUpdateTestCase(apiModule); + batchUpdateApiDelimit(apiModule); return apiModuleMapper.updateByPrimaryKeySelective(request); } public int deleteNode(List nodeIds) { - TestCaseExample testCaseExample = new TestCaseExample(); - testCaseExample.createCriteria().andNodeIdIn(nodeIds); + ApiDelimitExample apiDelimitExample = new ApiDelimitExample(); + apiDelimitExample.createCriteria().andModuleIdIn(nodeIds); + apiDelimitMapper.deleteByExample(apiDelimitExample); - ApiModuleExample testCaseNodeExample = new ApiModuleExample(); - testCaseNodeExample.createCriteria().andIdIn(nodeIds); - return apiModuleMapper.deleteByExample(testCaseNodeExample); + ApiModuleExample apiDelimitNodeExample = new ApiModuleExample(); + apiDelimitNodeExample.createCriteria().andIdIn(nodeIds); + return apiModuleMapper.deleteByExample(apiDelimitNodeExample); } - private void batchUpdateTestCase(List apiModule) { + private void batchUpdateApiDelimit(List apiModule) { SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); - TestCaseMapper testCaseMapper = sqlSession.getMapper(TestCaseMapper.class); + ApiDelimitMapper apiDelimitMapper = sqlSession.getMapper(ApiDelimitMapper.class); apiModule.forEach((value) -> { - testCaseMapper.updateByPrimaryKey(value); + apiDelimitMapper.updateByPrimaryKey(value); }); sqlSession.flushStatements(); } public void dragNode(DragModuleRequest request) { - checkTestCaseNodeExist(request); + checkApiModuleExist(request); List nodeIds = request.getNodeIds(); - List apiModule = QueryTestCaseByNodeIds(nodeIds); + List apiModule = queryByModuleIds(nodeIds); ApiModuleDTO nodeTree = request.getNodeTree(); List updateNodes = new ArrayList<>(); - buildUpdateTestCase(nodeTree, apiModule, updateNodes, "/", "0", 1); + buildUpdateDelimit(nodeTree, apiModule, updateNodes, "/", "0", nodeTree.getLevel()); updateNodes = updateNodes.stream() .filter(item -> nodeIds.contains(item.getId())) .collect(Collectors.toList()); - batchUpdateTestCaseNode(updateNodes); + batchUpdateModule(updateNodes); - batchUpdateTestCase(apiModule); + batchUpdateApiDelimit(apiModule); } - private void buildUpdateTestCase(ApiModuleDTO rootNode, List apiModule, - List updateNodes, String rootPath, String pId, int level) { + private void buildUpdateDelimit(ApiModuleDTO rootNode, List apiDelimits, + List updateNodes, String rootPath, String pId, int level) { rootPath = rootPath + rootNode.getName(); if (level > 8) { MSException.throwException(Translator.get("node_deep_limit")); } + if (rootNode.getId().equals("rootID")) { + rootPath = ""; + } + ApiModule apiDelimitNode = new ApiModule(); + apiDelimitNode.setId(rootNode.getId()); + apiDelimitNode.setLevel(level); + apiDelimitNode.setParentId(pId); + updateNodes.add(apiDelimitNode); - ApiModule testCaseNode = new ApiModule(); - testCaseNode.setId(rootNode.getId()); - testCaseNode.setLevel(level); - testCaseNode.setParentId(pId); - updateNodes.add(testCaseNode); - - for (TestCaseDTO item : apiModule) { - if (StringUtils.equals(item.getNodeId(), rootNode.getId())) { - item.setNodePath(rootPath); + for (ApiDelimitResult item : apiDelimits) { + if (StringUtils.equals(item.getModuleId(), rootNode.getId())) { + item.setModulePath(rootPath); } } List children = rootNode.getChildren(); if (children != null && children.size() > 0) { for (int i = 0; i < children.size(); i++) { - buildUpdateTestCase(children.get(i), apiModule, updateNodes, rootPath + '/', rootNode.getId(), level + 1); + buildUpdateDelimit(children.get(i), apiDelimits, updateNodes, rootPath + '/', rootNode.getId(), level + 1); } } } - private void batchUpdateTestCaseNode(List updateNodes) { + private void batchUpdateModule(List updateNodes) { SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); ApiModuleMapper apiModuleMapper = sqlSession.getMapper(ApiModuleMapper.class); updateNodes.forEach((value) -> { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java new file mode 100644 index 0000000000..ca203227d5 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -0,0 +1,208 @@ +package io.metersphere.api.service; + +import com.alibaba.fastjson.JSONObject; +import io.metersphere.api.dto.delimit.ApiTestCaseRequest; +import io.metersphere.api.dto.delimit.ApiTestCaseResult; +import io.metersphere.api.dto.delimit.SaveApiTestCaseRequest; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.ApiTestCaseMapper; +import io.metersphere.base.mapper.ApiTestFileMapper; +import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.CommonBeanFactory; +import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.ServiceUtils; +import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.i18n.Translator; +import io.metersphere.service.FileService; +import io.metersphere.service.QuotaService; +import org.aspectj.util.FileUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +@Service +@Transactional(rollbackFor = Exception.class) +public class ApiTestCaseService { + @Resource + private ApiTestCaseMapper apiTestCaseMapper; + @Resource + private ApiTestFileMapper apiTestFileMapper; + @Resource + private FileService fileService; + + private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; + + public List list(ApiTestCaseRequest request) { + request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); + return apiTestCaseMapper.list(request); + } + + public ApiTestCase get(String id) { + return apiTestCaseMapper.selectByPrimaryKey(id); + } + + public void create(SaveApiTestCaseRequest request, MultipartFile file, List bodyFiles) { + List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); + ApiTestCase test = createTest(request, file); + createBodyFiles(test, bodyUploadIds, bodyFiles); + } + + private ApiTestCase createTest(SaveApiTestCaseRequest request, MultipartFile file) { + if (file == null) { + throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); + } + checkQuota(); + request.setBodyUploadIds(null); + ApiTestCase test = createTest(request); + saveFile(test.getId(), file); + return test; + } + + private void checkQuota() { + QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class); + if (quotaService != null) { + quotaService.checkAPITestQuota(); + } + } + + public void update(SaveApiTestCaseRequest request, MultipartFile file, List bodyFiles) { + if (file == null) { + throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); + } + deleteFileByTestId(request.getId()); + + List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); + request.setBodyUploadIds(null); + ApiTestCase test = updateTest(request); + createBodyFiles(test, bodyUploadIds, bodyFiles); + saveFile(test.getId(), file); + } + + private void createBodyFiles(ApiTestCase test, List bodyUploadIds, List bodyFiles) { + if (bodyUploadIds.size() > 0) { + String dir = BODY_FILE_DIR + "/" + test.getId(); + File testDir = new File(dir); + if (!testDir.exists()) { + testDir.mkdirs(); + } + for (int i = 0; i < bodyUploadIds.size(); i++) { + MultipartFile item = bodyFiles.get(i); + File file = new File(testDir + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename()); + try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) { + file.createNewFile(); + FileUtil.copyStream(in, out); + } catch (IOException e) { + LogUtil.error(e); + MSException.throwException(Translator.get("upload_fail")); + } + } + } + } + + public void delete(String testId) { + deleteFileByTestId(testId); + //apiReportService.deleteByTestId(testId); + apiTestCaseMapper.deleteByPrimaryKey(testId); + deleteBodyFiles(testId); + } + + /** + * 是否已经创建了测试用例 + */ + public void checkIsRelateTest(String apiId) { + ApiTestCaseExample testCaseExample = new ApiTestCaseExample(); + testCaseExample.createCriteria().andApiDelimitIdEqualTo(apiId); + List testCases = apiTestCaseMapper.selectByExample(testCaseExample); + StringBuilder caseName = new StringBuilder(); + if (testCases.size() > 0) { + for (ApiTestCase testCase : testCases) { + caseName = caseName.append(testCase.getName()).append(","); + } + String str = caseName.toString().substring(0, caseName.length() - 1); + MSException.throwException(Translator.get("related_case_del_fail_prefix") + " " + str + " " + Translator.get("related_case_del_fail_suffix")); + } + } + + public void deleteBodyFiles(String testId) { + File file = new File(BODY_FILE_DIR + "/" + testId); + FileUtil.deleteContents(file); + if (file.exists()) { + file.delete(); + } + } + + private void checkNameExist(SaveApiTestCaseRequest request) { + ApiTestCaseExample example = new ApiTestCaseExample(); + example.createCriteria().andNameEqualTo(request.getName()).andApiDelimitIdEqualTo(request.getApiDelimitId()).andIdNotEqualTo(request.getId()); + if (apiTestCaseMapper.countByExample(example) > 0) { + MSException.throwException(Translator.get("load_test_already_exists")); + } + } + + + private ApiTestCase updateTest(SaveApiTestCaseRequest request) { + checkNameExist(request); + final ApiTestCase test = new ApiTestCase(); + test.setId(request.getId()); + test.setName(request.getName()); + test.setApiDelimitId(request.getApiDelimitId()); + test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); + test.setProjectId(request.getProjectId()); + test.setRequest(JSONObject.toJSONString(request.getRequest())); + test.setResponse(JSONObject.toJSONString(request.getResponse())); + test.setPriority(request.getPriority()); + test.setUpdateTime(System.currentTimeMillis()); + test.setDescription(request.getDescription()); + apiTestCaseMapper.updateByPrimaryKeySelective(test); + return test; + } + + private ApiTestCase createTest(SaveApiTestCaseRequest request) { + request.setId(UUID.randomUUID().toString()); + checkNameExist(request); + final ApiTestCase test = new ApiTestCase(); + test.setId(request.getId()); + test.setName(request.getName()); + test.setApiDelimitId(request.getApiDelimitId()); + test.setCreateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); + test.setUpdateUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); + test.setProjectId(request.getProjectId()); + test.setRequest(JSONObject.toJSONString(request.getRequest())); + test.setResponse(JSONObject.toJSONString(request.getResponse())); + test.setCreateTime(System.currentTimeMillis()); + test.setPriority(request.getPriority()); + test.setUpdateTime(System.currentTimeMillis()); + test.setDescription(request.getDescription()); + apiTestCaseMapper.insert(test); + return test; + } + + private void saveFile(String testId, MultipartFile file) { + final FileMetadata fileMetadata = fileService.saveFile(file); + ApiTestFile apiTestFile = new ApiTestFile(); + apiTestFile.setTestId(testId); + apiTestFile.setFileId(fileMetadata.getId()); + apiTestFileMapper.insert(apiTestFile); + } + + private void deleteFileByTestId(String testId) { + ApiTestFileExample ApiTestFileExample = new ApiTestFileExample(); + ApiTestFileExample.createCriteria().andTestIdEqualTo(testId); + final List ApiTestFiles = apiTestFileMapper.selectByExample(ApiTestFileExample); + apiTestFileMapper.deleteByExample(ApiTestFileExample); + + if (!CollectionUtils.isEmpty(ApiTestFiles)) { + final List fileIds = ApiTestFiles.stream().map(ApiTestFile::getFileId).collect(Collectors.toList()); + fileService.deleteFileByIds(fileIds); + } + } +} diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiDelimit.java b/backend/src/main/java/io/metersphere/base/domain/ApiDelimit.java new file mode 100644 index 0000000000..7d86acfcfd --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiDelimit.java @@ -0,0 +1,36 @@ +package io.metersphere.base.domain; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ApiDelimit implements Serializable { + private String id; + + private String projectId; + + private String name; + + private String path; + + private String url; + + private String description; + + private String status; + + private String userId; + + private String moduleId; + + private String modulePath; + + private Long createTime; + + private Long updateTime; + + private String request; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiDelimitExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiDelimitExample.java new file mode 100644 index 0000000000..8b3f36fc9a --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiDelimitExample.java @@ -0,0 +1,745 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class ApiDelimitExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public ApiDelimitExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andModuleIdIn(List values) { + addCriterion("module_id in", values, "module_id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNull() { + addCriterion("project_id is null"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNotNull() { + addCriterion("project_id is not null"); + return (Criteria) this; + } + + public Criteria andProjectIdEqualTo(String value) { + addCriterion("project_id =", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotEqualTo(String value) { + addCriterion("project_id <>", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThan(String value) { + addCriterion("project_id >", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThanOrEqualTo(String value) { + addCriterion("project_id >=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThan(String value) { + addCriterion("project_id <", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThanOrEqualTo(String value) { + addCriterion("project_id <=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLike(String value) { + addCriterion("project_id like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotLike(String value) { + addCriterion("project_id not like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdIn(List values) { + addCriterion("project_id in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotIn(List values) { + addCriterion("project_id not in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdBetween(String value1, String value2) { + addCriterion("project_id between", value1, value2, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotBetween(String value1, String value2) { + addCriterion("project_id not between", value1, value2, "projectId"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("name is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("name is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("name =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("name <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("name >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("name >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("name <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("name <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("name like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("name not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("name in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("name not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("name between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("name not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNull() { + addCriterion("description is null"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNotNull() { + addCriterion("description is not null"); + return (Criteria) this; + } + + public Criteria andDescriptionEqualTo(String value) { + addCriterion("description =", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotEqualTo(String value) { + addCriterion("description <>", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThan(String value) { + addCriterion("description >", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThanOrEqualTo(String value) { + addCriterion("description >=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThan(String value) { + addCriterion("description <", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThanOrEqualTo(String value) { + addCriterion("description <=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLike(String value) { + addCriterion("description like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotLike(String value) { + addCriterion("description not like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionIn(List values) { + addCriterion("description in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotIn(List values) { + addCriterion("description not in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionBetween(String value1, String value2) { + addCriterion("description between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotBetween(String value1, String value2) { + addCriterion("description not between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("status is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("status is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(String value) { + addCriterion("status =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(String value) { + addCriterion("status <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(String value) { + addCriterion("status >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(String value) { + addCriterion("status >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(String value) { + addCriterion("status <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(String value) { + addCriterion("status <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLike(String value) { + addCriterion("status like", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotLike(String value) { + addCriterion("status not like", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("status in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("status not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(String value1, String value2) { + addCriterion("status between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(String value1, String value2) { + addCriterion("status not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(String value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(String value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(String value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(String value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(String value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(String value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLike(String value) { + addCriterion("user_id like", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotLike(String value) { + addCriterion("user_id not like", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(String value1, String value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(String value1, String value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Long value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Long value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Long value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Long value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Long value1, Long value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiModuleExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiModuleExample.java index 198251d7f4..5a5d51e771 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiModuleExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiModuleExample.java @@ -189,6 +189,12 @@ public class ApiModuleExample { return (Criteria) this; } + + public Criteria andProtocolEqualTo(String value) { + addCriterion("protocol =", value, "protocol"); + return (Criteria) this; + } + public Criteria andProjectIdNotEqualTo(String value) { addCriterion("project_id <>", value, "projectId"); return (Criteria) this; diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java new file mode 100644 index 0000000000..d84baeb375 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java @@ -0,0 +1,34 @@ +package io.metersphere.base.domain; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ApiTestCase implements Serializable { + private String id; + + private String projectId; + + private String name; + + private String priority; + + private String apiDelimitId; + + private String description; + + private String request; + + private String response; + + private String createUserId; + + private String updateUserId; + + private Long createTime; + + private Long updateTime; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java new file mode 100644 index 0000000000..ca7d2fb470 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java @@ -0,0 +1,751 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class ApiTestCaseExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public ApiTestCaseExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andModuleIdIn(List values) { + addCriterion("module_id in", values, "module_id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNull() { + addCriterion("project_id is null"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNotNull() { + addCriterion("project_id is not null"); + return (Criteria) this; + } + + public Criteria andProjectIdEqualTo(String value) { + addCriterion("project_id =", value, "projectId"); + return (Criteria) this; + } + + public Criteria andApiDelimitIdEqualTo(String value) { + addCriterion("api_delimit_id =", value, "api_delimit_id"); + return (Criteria) this; + } + + + public Criteria andProjectIdNotEqualTo(String value) { + addCriterion("project_id <>", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThan(String value) { + addCriterion("project_id >", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThanOrEqualTo(String value) { + addCriterion("project_id >=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThan(String value) { + addCriterion("project_id <", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThanOrEqualTo(String value) { + addCriterion("project_id <=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLike(String value) { + addCriterion("project_id like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotLike(String value) { + addCriterion("project_id not like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdIn(List values) { + addCriterion("project_id in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotIn(List values) { + addCriterion("project_id not in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdBetween(String value1, String value2) { + addCriterion("project_id between", value1, value2, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotBetween(String value1, String value2) { + addCriterion("project_id not between", value1, value2, "projectId"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("name is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("name is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("name =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("name <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("name >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("name >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("name <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("name <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("name like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("name not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("name in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("name not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("name between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("name not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNull() { + addCriterion("description is null"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNotNull() { + addCriterion("description is not null"); + return (Criteria) this; + } + + public Criteria andDescriptionEqualTo(String value) { + addCriterion("description =", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotEqualTo(String value) { + addCriterion("description <>", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThan(String value) { + addCriterion("description >", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThanOrEqualTo(String value) { + addCriterion("description >=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThan(String value) { + addCriterion("description <", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThanOrEqualTo(String value) { + addCriterion("description <=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLike(String value) { + addCriterion("description like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotLike(String value) { + addCriterion("description not like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionIn(List values) { + addCriterion("description in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotIn(List values) { + addCriterion("description not in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionBetween(String value1, String value2) { + addCriterion("description between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotBetween(String value1, String value2) { + addCriterion("description not between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("status is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("status is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(String value) { + addCriterion("status =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(String value) { + addCriterion("status <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(String value) { + addCriterion("status >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(String value) { + addCriterion("status >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(String value) { + addCriterion("status <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(String value) { + addCriterion("status <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLike(String value) { + addCriterion("status like", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotLike(String value) { + addCriterion("status not like", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("status in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("status not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(String value1, String value2) { + addCriterion("status between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(String value1, String value2) { + addCriterion("status not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(String value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(String value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(String value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(String value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(String value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(String value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLike(String value) { + addCriterion("user_id like", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotLike(String value) { + addCriterion("user_id not like", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(String value1, String value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(String value1, String value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Long value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Long value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Long value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Long value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Long value1, Long value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.java new file mode 100644 index 0000000000..68f2e5b406 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.java @@ -0,0 +1,45 @@ +package io.metersphere.base.mapper; + +import io.metersphere.api.dto.delimit.ApiComputeResult; +import io.metersphere.api.dto.delimit.ApiDelimitRequest; +import io.metersphere.api.dto.delimit.ApiDelimitResult; +import io.metersphere.base.domain.ApiDelimit; +import io.metersphere.base.domain.ApiDelimitExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ApiDelimitMapper { + + List list(@Param("request") ApiDelimitRequest request); + + List selectByIds(@Param("ids") List ids); + + long countByExample(ApiDelimitExample example); + + int deleteByExample(ApiDelimitExample example); + + int deleteByPrimaryKey(String id); + + int insert(ApiDelimit record); + + int insertSelective(ApiDelimit record); + + List selectByExampleWithBLOBs(ApiDelimitExample example); + + List selectByExample(ApiDelimitExample example); + + ApiDelimit selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") ApiDelimit record, @Param("example") ApiDelimitExample example); + + int updateByExampleWithBLOBs(@Param("record") ApiDelimit record, @Param("example") ApiDelimitExample example); + + int updateByExample(@Param("record") ApiDelimit record, @Param("example") ApiDelimitExample example); + + int updateByPrimaryKeySelective(ApiDelimit record); + + int updateByPrimaryKeyWithBLOBs(ApiDelimit record); + + int updateByPrimaryKey(ApiDelimit record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.xml new file mode 100644 index 0000000000..22ef97ecd2 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiDelimitMapper.xml @@ -0,0 +1,557 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, project_id, name,module_id,module_path,url ,path ,description, status, user_id, create_time, update_time + + + request + + + + + + + + + and api_delimit.name + + + + + + and api_delimit.update_time + + + + + + and project.name + + + + + + and api_delimit.create_time + + + + + + and api_delimit.status + + + + + + and api_delimit.user_id + + + + + + + + + + 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} + + + + + + + + + + delete from api_delimit + where id = #{id,jdbcType=VARCHAR} + + + delete from api_delimit + + + + + + insert into api_delimit (id, project_id, name, url,module_id,module_path,path, + description, status, user_id, + create_time, update_time, request + ) + values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{moduleId,jdbcType=VARCHAR},#{modulePath,jdbcType=VARCHAR},#{path,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, + #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{request,jdbcType=LONGVARCHAR} + ) + + + insert into api_delimit + + + id, + + + project_id, + + + name, + + + url, + + + path, + + + + module_id, + + + module_path, + + + description, + + + status, + + + user_id, + + + create_time, + + + update_time, + + + request, + + + + + #{id,jdbcType=VARCHAR}, + + + #{projectId,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + + #{url,jdbcType=VARCHAR}, + + + #{moduleId,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{status,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=BIGINT}, + + + #{request,jdbcType=LONGVARCHAR}, + + + + + + update api_delimit + + + id = #{record.id,jdbcType=VARCHAR}, + + + project_id = #{record.projectId,jdbcType=VARCHAR}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + + module_id = #{record.moduleId,jdbcType=BIGINT}, + + + module_path = #{record.modulePath,jdbcType=BIGINT}, + + + + url = #{record.url,jdbcType=LONGVARCHAR}, + + + path = #{record.path,jdbcType=LONGVARCHAR}, + + + + description = #{record.description,jdbcType=VARCHAR}, + + + status = #{record.status,jdbcType=VARCHAR}, + + + user_id = #{record.userId,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=BIGINT}, + + + request = #{record.request,jdbcType=LONGVARCHAR}, + + + + + + + + update api_delimit + set id = #{record.id,jdbcType=VARCHAR}, + project_id = #{record.projectId,jdbcType=VARCHAR}, + name = #{record.name,jdbcType=VARCHAR}, + module_id = #{moduleId,jdbcType=VARCHAR}, + module_path = #{modulePath,jdbcType=VARCHAR}, + url = #{url,jdbcType=VARCHAR}, + path = #{path,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + status = #{record.status,jdbcType=VARCHAR}, + user_id = #{record.userId,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT}, + request = #{record.request,jdbcType=LONGVARCHAR} + + + + + + update api_delimit + set id = #{record.id,jdbcType=VARCHAR}, + project_id = #{record.projectId,jdbcType=VARCHAR}, + name = #{record.name,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + status = #{record.status,jdbcType=VARCHAR}, + user_id = #{record.userId,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT} + + + + + + update api_delimit + + + project_id = #{projectId,jdbcType=VARCHAR}, + + + name = #{name,jdbcType=VARCHAR}, + + + + module_id = #{moduleId,jdbcType=BIGINT}, + + + url = #{url,jdbcType=LONGVARCHAR}, + + + path = #{path,jdbcType=VARCHAR}, + + + module_path = #{modulePath,jdbcType=VARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + status = #{status,jdbcType=VARCHAR}, + + + user_id = #{userId,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=BIGINT}, + + + request = #{request,jdbcType=LONGVARCHAR}, + + + + where id = #{id,jdbcType=VARCHAR} + + + update api_delimit + set project_id = #{projectId,jdbcType=VARCHAR}, + name = #{name,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + user_id = #{userId,jdbcType=VARCHAR}, + module_id = #{moduleId,jdbcType=VARCHAR}, + module_path = #{modulePath,jdbcType=VARCHAR}, + url = #{url,jdbcType=VARCHAR}, + path = #{path,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, + request = #{request,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=VARCHAR} + + + update api_delimit + set project_id = #{projectId,jdbcType=VARCHAR}, + name = #{name,jdbcType=VARCHAR}, + module_id = #{moduleId,jdbcType=VARCHAR}, + url = #{url,jdbcType=VARCHAR}, + module_path = #{modulePath,jdbcType=VARCHAR}, + path = #{path,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + user_id = #{userId,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.java new file mode 100644 index 0000000000..cb2dbd8730 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.java @@ -0,0 +1,32 @@ +package io.metersphere.base.mapper; + +import io.metersphere.api.dto.delimit.ApiTestCaseRequest; +import io.metersphere.api.dto.delimit.ApiTestCaseResult; +import io.metersphere.base.domain.ApiTestCase; +import io.metersphere.base.domain.ApiTestCaseExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ApiTestCaseMapper { + + List list(@Param("request") ApiTestCaseRequest request); + + long countByExample(ApiTestCaseExample example); + + int deleteByExample(ApiTestCaseExample example); + + int deleteByPrimaryKey(String id); + + int insert(ApiTestCase record); + + List selectByExampleWithBLOBs(ApiTestCaseExample example); + + List selectByExample(ApiTestCaseExample example); + + ApiTestCase selectByPrimaryKey(String id); + + int updateByPrimaryKeySelective(ApiTestCase record); + + int updateByPrimaryKey(ApiTestCase record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml new file mode 100644 index 0000000000..beca00f27f --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, project_id, name,api_delimit_id,priority,description, create_user_id, update_user_id, create_time, update_time + + + request + + + + + + + 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} + + + + + + + + + + + + delete from api_test_case where id = #{id,jdbcType=VARCHAR} + + + + delete from api_test_case + + + + + + + insert into api_test_case (id, project_id, name, priority,api_delimit_id,description, create_user_id, update_user_id, + create_time, update_time, request,response + ) + values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{apiDelimitId,jdbcType=VARCHAR},#{description,jdbcType=VARCHAR}, + #{createUserId,jdbcType=VARCHAR}, #{updateUserId,jdbcType=VARCHAR}, + #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR}) + + + + + + update api_test_case + + + project_id = #{projectId,jdbcType=VARCHAR}, + + + name = #{name,jdbcType=VARCHAR}, + + + + api_delimit_id = #{apiDelimitId,jdbcType=BIGINT}, + + + priority = #{priority,jdbcType=LONGVARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + update_user_id = #{updateUserId,jdbcType=VARCHAR}, + + + update_time = #{updateTime,jdbcType=BIGINT}, + + + request = #{request,jdbcType=LONGVARCHAR}, + + + request = #{response,jdbcType=LONGVARCHAR}, + + + + where id = #{id,jdbcType=VARCHAR} + + + + update api_test_case + set project_id = #{projectId,jdbcType=VARCHAR}, + name = #{name,jdbcType=VARCHAR}, + api_delimit_id = #{apiDelimitId,jdbcType=VARCHAR}, + priority = #{priority,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + update_user_id = #{updateUserId,jdbcType=VARCHAR}, + update_time = #{updateTime,jdbcType=BIGINT} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java b/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java index abb0873aa3..69587b0f5e 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java +++ b/backend/src/main/java/io/metersphere/commons/constants/APITestStatus.java @@ -1,5 +1,5 @@ package io.metersphere.commons.constants; public enum APITestStatus { - Saved, Starting, Running, Reporting, Completed, Debug, Error, Success + Saved, Starting, Running, Reporting, Completed, Debug, Error, Success,Underway } diff --git a/frontend/src/business/components/api/delimit/ApiDelimit.vue b/frontend/src/business/components/api/delimit/ApiDelimit.vue index b955b4f8cb..567b27e0ec 100644 --- a/frontend/src/business/components/api/delimit/ApiDelimit.vue +++ b/frontend/src/business/components/api/delimit/ApiDelimit.vue @@ -2,7 +2,8 @@ - + @@ -28,18 +29,16 @@ + ref="apiList">
- +
@@ -66,6 +65,7 @@ import MsApiConfig from "./components/ApiConfig"; import MsDebugHttpPage from "./components/debug/DebugHttpPage"; import MsRunTestHttpPage from "./components/runtest/RunTestHttpPage"; + import {getCurrentUser, getUUID} from "../../../../common/js/utils"; export default { name: "TestCase", @@ -86,42 +86,34 @@ projectId: null, isHide: true, editableTabsValue: '1', + tabIndex: 1, + result: {}, + currentPage: 1, + pageSize: 5, + total: 0, + currentProject: null, + currentModule: null, + currentApi: {}, + moduleOptions: {}, editableTabs: [{ title: this.$t('api_test.delimit.api_title'), name: '1', type: "list", closable: false }], - tabIndex: 1, - - result: {}, - currentPage: 1, - pageSize: 5, - total: 0, - projects: [], - currentProject: null, - treeNodes: [], - selectApi: {}, - selectParentNodes: [], - testCaseReadOnly: true, - selectNode: {}, - nodeTreeDraggable: true, - } }, - created() { - - }, - watch: { - '$route': 'init', - - }, - methods: { handleCommand(e) { if (e === "add") { + this.currentApi = { + status: "Underway", + path: "GET", + userId: getCurrentUser().id, + }; this.handleTabsEdit(this.$t('api_test.delimit.request.title'), e); - } else if (e === "test") { + } + else if (e === "test") { this.handleTabsEdit(this.$t("commons.api"), e); } else if (e === "closeAll") { @@ -154,45 +146,56 @@ if (targetName === undefined || targetName === null) { targetName = this.$t('api_test.delimit.request.title'); } - let newTabName = ++this.tabIndex + ''; + let newTabName = getUUID().substring(0, 8); this.editableTabs.push({ title: targetName, name: newTabName, closable: true, - type: action, - content: MsApiConfig + type: action }); this.editableTabsValue = newTabName; } }, - editTestCase(testCase) { - this.handleTabsEdit(testCase.api_name, "add"); + editApi(row) { + this.currentApi = row; + this.handleTabsEdit(row.name, "add"); }, handleCase(testCase) { - this.selectApi = testCase; + this.currentApi = testCase; this.isHide = false; }, apiCaseClose() { this.isHide = true; }, - - batchMove(selectIds) { + selectModule(data) { + this.currentModule = data; }, - - refresh() { - }, - moveToNode() { + refresh(data) { + this.$refs.apiList[0].initTableData(data); }, saveAs(data) { this.handleCommand("add"); }, runTest(data) { - console.log(data); this.handleCommand("test"); }, - search() { - alert(1); + saveApi(data) { + for (let index in this.editableTabs) { + let tab = this.editableTabs[index]; + if (tab.name === this.editableTabsValue) { + tab.title = data.name; + break; + } + } + this.$refs.apiList[0].initTableData(data); + + }, + initTree(data) { + this.moduleOptions = data; + }, + changeProject(data) { + this.currentProject = data; } } } diff --git a/frontend/src/business/components/api/delimit/components/ApiCaseList.vue b/frontend/src/business/components/api/delimit/components/ApiCaseList.vue index 586e530945..61d6de00f8 100644 --- a/frontend/src/business/components/api/delimit/components/ApiCaseList.vue +++ b/frontend/src/business/components/api/delimit/components/ApiCaseList.vue @@ -1,11 +1,11 @@ @@ -251,13 +376,12 @@ .ms-api-header-select { margin-left: 20px; - width: 150px; } .el-card-btn { float: right; top: 20px; - right: 20px; + right: 0px; padding: 0; background: 0 0; border: none; @@ -278,19 +402,6 @@ color: white; } - .ms-ap-collapse { - padding-top: 0px; - border: 0px; - } - - /deep/ .el-collapse-item__header { - border-bottom: 0px; - margin-top: 0px; - width: 300px; - line-height: 0px; - color: #666666; - } - .variable-combine { overflow: hidden; text-overflow: ellipsis; diff --git a/frontend/src/business/components/api/delimit/components/ApiConfig.vue b/frontend/src/business/components/api/delimit/components/ApiConfig.vue index 4b0f2ac7e2..3ac35def9d 100644 --- a/frontend/src/business/components/api/delimit/components/ApiConfig.vue +++ b/frontend/src/business/components/api/delimit/components/ApiConfig.vue @@ -1,13 +1,16 @@ diff --git a/frontend/src/business/components/api/delimit/components/ApiVariable.vue b/frontend/src/business/components/api/delimit/components/ApiVariable.vue index cd36f59bf1..6abed3dcf9 100644 --- a/frontend/src/business/components/api/delimit/components/ApiVariable.vue +++ b/frontend/src/business/components/api/delimit/components/ApiVariable.vue @@ -67,7 +67,7 @@ + + diff --git a/frontend/src/business/components/api/delimit/components/auth/ApiAuthConfig.vue b/frontend/src/business/components/api/delimit/components/auth/ApiAuthConfig.vue new file mode 100644 index 0000000000..bec4ab9bfb --- /dev/null +++ b/frontend/src/business/components/api/delimit/components/auth/ApiAuthConfig.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/frontend/src/business/components/api/delimit/components/basis/AddBasisHttpApi.vue b/frontend/src/business/components/api/delimit/components/basis/AddBasisHttpApi.vue index 71ea9d52cc..24ed1f0f11 100644 --- a/frontend/src/business/components/api/delimit/components/basis/AddBasisHttpApi.vue +++ b/frontend/src/business/components/api/delimit/components/basis/AddBasisHttpApi.vue @@ -1,27 +1,38 @@ diff --git a/frontend/src/business/components/api/delimit/components/complete/AddCompleteHttpApi.vue b/frontend/src/business/components/api/delimit/components/complete/AddCompleteHttpApi.vue index 2792c7f1c1..ab3ce8aef5 100644 --- a/frontend/src/business/components/api/delimit/components/complete/AddCompleteHttpApi.vue +++ b/frontend/src/business/components/api/delimit/components/complete/AddCompleteHttpApi.vue @@ -1,48 +1,59 @@