diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java index f8d0f64f27..2a4568f8db 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java @@ -78,4 +78,8 @@ public interface ExtApiScenarioMapper { * @return 关联的用例ID集合 */ List getSelectIdsByAssociateParam(@Param("request") AssociateOtherCaseRequest request, @Param("deleted") boolean deleted); + + ApiScenario getScenarioByResourceId(String id); + + ApiScenario getScenarioByReportId(String reportId); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml index 16a785fc54..65588b3326 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml @@ -609,6 +609,16 @@ ) + + diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.java index b83fa3d8a0..db17b59f06 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.java @@ -97,4 +97,8 @@ public interface ExtApiTestCaseMapper { List getSelectIdsByAssociateParam(@Param("request") AssociateOtherCaseRequest request, @Param("deleted") boolean deleted); List getTestPlanNum(@Param("ids") List ids); + + ApiTestCase getCaseByResourceId(String resourceId); + + ApiTestCase getCaseByReportId(String resourceId); } \ No newline at end of file diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml index 0c2a6e73bf..c05124b6f2 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiTestCaseMapper.xml @@ -403,6 +403,18 @@ + + diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportSendNoticeService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportSendNoticeService.java index 55184a9767..a3dbaa04c1 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportSendNoticeService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportSendNoticeService.java @@ -8,10 +8,7 @@ import io.metersphere.api.domain.ApiScenarioReport; import io.metersphere.api.domain.ApiTestCase; import io.metersphere.api.dto.share.ApiReportShareRequest; import io.metersphere.api.dto.share.ShareInfoDTO; -import io.metersphere.api.mapper.ApiReportMapper; -import io.metersphere.api.mapper.ApiScenarioMapper; -import io.metersphere.api.mapper.ApiScenarioReportMapper; -import io.metersphere.api.mapper.ApiTestCaseMapper; +import io.metersphere.api.mapper.*; import io.metersphere.project.domain.Project; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.ApiExecuteResourceType; @@ -58,13 +55,13 @@ public class ApiReportSendNoticeService { private EnvironmentMapper environmentMapper; @Resource private ProjectMapper projectMapper; + @Resource + private ExtApiScenarioMapper extApiScenarioMapper; + @Resource + private ExtApiTestCaseMapper extApiTestCaseMapper; public void sendNotice(ApiNoticeDTO noticeDTO) { String noticeType = null; - if (StringUtils.equalsAnyIgnoreCase(noticeDTO.getResourceType(), - ApiExecuteResourceType.PLAN_RUN_API_CASE.name(), ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name())) { - return; - } SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class); assert systemParameterService != null; BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); @@ -81,8 +78,21 @@ public class ApiReportSendNoticeService { String shareUrl = baseSystemConfigDTO.getUrl() + "/#/share/%s?shareId=" + url.getId(); ApiScenarioReport report = new ApiScenarioReport(); if (StringUtils.equalsAnyIgnoreCase(noticeDTO.getResourceType(), - ApiExecuteResourceType.API_SCENARIO.name(), ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name())) { - ApiScenario scenario = apiScenarioMapper.selectByPrimaryKey(noticeDTO.getResourceId()); + ApiExecuteResourceType.API_SCENARIO.name(), ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name(), ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name())) { + ApiScenario scenario = null; + switch (ApiExecuteResourceType.valueOf(noticeDTO.getResourceType())) { + case ApiExecuteResourceType.API_SCENARIO -> + scenario = apiScenarioMapper.selectByPrimaryKey(noticeDTO.getResourceId()); + case ApiExecuteResourceType.TEST_PLAN_API_SCENARIO -> + scenario = extApiScenarioMapper.getScenarioByResourceId(noticeDTO.getResourceId()); + case ApiExecuteResourceType.PLAN_RUN_API_SCENARIO -> + scenario = extApiScenarioMapper.getScenarioByReportId(noticeDTO.getResourceId()); + default -> { + } + } + if (scenario == null) { + return; + } beanMap = new BeanMap(scenario); noticeType = NoticeConstants.TaskType.API_SCENARIO_TASK; report = apiScenarioReportMapper.selectByPrimaryKey(noticeDTO.getReportId()); @@ -96,8 +106,22 @@ public class ApiReportSendNoticeService { } shareUrl = String.format(shareUrl, "shareReportScenario"); } else if (StringUtils.equalsAnyIgnoreCase(noticeDTO.getResourceType(), - ApiExecuteResourceType.API_CASE.name(), ApiExecuteResourceType.TEST_PLAN_API_CASE.name())) { - ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(noticeDTO.getResourceId()); + ApiExecuteResourceType.API_CASE.name(), ApiExecuteResourceType.TEST_PLAN_API_CASE.name(), ApiExecuteResourceType.PLAN_RUN_API_CASE.name())) { + ApiTestCase testCase = null; + switch (ApiExecuteResourceType.valueOf(noticeDTO.getResourceType())) { + case ApiExecuteResourceType.API_CASE -> + testCase = apiTestCaseMapper.selectByPrimaryKey(noticeDTO.getResourceId()); + case ApiExecuteResourceType.TEST_PLAN_API_CASE -> + testCase = extApiTestCaseMapper.getCaseByResourceId(noticeDTO.getResourceId()); + case ApiExecuteResourceType.PLAN_RUN_API_CASE -> + testCase = extApiTestCaseMapper.getCaseByReportId(noticeDTO.getResourceId()); + default -> { + } + } + if (testCase == null) { + return; + } + beanMap = new BeanMap(testCase); // TODO 是否需要区分场景和用例 diff --git a/frontend/src/views/project-management/taskCenter/component/scheduledTask.vue b/frontend/src/views/project-management/taskCenter/component/scheduledTask.vue index 3c6c064d61..a11a518571 100644 --- a/frontend/src/views/project-management/taskCenter/component/scheduledTask.vue +++ b/frontend/src/views/project-management/taskCenter/component/scheduledTask.vue @@ -221,7 +221,7 @@ edit: ['ORGANIZATION_TASK_CENTER:READ+STOP', 'PROJECT_API_SCENARIO:READ+EXECUTE'], jump: ['PROJECT_API_SCENARIO:READ'], }, - TEST_CASE: { + TEST_PLAN: { edit: ['ORGANIZATION_TASK_CENTER:READ+STOP', 'PROJECT_TEST_PLAN:READ+EXECUTE'], jump: ['PROJECT_TEST_PLAN:READ'], }, @@ -234,7 +234,7 @@ edit: ['SYSTEM_TASK_CENTER:READ+STOP', 'PROJECT_API_SCENARIO:READ+EXECUTE'], jump: ['PROJECT_API_SCENARIO:READ'], }, - TEST_CASE: { + TEST_PLAN: { edit: ['SYSTEM_TASK_CENTER:READ+STOP', 'PROJECT_TEST_PLAN:READ+EXECUTE'], jump: ['PROJECT_TEST_PLAN:READ'], }, @@ -247,7 +247,7 @@ edit: ['PROJECT_API_SCENARIO:READ+EXECUTE'], jump: ['PROJECT_API_SCENARIO:READ'], }, - TEST_CASE: { + TEST_PLAN: { edit: ['PROJECT_TEST_PLAN:READ+EXECUTE'], jump: ['PROJECT_TEST_PLAN:READ'], },