From 854e4b2412d64057c2643e64ee74430fb149a090 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 16 Apr 2024 20:52:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=89=A7=E8=A1=8C=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=B8=85=E7=90=86=E5=92=8C=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/ExecuteReportDTO.java | 6 +++ .../api/mapper/ExtApiReportMapper.java | 3 ++ .../api/mapper/ExtApiReportMapper.xml | 13 ++++- .../mapper/ExtApiScenarioReportMapper.java | 4 ++ .../api/mapper/ExtApiScenarioReportMapper.xml | 13 ++++- .../api/mapper/ExtApiTestCaseMapper.xml | 3 +- .../api/service/ApiTaskCenterService.java | 21 +++++--- .../service/definition/ApiReportService.java | 41 +++------------- .../ApiTestCaseBatchRunService.java | 3 ++ .../definition/ApiTestCaseService.java | 20 ++++++++ .../service/scenario/ApiScenarioService.java | 8 ++++ .../controller/ApiReportControllerTests.java | 48 ------------------- .../system/dto/taskcenter/TaskCenterDTO.java | 3 ++ .../case/tabContent/tabCaseExecuteHistory.vue | 26 ++++++++-- .../scenario/components/executeHistory.vue | 28 +++++++++-- .../taskCenter/component/apiCase.vue | 28 ++++++++--- .../taskCenter/locale/en-US.ts | 1 + .../taskCenter/locale/zh-CN.ts | 1 + 18 files changed, 164 insertions(+), 106 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ExecuteReportDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ExecuteReportDTO.java index d0f7a915b5..3ef364403f 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ExecuteReportDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ExecuteReportDTO.java @@ -33,6 +33,12 @@ public class ExecuteReportDTO implements Serializable { @Schema(description = "是否删除") private boolean deleted; + @Schema(description = "执行历史是否被清理") + private boolean historyDeleted = false; + + @Schema(description = "是否集成") + private boolean integrated; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.java index c41f7dff12..28eaca4f5b 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.java @@ -4,6 +4,7 @@ import io.metersphere.api.domain.ApiReport; import io.metersphere.api.dto.definition.ApiReportBatchRequest; import io.metersphere.api.dto.definition.ApiReportPageRequest; import io.metersphere.api.dto.definition.ApiReportStepDTO; +import io.metersphere.api.dto.definition.ExecuteReportDTO; import io.metersphere.api.dto.report.ReportDTO; import io.metersphere.system.dto.sdk.ApiReportMessageDTO; import io.metersphere.system.dto.taskcenter.TaskCenterDTO; @@ -41,4 +42,6 @@ public interface ExtApiReportMapper { void updateApiCaseStatus(@Param("ids") List ids); List getNoticeList(@Param("ids") List ids); + + List getHistoryDeleted(@Param("ids") List ids); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml index fcebf7fc74..890464b4aa 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml @@ -194,8 +194,8 @@ LEFT JOIN api_test_case c ON a.api_test_case_id = c.id LEFT JOIN test_resource_pool t ON ar.pool_id = t.id left join project on ar.project_id = project.id - where ar.deleted = false - and ar.test_plan_id = 'NONE' + where + ar.test_plan_id = 'NONE' and ar.start_time BETWEEN #{startTime} AND #{endTime} ) as api_report where @@ -265,5 +265,14 @@ + diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.java index 48e7782ee7..38ad66d837 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.java @@ -4,6 +4,7 @@ import io.metersphere.api.domain.ApiScenarioBlob; import io.metersphere.api.domain.ApiScenarioReport; import io.metersphere.api.dto.definition.ApiReportBatchRequest; import io.metersphere.api.dto.definition.ApiReportPageRequest; +import io.metersphere.api.dto.definition.ExecuteReportDTO; import io.metersphere.api.dto.report.ReportDTO; import io.metersphere.api.dto.scenario.ApiScenarioReportStepDTO; import io.metersphere.system.dto.sdk.ApiReportMessageDTO; @@ -54,4 +55,7 @@ public interface ExtApiScenarioReportMapper { List selectStepDeatilByReportId(String id); List getNoticeList(@Param("ids") List ids); + + + List getHistoryDeleted(@Param("ids") List ids); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.xml index 7c64adbe70..e89d986825 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioReportMapper.xml @@ -173,8 +173,7 @@ left JOIN api_scenario s on a.api_scenario_id = s.id left JOIN test_resource_pool t on asr.pool_id = t.id left join project on asr.project_id = project.id - where asr.deleted = false - and asr.test_plan_id = 'NONE' + where asr.test_plan_id = 'NONE' and asr.start_time BETWEEN #{startTime} AND #{endTime} ) api_scenario_report where api_scenario_report.project_id IN @@ -245,6 +244,16 @@ + 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 0cf930bfcd..3b6a9f581d 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 @@ -246,7 +246,8 @@ api_report.create_user, api_report.trigger_mode, api_report.test_plan_id, - api_report.deleted + api_report.deleted, + api_report.integrated from api_report left join api_test_case_record atc on atc.api_report_id = api_report.id where diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java index 20a85f6397..8fd8f37e6c 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java @@ -2,6 +2,7 @@ package io.metersphere.api.service; import com.github.pagehelper.Page; import com.github.pagehelper.page.PageMethod; +import io.metersphere.api.dto.definition.ExecuteReportDTO; import io.metersphere.api.dto.report.ReportDTO; import io.metersphere.api.mapper.ExtApiReportMapper; import io.metersphere.api.mapper.ExtApiScenarioReportMapper; @@ -36,14 +37,13 @@ import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.TaskRunnerClient; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -131,17 +131,25 @@ public class ApiTaskCenterService { List list = new ArrayList<>(); List projectIds = projectList.stream().map(OptionDTO::getId).toList(); if (request != null && !projectIds.isEmpty()) { + Map historyDeletedMap = new HashMap<>(); if (request.getModuleType().equals(TaskCenterResourceType.API_CASE.toString())) { list = extApiReportMapper.taskCenterlist(request, projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); + //执行历史列表 + List reportIds = list.stream().map(TaskCenterDTO::getId).toList(); + List historyDeletedList = extApiReportMapper.getHistoryDeleted(reportIds); + historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity())); } else if (request.getModuleType().equals(TaskCenterResourceType.API_SCENARIO.toString())) { list = extApiScenarioReportMapper.taskCenterlist(request, projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); + List reportIds = list.stream().map(TaskCenterDTO::getId).toList(); + List historyDeletedList = extApiScenarioReportMapper.getHistoryDeleted(reportIds); + historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity())); } - processTaskCenter(list, projectList, projectIds); + processTaskCenter(list, projectList, projectIds, historyDeletedMap); } return list; } - private void processTaskCenter(List list, List projectList, List projectIds) { + private void processTaskCenter(List list, List projectList, List projectIds, Map historyDeletedMap) { if (!list.isEmpty()) { // 取所有的userid Set userSet = list.stream() @@ -158,6 +166,7 @@ public class ApiTaskCenterService { item.setOperationName(userMap.getOrDefault(item.getOperationName(), StringUtils.EMPTY)); item.setProjectName(projectMap.getOrDefault(item.getProjectId(), StringUtils.EMPTY)); item.setOrganizationName(orgMap.getOrDefault(item.getProjectId(), StringUtils.EMPTY)); + item.setHistoryDeleted(MapUtils.isNotEmpty(historyDeletedMap) && !historyDeletedMap.containsKey(item.getId())); }); } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java index 13468d6bf1..4b30baa9b7 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiReportService.java @@ -5,7 +5,6 @@ import io.metersphere.api.dto.definition.*; import io.metersphere.api.dto.report.ApiReportListDTO; import io.metersphere.api.mapper.*; import io.metersphere.api.utils.ApiDataUtils; -import io.metersphere.sdk.constants.ApiExecuteResourceType; import io.metersphere.sdk.constants.ApiReportStatus; import io.metersphere.sdk.domain.Environment; import io.metersphere.sdk.domain.EnvironmentGroup; @@ -23,7 +22,6 @@ import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.service.UserLoginService; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -215,41 +213,14 @@ public class ApiReportService { apiReportDTO.setEnvironmentName(environmentName); apiReportDTO.setCreatUserName(userMapper.selectByPrimaryKey(apiReportDTO.getCreateUser()).getName()); //需要查询出所有的步骤 - if (BooleanUtils.isTrue(apiReport.getIntegrated())) { - List apiReportSteps = extApiReportMapper.selectStepsByReportId(id); - if (CollectionUtils.isEmpty(apiReportSteps)) { - throw new MSException(Translator.get("api_case_report_not_exist")); - } - apiReportSteps.sort(Comparator.comparingLong(ApiReportStepDTO::getSort)); - apiReportDTO.setChildren(apiReportSteps); - apiReportDTO.setTotal((long) apiReportSteps.size()); - apiReportDTO.setPendingCount(apiReportSteps.stream().filter(step -> StringUtils.equals(ApiReportStatus.PENDING.name(), step.getStatus()) || StringUtils.isBlank(step.getStatus())).count()); - return apiReportDTO; - } - ApiTestCaseRecordExample example = new ApiTestCaseRecordExample(); - example.createCriteria().andApiReportIdEqualTo(id); - List apiTestCaseRecords = apiTestCaseRecordMapper.selectByExample(example); - if (CollectionUtils.isEmpty(apiTestCaseRecords)) { + List apiReportSteps = extApiReportMapper.selectStepsByReportId(id); + if (CollectionUtils.isEmpty(apiReportSteps)) { throw new MSException(Translator.get("api_case_report_not_exist")); } - ApiReportDetailExample apiReportDetailExample = new ApiReportDetailExample(); - apiReportDetailExample.createCriteria().andReportIdEqualTo(id).andStepIdEqualTo(apiTestCaseRecords.getFirst().getApiTestCaseId()); - List apiReportDetails = apiReportDetailMapper.selectByExampleWithBLOBs(apiReportDetailExample); - if (CollectionUtils.isNotEmpty(apiReportDetails)) { - ApiReportStepDTO apiReportStepDTO = new ApiReportStepDTO(); - BeanUtils.copyBean(apiReportStepDTO, apiReportDetails.getFirst()); - apiReportStepDTO.setStepId(apiTestCaseRecords.getFirst().getApiTestCaseId()); - apiReportStepDTO.setReportId(id); - apiReportStepDTO.setSort(1L); - apiReportStepDTO.setName(apiReport.getName()); - apiReportStepDTO.setStepType(ApiExecuteResourceType.API_CASE.name()); - List apiReportSteps = new ArrayList<>(); - apiReportSteps.add(apiReportStepDTO); - apiReportDTO.setChildren(apiReportSteps); - } else { - apiReportDTO.setTotal(1L); - apiReportDTO.setPendingCount(1L); - } + apiReportSteps.sort(Comparator.comparingLong(ApiReportStepDTO::getSort)); + apiReportDTO.setChildren(apiReportSteps); + apiReportDTO.setTotal((long) apiReportSteps.size()); + apiReportDTO.setPendingCount(apiReportSteps.stream().filter(step -> StringUtils.equals(ApiReportStatus.PENDING.name(), step.getStatus()) || StringUtils.isBlank(step.getStatus())).count()); return apiReportDTO; } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java index 4cd777d139..7ffe6d5b95 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseBatchRunService.java @@ -366,6 +366,7 @@ public class ApiTestCaseBatchRunService { public List initApiReport(ApiRunModeConfigDTO runModeConfig, List apiTestCases, String userId) { List apiReports = new ArrayList<>(); List apiTestCaseRecords = new ArrayList<>(); + List apiReportSteps = new ArrayList<>(); for (ApiTestCase apiTestCase : apiTestCases) { // 初始化报告 ApiReport apiReport = getApiReport(runModeConfig, apiTestCase, userId); @@ -373,8 +374,10 @@ public class ApiTestCaseBatchRunService { // 创建报告和用例的关联关系 ApiTestCaseRecord apiTestCaseRecord = apiTestCaseService.getApiTestCaseRecord(apiTestCase, apiReport); apiTestCaseRecords.add(apiTestCaseRecord); + apiReportSteps.add(getApiReportStep(apiTestCase, apiReport.getId(), 1)); } apiReportService.insertApiReport(apiReports, apiTestCaseRecords); + apiReportService.insertApiReportStep(apiReportSteps); return apiTestCaseRecords; } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java index 1664dbe745..3226a120e0 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiTestCaseService.java @@ -102,6 +102,8 @@ public class ApiTestCaseService extends MoveNodeService { private EnvironmentService environmentService; @Resource private ApiTestCaseNoticeService apiTestCaseNoticeService; + @Resource + private ExtApiReportMapper extApiReportMapper; private static final String CASE_TABLE = "api_test_case"; private static final int MAX_TAG_SIZE = 10; @@ -557,10 +559,16 @@ public class ApiTestCaseService extends MoveNodeService { .collect(Collectors.toSet()); Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userSet)); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + //执行历史列表 + List reportIds = executeList.stream().map(ExecuteReportDTO::getId).toList(); + List historyDeletedList = extApiReportMapper.getHistoryDeleted(reportIds); + Map historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity())); + executeList.forEach(apiReport -> { apiReport.setOperationUser(userMap.get(apiReport.getCreateUser())); Date date = new Date(apiReport.getStartTime()); apiReport.setNum(sdf.format(date)); + apiReport.setHistoryDeleted(MapUtils.isNotEmpty(historyDeletedMap) && !historyDeletedMap.containsKey(apiReport.getId())); }); return executeList; } @@ -754,9 +762,21 @@ public class ApiTestCaseService extends MoveNodeService { ApiTestCaseRecord apiTestCaseRecord = getApiTestCaseRecord(apiTestCase, apiReport); apiReportService.insertApiReport(List.of(apiReport), List.of(apiTestCaseRecord)); + //初始化步骤 + apiReportService.insertApiReportStep(List.of(getApiReportStep(apiTestCase, reportId, 1L))); return apiTestCaseRecord; } + private ApiReportStep getApiReportStep(ApiTestCase apiTestCase, String reportId, long sort) { + ApiReportStep apiReportStep = new ApiReportStep(); + apiReportStep.setReportId(reportId); + apiReportStep.setStepId(apiTestCase.getId()); + apiReportStep.setSort(sort); + apiReportStep.setName(apiTestCase.getName()); + apiReportStep.setStepType(ApiExecuteResourceType.API_CASE.name()); + return apiReportStep; + } + public ApiTestCaseRecord getApiTestCaseRecord(ApiTestCase apiTestCase, ApiReport apiReport) { ApiTestCaseRecord apiTestCaseRecord = new ApiTestCaseRecord(); apiTestCaseRecord.setApiTestCaseId(apiTestCase.getId()); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java index 28848d95cf..f09a6d6bcc 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java @@ -192,6 +192,8 @@ public class ApiScenarioService extends MoveNodeService { private ApiScenarioReportMapper apiScenarioReportMapper; @Resource private ApiScenarioNoticeService apiScenarioNoticeService; + @Resource + private ExtApiScenarioReportMapper extApiScenarioReportMapper; public static final String PRIORITY = "Priority"; public static final String STATUS = "Status"; @@ -2823,12 +2825,18 @@ public class ApiScenarioService extends MoveNodeService { Set userSet = executeList.stream() .flatMap(apiReport -> Stream.of(apiReport.getCreateUser())) .collect(Collectors.toSet()); + //执行历史列表 + List reportIds = executeList.stream().map(ExecuteReportDTO::getId).toList(); + List historyDeletedList = extApiScenarioReportMapper.getHistoryDeleted(reportIds); + Map historyDeletedMap = historyDeletedList.stream().collect(Collectors.toMap(ExecuteReportDTO::getId, Function.identity())); + Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userSet)); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); executeList.forEach(apiReport -> { apiReport.setOperationUser(userMap.get(apiReport.getCreateUser())); Date date = new Date(apiReport.getStartTime()); apiReport.setNum(sdf.format(date)); + apiReport.setHistoryDeleted(MapUtils.isNotEmpty(historyDeletedMap) && !historyDeletedMap.containsKey(apiReport.getId())); }); return executeList; } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiReportControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiReportControllerTests.java index 75e5fdfb09..d92f665d19 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiReportControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiReportControllerTests.java @@ -352,54 +352,6 @@ public class ApiReportControllerTests extends BaseTest { .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is5xxServerError()); - reports = new ArrayList<>(); - apiReport = new ApiReport(); - apiReport.setId("test-report-id-no-step"); - apiReport.setProjectId(DEFAULT_PROJECT_ID); - apiReport.setName("test-report-name"); - apiReport.setStartTime(System.currentTimeMillis()); - apiReport.setCreateUser("admin"); - apiReport.setUpdateUser("admin"); - apiReport.setUpdateTime(System.currentTimeMillis()); - apiReport.setPoolId(testResourcePools.getFirst().getId()); - apiReport.setEnvironmentId(environments.getFirst().getId()); - apiReport.setRunMode("api-run-mode"); - apiReport.setStatus(ApiReportStatus.SUCCESS.name()); - apiReport.setTriggerMode("api-trigger-mode"); - apiReport.setIntegrated(false); - reports.add(apiReport); - record = new ApiTestCaseRecord(); - record.setApiTestCaseId("api-resource-id"); - record.setApiReportId(apiReport.getId()); - apiReportService.insertApiReport(reports, List.of(record)); - - mockMvc.perform(getRequestBuilder(GET + "test-report-id-no-step")) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().is2xxSuccessful()); - - reports = new ArrayList<>(); - apiReport = new ApiReport(); - apiReport.setId("test-report-id-no-step-no-record"); - apiReport.setProjectId(DEFAULT_PROJECT_ID); - apiReport.setName("test-report-name"); - apiReport.setStartTime(System.currentTimeMillis()); - apiReport.setCreateUser("admin"); - apiReport.setUpdateUser("admin"); - apiReport.setUpdateTime(System.currentTimeMillis()); - apiReport.setPoolId(testResourcePools.getFirst().getId()); - apiReport.setEnvironmentId(environments.getFirst().getId()); - apiReport.setRunMode("api-run-mode"); - apiReport.setStatus(ApiReportStatus.SUCCESS.name()); - apiReport.setTriggerMode("api-trigger-mode"); - apiReport.setIntegrated(false); - reports.add(apiReport); - apiReportService.insertApiReport(reports, new ArrayList<>()); - - mockMvc.perform(getRequestBuilder(GET + "test-report-id-no-step-no-record")) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().is5xxServerError()); - - // @@校验权限 requestGetPermissionTest(PermissionConstants.PROJECT_API_REPORT_READ, GET + "api-report-id0"); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskcenter/TaskCenterDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskcenter/TaskCenterDTO.java index cd36a70a8d..9151407d9a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskcenter/TaskCenterDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/taskcenter/TaskCenterDTO.java @@ -58,5 +58,8 @@ public class TaskCenterDTO implements Serializable { @Schema(description = "是否为集合报告") private boolean integrated; + @Schema(description = "执行历史是否被清理") + private boolean historyDeleted = false; + } diff --git a/frontend/src/views/api-test/management/components/management/case/tabContent/tabCaseExecuteHistory.vue b/frontend/src/views/api-test/management/components/management/case/tabContent/tabCaseExecuteHistory.vue index f6db5868f3..8411920038 100644 --- a/frontend/src/views/api-test/management/components/management/case/tabContent/tabCaseExecuteHistory.vue +++ b/frontend/src/views/api-test/management/components/management/case/tabContent/tabCaseExecuteHistory.vue @@ -83,11 +83,30 @@ @@ -107,6 +126,7 @@ import { getApiCaseExecuteHistory } from '@/api/modules/api-test/management'; import { useI18n } from '@/hooks/useI18n'; import useAppStore from '@/store/modules/app'; + import { hasAnyPermission } from '@/utils/permission'; import { ApiCaseExecuteHistoryItem } from '@/models/apiTest/management'; import { ReportEnum, ReportStatus, TriggerModeLabel } from '@/enums/reportEnum'; diff --git a/frontend/src/views/api-test/scenario/components/executeHistory.vue b/frontend/src/views/api-test/scenario/components/executeHistory.vue index 881e6036fe..4da211f393 100644 --- a/frontend/src/views/api-test/scenario/components/executeHistory.vue +++ b/frontend/src/views/api-test/scenario/components/executeHistory.vue @@ -75,9 +75,30 @@ @@ -98,6 +119,7 @@ import { getExecuteHistory } from '@/api/modules/api-test/scenario'; import { useI18n } from '@/hooks/useI18n'; + import { hasAnyPermission } from '@/utils/permission'; import { ExecuteHistoryItem } from '@/models/apiTest/scenario'; import { ExecuteStatusFilters } from '@/enums/apiEnum'; diff --git a/frontend/src/views/project-management/taskCenter/component/apiCase.vue b/frontend/src/views/project-management/taskCenter/component/apiCase.vue index e0d8806fff..38c049be8f 100644 --- a/frontend/src/views/project-management/taskCenter/component/apiCase.vue +++ b/frontend/src/views/project-management/taskCenter/component/apiCase.vue @@ -133,12 +133,27 @@ {{ dayjs(record.operationTime).format('YYYY-MM-DD HH:mm:ss') }}