refactor(接口测试): 优化发通知
This commit is contained in:
parent
6f5b9c740b
commit
c0eb21dc22
|
@ -78,4 +78,8 @@ public interface ExtApiScenarioMapper {
|
|||
* @return 关联的用例ID集合
|
||||
*/
|
||||
List<String> getSelectIdsByAssociateParam(@Param("request") AssociateOtherCaseRequest request, @Param("deleted") boolean deleted);
|
||||
|
||||
ApiScenario getScenarioByResourceId(String id);
|
||||
|
||||
ApiScenario getScenarioByReportId(String reportId);
|
||||
}
|
||||
|
|
|
@ -609,6 +609,16 @@
|
|||
)
|
||||
<include refid="queryByAssociateParam"/>
|
||||
</select>
|
||||
<select id="getScenarioByResourceId" resultType="io.metersphere.api.domain.ApiScenario">
|
||||
select api_scenario.* from api_scenario
|
||||
inner join test_plan_api_scenario on api_scenario.id = test_plan_api_scenario.api_scenario_id
|
||||
where test_plan_api_scenario.id = #{id}
|
||||
</select>
|
||||
<select id="getScenarioByReportId" resultType="io.metersphere.api.domain.ApiScenario">
|
||||
select api_scenario.* from api_scenario
|
||||
inner join test_plan_report_api_scenario tpras on api_scenario.id = tpras.api_scenario_id
|
||||
where tpras.id = #{reportId}
|
||||
</select>
|
||||
|
||||
<sql id="report_filters">
|
||||
<if test="${filter} != null and ${filter}.size() > 0">
|
||||
|
|
|
@ -97,4 +97,8 @@ public interface ExtApiTestCaseMapper {
|
|||
List<String> getSelectIdsByAssociateParam(@Param("request") AssociateOtherCaseRequest request, @Param("deleted") boolean deleted);
|
||||
|
||||
List<ExecuteReportDTO> getTestPlanNum(@Param("ids") List<String> ids);
|
||||
|
||||
ApiTestCase getCaseByResourceId(String resourceId);
|
||||
|
||||
ApiTestCase getCaseByReportId(String resourceId);
|
||||
}
|
|
@ -403,6 +403,18 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getCaseByResourceId" resultType="io.metersphere.api.domain.ApiTestCase">
|
||||
select api_test_case.*
|
||||
from api_test_case
|
||||
inner join test_plan_api_case on api_test_case.id = test_plan_api_case.api_case_id
|
||||
where test_plan_api_case.id = #{resourceId}
|
||||
</select>
|
||||
<select id="getCaseByReportId" resultType="io.metersphere.api.domain.ApiTestCase">
|
||||
select atc.*
|
||||
from api_test_case atc
|
||||
inner join test_plan_report_api_case tprac on atc.id = tprac.api_case_id
|
||||
where tprac.id = #{reportId}
|
||||
</select>
|
||||
|
||||
<sql id="report_filters">
|
||||
<if test="${filter} != null and ${filter}.size() > 0">
|
||||
|
|
|
@ -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 是否需要区分场景和用例
|
||||
|
|
|
@ -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'],
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue