diff --git a/test-track/backend/src/main/java/io/metersphere/controller/remote/TrackApiCaseController.java b/test-track/backend/src/main/java/io/metersphere/controller/remote/TrackApiCaseController.java new file mode 100644 index 0000000000..382e1f180b --- /dev/null +++ b/test-track/backend/src/main/java/io/metersphere/controller/remote/TrackApiCaseController.java @@ -0,0 +1,27 @@ +package io.metersphere.controller.remote; + +import io.metersphere.dto.ApiCaseRelevanceRequest; +import io.metersphere.plan.service.TestPlanService; +import io.metersphere.service.remote.api.RelevanceApiCaseService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RequestMapping("/api/testcase") +@RestController +public class TrackApiCaseController { + + @Resource + RelevanceApiCaseService relevanceApiCaseService; + @Resource + TestPlanService testPlanService; + + @PostMapping("/relevance") + public void relevance(@RequestBody ApiCaseRelevanceRequest request) { + request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getPlanId())); + relevanceApiCaseService.relevance(request); + } +} diff --git a/test-track/backend/src/main/java/io/metersphere/controller/remote/TrackApiDefinitionController.java b/test-track/backend/src/main/java/io/metersphere/controller/remote/TrackApiDefinitionController.java index 9996fc44f1..ce6f2edebf 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/remote/TrackApiDefinitionController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/remote/TrackApiDefinitionController.java @@ -1,6 +1,8 @@ package io.metersphere.controller.remote; +import io.metersphere.dto.ApiCaseRelevanceRequest; import io.metersphere.plan.request.api.ApiDefinitionRequest; +import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.service.remote.api.PlanApiDefinitionService; import org.springframework.web.bind.annotation.*; @@ -12,10 +14,18 @@ public class TrackApiDefinitionController { @Resource PlanApiDefinitionService planApiDefinitionService; + @Resource + TestPlanService testPlanService; @PostMapping("/list/relevance/{goPage}/{pageSize}") public Object listRelevance(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) { return planApiDefinitionService.listRelevance(request, goPage, pageSize); } + + @PostMapping("/relevance") + public void relevance(@RequestBody ApiCaseRelevanceRequest request) { + request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getPlanId())); + planApiDefinitionService.relevance(request); + } } diff --git a/test-track/backend/src/main/java/io/metersphere/dto/ApiCaseRelevanceRequest.java b/test-track/backend/src/main/java/io/metersphere/dto/ApiCaseRelevanceRequest.java new file mode 100644 index 0000000000..f8b06219a1 --- /dev/null +++ b/test-track/backend/src/main/java/io/metersphere/dto/ApiCaseRelevanceRequest.java @@ -0,0 +1,49 @@ +package io.metersphere.dto; + +import io.metersphere.plan.request.api.ApiScenarioRequest; +import lombok.Getter; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Getter +@Setter +public class ApiCaseRelevanceRequest { + /** + * 测试计划ID + */ + private String planId; + + private String environmentId; + + /** + * 具体要关联的用例 + */ + private List selectIds = new ArrayList<>(); + + /** + * 项目环境对应关系 + */ + private Map envMap; + + /** + * 用例的环境的对应关系 + */ + private Map> mapping; + /** + *测试评审ID + */ + private String reviewId; + + private String environmentType; + + private String envGroupId; + + private List ids; + + private ApiScenarioRequest condition; + + private Boolean allowedRepeatCase = false; +} diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanApiDefinitionService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanApiDefinitionService.java index 0ef9461b37..2d72bd1d1d 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanApiDefinitionService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanApiDefinitionService.java @@ -1,5 +1,6 @@ package io.metersphere.plan.service.remote.api; +import io.metersphere.dto.ApiCaseRelevanceRequest; import io.metersphere.plan.request.api.ApiDefinitionRequest; import io.metersphere.plan.service.TestPlanService; import org.apache.commons.lang3.StringUtils; @@ -11,7 +12,7 @@ import javax.annotation.Resource; @Service public class PlanApiDefinitionService extends ApiTestService { - private static final String BASE_UEL = "/api/definition"; + private static final String BASE_URL = "/api/definition"; @Resource @Lazy @@ -21,6 +22,11 @@ public class PlanApiDefinitionService extends ApiTestService { if (StringUtils.isNotBlank(request.getPlanId()) && testPlanService.isAllowedRepeatCase(request.getPlanId())) { request.setRepeatCase(true); } - return microService.postForData(serviceName, BASE_UEL + String.format("/list/relevance/%s/%s", pageNum, pageSize), request); + return microService.postForData(serviceName, BASE_URL + String.format("/list/relevance/%s/%s", pageNum, pageSize), request); } + + public void relevance(ApiCaseRelevanceRequest request) { + microService.postForData(serviceName, BASE_URL + "/relevance", request); + } + } diff --git a/test-track/backend/src/main/java/io/metersphere/service/remote/api/RelevanceApiCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/remote/api/RelevanceApiCaseService.java index 1ef1fe7379..8bb5796e94 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/remote/api/RelevanceApiCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/remote/api/RelevanceApiCaseService.java @@ -2,6 +2,7 @@ package io.metersphere.service.remote.api; import io.metersphere.base.domain.ApiScenario; import io.metersphere.base.domain.ApiTestCase; +import io.metersphere.dto.ApiCaseRelevanceRequest; import org.springframework.stereotype.Service; import java.util.List; @@ -15,6 +16,10 @@ public class RelevanceApiCaseService extends TrackApiTestService{ return microService.postForDataArray(serviceName, BASE_URL + "/getApiCaseByIds", ids, ApiTestCase.class); } + public void relevance(ApiCaseRelevanceRequest param) { + microService.postForData(serviceName, BASE_URL + "/relevance", param); + } + public List getScenarioCaseByIds(List ids) { return microService.postForDataArray(serviceName, BASE_URL + "/getScenarioCaseByIds", ids, ApiScenario.class); }