diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java index 36483cad45..3b98df58c6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java @@ -33,8 +33,8 @@ public class ApiDefinitionModuleController { @Operation(summary = "接口测试-接口管理-模块-查找模块") @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) @CheckOwner(resourceId = "#request.projectId", resourceType = "project") - public List getTree(@RequestBody @Validated ApiModuleRequest request) { - return apiDefinitionModuleService.getTree(request, false); + public List getTreeAndRequest(@RequestBody @Validated ApiModuleRequest request) { + return apiDefinitionModuleService.getTree(request, false, true); } @PostMapping("/add") @@ -97,4 +97,12 @@ public class ApiDefinitionModuleController { public EnvApiTreeDTO envTree(@RequestBody @Validated EnvApiModuleRequest request) { return apiDefinitionModuleService.envTree(request); } + + @PostMapping("/only/tree") + @Operation(summary = "接口测试-接口管理-模块-不包含请求数据的模块树") + @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) + @CheckOwner(resourceId = "#request.projectId", resourceType = "project") + public List getTree(@RequestBody @Validated ApiModuleRequest request) { + return apiDefinitionModuleService.getTree(request, false, false); + } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportShareService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportShareService.java index e7886d2ef8..dc470de019 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportShareService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiReportShareService.java @@ -40,7 +40,7 @@ public class ApiReportShareService { @Resource private ApiScenarioReportMapper apiScenarioReportMapper; - private static final Long DEFAULT = 1000L * 60 * 60 * 24 * 30; + private static final Long DEFAULT = 1000L * 60 * 60 * 24; @Transactional(propagation = Propagation.NOT_SUPPORTED) public void validateExpired(ShareInfo shareInfo) { diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiReportServiceImpl.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiReportServiceImpl.java new file mode 100644 index 0000000000..74755d7ac9 --- /dev/null +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiReportServiceImpl.java @@ -0,0 +1,95 @@ +package io.metersphere.api.service; + +import io.metersphere.api.domain.*; +import io.metersphere.api.mapper.*; +import io.metersphere.sdk.constants.ProjectApplicationType; +import io.metersphere.sdk.util.LogUtils; +import io.metersphere.system.service.BaseCleanUpReport; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +import static io.metersphere.sdk.util.ShareUtil.getCleanDate; + +@Component +@Transactional(rollbackFor = Exception.class) +public class CleanupApiReportServiceImpl implements BaseCleanUpReport { + + @Resource + private ApiReportMapper apiReportMapper; + @Resource + private ExtApiReportMapper extApiReportMapper; + @Resource + private ApiReportStepMapper apiReportStepMapper; + @Resource + private ApiReportDetailMapper apiReportDetailMapper; + @Resource + private ApiReportLogMapper apiReportLogMapper; + @Resource + private ApiScenarioReportMapper apiScenarioReportMapper; + @Resource + private ExtApiScenarioReportMapper extApiScenarioReportMapper; + @Resource + private ApiScenarioReportStepMapper apiScenarioReportStepMapper; + @Resource + private ApiScenarioReportDetailMapper apiScenarioReportDetailMapper; + @Resource + private ApiScenarioReportLogMapper apiScenarioReportLogMapper; + + @Override + public void cleanReport(Map map, String projectId) { + LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告"); + String expr = map.get(ProjectApplicationType.API.API_CLEAN_REPORT.name()); + long timeMills = getCleanDate(expr); + int apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId); + while (apiReportCount > 0) { + List ids = extApiReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId); + ApiReportExample reportExample = new ApiReportExample(); + reportExample.createCriteria().andIdIn(ids); + ApiReport report = new ApiReport(); + report.setDeleted(true); + apiReportMapper.updateByExampleSelective(report, reportExample); + deleteApiReport(ids); + apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId); + } + int scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId); + while (scenarioReportCount > 0) { + List ids = extApiScenarioReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId); + ApiScenarioReportExample reportExample = new ApiScenarioReportExample(); + reportExample.createCriteria().andIdIn(ids); + ApiScenarioReport report = new ApiScenarioReport(); + report.setDeleted(true); + apiScenarioReportMapper.updateByExampleSelective(report, reportExample); + deleteScenarioReport(ids); + scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId); + } + } + + private void deleteApiReport(List ids) { + ApiReportStepExample stepExample = new ApiReportStepExample(); + stepExample.createCriteria().andReportIdIn(ids); + apiReportStepMapper.deleteByExample(stepExample); + ApiReportDetailExample detailExample = new ApiReportDetailExample(); + detailExample.createCriteria().andReportIdIn(ids); + apiReportDetailMapper.deleteByExample(detailExample); + ApiReportLogExample logExample = new ApiReportLogExample(); + logExample.createCriteria().andReportIdIn(ids); + apiReportLogMapper.deleteByExample(logExample); + } + + private void deleteScenarioReport(List ids) { + ApiScenarioReportStepExample stepExample = new ApiScenarioReportStepExample(); + stepExample.createCriteria().andReportIdIn(ids); + apiScenarioReportStepMapper.deleteByExample(stepExample); + ApiScenarioReportDetailExample detailExample = new ApiScenarioReportDetailExample(); + detailExample.createCriteria().andReportIdIn(ids); + apiScenarioReportDetailMapper.deleteByExample(detailExample); + ApiScenarioReportLogExample logExample = new ApiScenarioReportLogExample(); + logExample.createCriteria().andReportIdIn(ids); + apiScenarioReportLogMapper.deleteByExample(logExample); + } + +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiResourceService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiResourceServiceImpl.java similarity index 80% rename from backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiResourceService.java rename to backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiResourceServiceImpl.java index c917b57e9d..e95ccd8ad0 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiResourceService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiResourceServiceImpl.java @@ -3,12 +3,8 @@ package io.metersphere.api.service; import io.metersphere.api.domain.*; import io.metersphere.api.mapper.*; import io.metersphere.api.service.schedule.SwaggerUrlImportJob; -import io.metersphere.project.domain.ProjectApplication; -import io.metersphere.project.domain.ProjectApplicationExample; -import io.metersphere.project.mapper.ProjectApplicationMapper; import io.metersphere.sdk.constants.DefaultRepositoryDir; import io.metersphere.sdk.constants.OperationLogConstants; -import io.metersphere.sdk.constants.ProjectApplicationType; import io.metersphere.sdk.domain.ShareInfoExample; import io.metersphere.sdk.mapper.ShareInfoMapper; import io.metersphere.sdk.util.LogUtils; @@ -28,12 +24,9 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; -import static io.metersphere.sdk.util.ShareUtil.getCleanDate; - @Component @Transactional(rollbackFor = Exception.class) -public class CleanupApiResourceService implements CleanupProjectResourceService { - +public class CleanupApiResourceServiceImpl implements CleanupProjectResourceService { @Resource private ApiDefinitionModuleMapper apiDefinitionModuleMapper; @@ -88,12 +81,8 @@ public class CleanupApiResourceService implements CleanupProjectResourceService @Resource private ShareInfoMapper shareInfoMapper; @Resource - private ProjectApplicationMapper projectApplicationMapper; - @Resource private ApiDefinitionSwaggerMapper apiDefinitionSwaggerMapper; - private static final String DEFAULT = "30D"; - @Async @Override @@ -119,46 +108,6 @@ public class CleanupApiResourceService implements CleanupProjectResourceService shareInfoMapper.deleteByExample(example); } - @Async - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告资源"); - //只是删除报告的详情, 但是会保存执行历史 - ProjectApplicationExample example = new ProjectApplicationExample(); - example.createCriteria().andProjectIdEqualTo(projectId).andTypeEqualTo(ProjectApplicationType.API.API_CLEAN_REPORT.name()); - List projectApplications = projectApplicationMapper.selectByExample(example); - long timeMills = 0; - if (CollectionUtils.isNotEmpty(projectApplications)) { - String expr = projectApplications.getFirst().getTypeValue(); - timeMills = getCleanDate(expr); - } else { - timeMills = getCleanDate(DEFAULT); - } - int apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId); - while (apiReportCount > 0) { - List ids = extApiReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId); - ApiReportExample reportExample = new ApiReportExample(); - reportExample.createCriteria().andIdIn(ids); - ApiReport report = new ApiReport(); - report.setDeleted(true); - apiReportMapper.updateByExampleSelective(report, reportExample); - deleteApiReport(ids); - apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId); - } - - int scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId); - while (scenarioReportCount > 0) { - List ids = extApiScenarioReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId); - ApiScenarioReportExample reportExample = new ApiScenarioReportExample(); - reportExample.createCriteria().andIdIn(ids); - ApiScenarioReport report = new ApiScenarioReport(); - report.setDeleted(true); - apiScenarioReportMapper.updateByExampleSelective(report, reportExample); - deleteScenarioReport(ids); - scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId); - } - } - private void delScenarioModule(String projectId) { ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample(); apiScenarioModuleExample.createCriteria().andProjectIdEqualTo(projectId); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java index bb819f5a0b..3ee11a4ee9 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java @@ -61,10 +61,13 @@ public class ApiDefinitionModuleService extends ModuleTreeService { @Resource private ApiTestCaseService apiTestCaseService; - public List getTree(ApiModuleRequest request, boolean deleted) { + public List getTree(ApiModuleRequest request, boolean deleted, boolean containRequest) { //接口的树结构是 模块:子模块+接口 接口为非delete状态的 List fileModuleList = extApiDefinitionModuleMapper.selectBaseByRequest(request); List baseTreeNodes = super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_API)); + if (!containRequest) { + return baseTreeNodes; + } List apiTreeNodeList = extApiDefinitionModuleMapper.selectApiDataByRequest(request, deleted); return apiDebugModuleService.getBaseTreeNodes(apiTreeNodeList, baseTreeNodes); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java index a70b80ebbd..677ff47379 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java @@ -59,6 +59,7 @@ public class ApiDefinitionModuleControllerTests extends BaseTest { private static final String URL_FILE_MODULE_COUNT = "/api/definition/module/count"; private static final String URL_MODULE_TRASH_TREE = "/api/definition/module/trash/tree"; private static final String URL_MODULE_TRASH_COUNT = "/api/definition/module/trash/count"; + private static final String URL_MODULE_ONLY_TREE = "/api/definition/module/only/tree"; private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest(); private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError(); private static Project project; @@ -953,6 +954,10 @@ public class ApiDefinitionModuleControllerTests extends BaseTest { this.setProtocol("HTTP"); this.setProjectId(project.getId()); }}); + this.requestPostWithOkAndReturn(URL_MODULE_ONLY_TREE, new ApiModuleRequest() {{ + this.setProtocol("HTTP"); + this.setProjectId(project.getId()); + }}); String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8); ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class); diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/CleanupApiTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/CleanupApiTests.java index 95b7b40143..c5d078869f 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/CleanupApiTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/CleanupApiTests.java @@ -2,12 +2,11 @@ package io.metersphere.api.controller; import io.metersphere.api.domain.*; import io.metersphere.api.mapper.*; -import io.metersphere.api.service.CleanupApiResourceService; +import io.metersphere.api.service.CleanupApiReportServiceImpl; +import io.metersphere.api.service.CleanupApiResourceServiceImpl; import io.metersphere.api.service.definition.ApiReportService; import io.metersphere.api.service.scenario.ApiScenarioReportService; import io.metersphere.api.service.schedule.SwaggerUrlImportJob; -import io.metersphere.project.domain.ProjectApplication; -import io.metersphere.project.mapper.ProjectApplicationMapper; import io.metersphere.sdk.constants.ApiReportStatus; import io.metersphere.sdk.constants.ProjectApplicationType; import io.metersphere.sdk.constants.ScheduleType; @@ -25,7 +24,9 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -34,7 +35,7 @@ import java.util.List; public class CleanupApiTests { private final ProjectServiceInvoker serviceInvoker; @Resource - private CleanupApiResourceService cleanupApiResourceService; + private CleanupApiResourceServiceImpl cleanupApiResourceServiceImpl; @Resource private ApiDefinitionModuleMapper apiDefinitionModuleMapper; @Resource @@ -52,11 +53,7 @@ public class CleanupApiTests { @Resource private ScheduleMapper scheduleMapper; @Resource - private ProjectApplicationMapper projectApplicationMapper; - @Resource - private ApiReportMapper apiReportMapper; - @Resource - private ApiScenarioReportMapper apiScenarioReportMapper; + private CleanupApiReportServiceImpl cleanupApiReportServiceImpl; @Autowired public CleanupApiTests(ProjectServiceInvoker serviceInvoker) { @@ -144,7 +141,7 @@ public class CleanupApiTests { initReportData("test"); initScheduleData(); serviceInvoker.invokeServices("test"); - cleanupApiResourceService.deleteResources("test"); + cleanupApiResourceServiceImpl.deleteResources("test"); } private void initScheduleData() { @@ -169,21 +166,9 @@ public class CleanupApiTests { @Order(2) public void testCleanupReport() throws Exception { initReportData("test-clean-project"); - cleanupApiResourceService.cleanReportResources("test-clean-project"); - ApiReportExample apiReportExample = new ApiReportExample(); - apiReportExample.createCriteria().andProjectIdEqualTo("test-clean-project"); - apiReportMapper.deleteByExample(apiReportExample); - ApiScenarioReportExample apiScenarioReportExample = new ApiScenarioReportExample(); - apiScenarioReportExample.createCriteria().andProjectIdEqualTo("test-clean-project"); - apiScenarioReportMapper.deleteByExample(apiScenarioReportExample); - // 清理报告有数据 - ProjectApplication projectApplication = new ProjectApplication(); - projectApplication.setProjectId("test-clean-project-report"); - projectApplication.setType(ProjectApplicationType.API.API_CLEAN_REPORT.name()); - projectApplication.setTypeValue("1D"); - projectApplicationMapper.insert(projectApplication); - initReportData("test-clean-project1"); - cleanupApiResourceService.cleanReportResources("test-clean-project1"); + Map map = new HashMap<>(); + map.put(ProjectApplicationType.API.API_CLEAN_REPORT.name(), "1D"); + cleanupApiReportServiceImpl.cleanReport(map, "test-clean-project"); } private void initReportData(String projectId) { diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/CleanupResourceTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/CleanupResourceTests.java deleted file mode 100644 index 61b7969690..0000000000 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/CleanupResourceTests.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.metersphere.api.controller; - -import io.metersphere.api.service.CleanupApiResourceService; -import jakarta.annotation.Resource; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; - - -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) -@AutoConfigureMockMvc -public class CleanupResourceTests { - @Resource - private CleanupApiResourceService resourceService; - - @Test - @Order(1) - public void testCleanupResource() throws Exception { - resourceService.deleteResources("test"); - } - - @Test - @Order(1) - public void testCleanupReportResource() throws Exception { - resourceService.cleanReportResources("test"); - } -} diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/CleanupBugResourceService.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/CleanupBugResourceService.java index 939b0af07e..d901f39db6 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/service/CleanupBugResourceService.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/service/CleanupBugResourceService.java @@ -17,96 +17,90 @@ import java.util.List; @Component public class CleanupBugResourceService implements CleanupProjectResourceService { - @Resource - private BugMapper bugMapper; - @Resource - private BugContentMapper bugContentMapper; - @Resource - private BugFollowerMapper bugFollowerMapper; - @Resource - private BugLocalAttachmentMapper bugLocalAttachmentMapper; - @Resource - private BugCommentMapper bugCommentMapper; - @Resource - private BugCustomFieldMapper bugCustomFieldMapper; - @Resource - private BugRelationCaseMapper bugRelationCaseMapper; + @Resource + private BugMapper bugMapper; + @Resource + private BugContentMapper bugContentMapper; + @Resource + private BugFollowerMapper bugFollowerMapper; + @Resource + private BugLocalAttachmentMapper bugLocalAttachmentMapper; + @Resource + private BugCommentMapper bugCommentMapper; + @Resource + private BugCustomFieldMapper bugCustomFieldMapper; + @Resource + private BugRelationCaseMapper bugRelationCaseMapper; - @Async - @Override - public void deleteResources(String projectId) { - LogUtils.info("删除当前项目[" + projectId + "]相关缺陷测试资源"); - List deleteIds = getBugIds(projectId); - if (CollectionUtils.isNotEmpty(deleteIds)) { - // 清理缺陷 - deleteBug(deleteIds); - // 清理缺陷内容 - deleteBugContent(deleteIds); - // 清理缺陷关注人信息 - deleteBugFollower(deleteIds); - // 清理缺陷本地附件 - deleteBugLocalAttachment(deleteIds); - // 清理缺陷评论 - deleteBugComment(deleteIds); - // 清理缺陷自定义字段 - deleteBugCustomField(deleteIds); - // 清理缺陷关联用例 - deleteBugRelateCase(deleteIds); - } - } + @Async + @Override + public void deleteResources(String projectId) { + LogUtils.info("删除当前项目[" + projectId + "]相关缺陷测试资源"); + List deleteIds = getBugIds(projectId); + if (CollectionUtils.isNotEmpty(deleteIds)) { + // 清理缺陷 + deleteBug(deleteIds); + // 清理缺陷内容 + deleteBugContent(deleteIds); + // 清理缺陷关注人信息 + deleteBugFollower(deleteIds); + // 清理缺陷本地附件 + deleteBugLocalAttachment(deleteIds); + // 清理缺陷评论 + deleteBugComment(deleteIds); + // 清理缺陷自定义字段 + deleteBugCustomField(deleteIds); + // 清理缺陷关联用例 + deleteBugRelateCase(deleteIds); + } + } - @Async - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关缺陷测试报告资源"); - } + private List getBugIds(String projectId) { + BugExample example = new BugExample(); + example.createCriteria().andProjectIdEqualTo(projectId); + List bugs = bugMapper.selectByExample(example); + return bugs.stream().map(Bug::getId).toList(); + } - private List getBugIds(String projectId) { - BugExample example = new BugExample(); - example.createCriteria().andProjectIdEqualTo(projectId); - List bugs = bugMapper.selectByExample(example); - return bugs.stream().map(Bug::getId).toList(); - } + private void deleteBug(List bugIds) { + BugExample example = new BugExample(); + example.createCriteria().andIdIn(bugIds); + bugMapper.deleteByExample(example); + } - private void deleteBug(List bugIds) { - BugExample example = new BugExample(); - example.createCriteria().andIdIn(bugIds); - bugMapper.deleteByExample(example); - } + private void deleteBugContent(List bugIds) { + BugContentExample example = new BugContentExample(); + example.createCriteria().andBugIdIn(bugIds); + bugContentMapper.deleteByExample(example); + } - private void deleteBugContent(List bugIds) { - BugContentExample example = new BugContentExample(); - example.createCriteria().andBugIdIn(bugIds); - bugContentMapper.deleteByExample(example); - } + private void deleteBugFollower(List bugIds) { + BugFollowerExample example = new BugFollowerExample(); + example.createCriteria().andBugIdIn(bugIds); + bugFollowerMapper.deleteByExample(example); + } - private void deleteBugFollower(List bugIds) { - BugFollowerExample example = new BugFollowerExample(); - example.createCriteria().andBugIdIn(bugIds); - bugFollowerMapper.deleteByExample(example); - } + private void deleteBugLocalAttachment(List bugIds) { + BugLocalAttachmentExample example = new BugLocalAttachmentExample(); + example.createCriteria().andBugIdIn(bugIds); + bugLocalAttachmentMapper.deleteByExample(example); + } - private void deleteBugLocalAttachment(List bugIds) { - BugLocalAttachmentExample example = new BugLocalAttachmentExample(); - example.createCriteria().andBugIdIn(bugIds); - bugLocalAttachmentMapper.deleteByExample(example); - } + private void deleteBugComment(List bugIds) { + BugCommentExample example = new BugCommentExample(); + example.createCriteria().andBugIdIn(bugIds); + bugCommentMapper.deleteByExample(example); + } - private void deleteBugComment(List bugIds) { - BugCommentExample example = new BugCommentExample(); - example.createCriteria().andBugIdIn(bugIds); - bugCommentMapper.deleteByExample(example); - } + private void deleteBugCustomField(List bugIds) { + BugCustomFieldExample example = new BugCustomFieldExample(); + example.createCriteria().andBugIdIn(bugIds); + bugCustomFieldMapper.deleteByExample(example); + } - private void deleteBugCustomField(List bugIds) { - BugCustomFieldExample example = new BugCustomFieldExample(); - example.createCriteria().andBugIdIn(bugIds); - bugCustomFieldMapper.deleteByExample(example); - } - - private void deleteBugRelateCase(List bugIds) { - BugRelationCaseExample example = new BugRelationCaseExample(); - example.createCriteria().andBugIdIn(bugIds); - bugRelationCaseMapper.deleteByExample(example); - } + private void deleteBugRelateCase(List bugIds) { + BugRelationCaseExample example = new BugRelationCaseExample(); + example.createCriteria().andBugIdIn(bugIds); + bugRelationCaseMapper.deleteByExample(example); + } } diff --git a/backend/services/bug-management/src/test/java/io/metersphere/bug/service/CleanBugResourceServiceTests.java b/backend/services/bug-management/src/test/java/io/metersphere/bug/service/CleanBugResourceServiceTests.java index 376b674ebd..539134e9fb 100644 --- a/backend/services/bug-management/src/test/java/io/metersphere/bug/service/CleanBugResourceServiceTests.java +++ b/backend/services/bug-management/src/test/java/io/metersphere/bug/service/CleanBugResourceServiceTests.java @@ -13,27 +13,25 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.SqlConfig; -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class CleanBugResourceServiceTests extends BaseTest { - private final ProjectServiceInvoker serviceInvoker; - @Resource - private CleanupBugResourceService cleanupBugResourceService; + private final ProjectServiceInvoker serviceInvoker; + @Resource + private CleanupBugResourceService cleanupBugResourceService; - @Autowired - public CleanBugResourceServiceTests(ProjectServiceInvoker serviceInvoker) { - this.serviceInvoker = serviceInvoker; - } + @Autowired + public CleanBugResourceServiceTests(ProjectServiceInvoker serviceInvoker) { + this.serviceInvoker = serviceInvoker; + } - @Test - @Order(1) - @Sql(scripts = {"/dml/init_bug_clean_resource.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) - void test() { - serviceInvoker.invokeServices("default-project-for-clean-resource"); - serviceInvoker.invokeServices("default-project-for-clean-resource-not-exist"); - cleanupBugResourceService.cleanReportResources("default-project-for-clean-resource"); - cleanupBugResourceService.cleanReportResources("default-project-for-clean-resource-not-exist"); - } + @Test + @Order(1) + @Sql(scripts = {"/dml/init_bug_clean_resource.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) + void test() { + serviceInvoker.invokeServices("default-project-for-clean-resource"); + serviceInvoker.invokeServices("default-project-for-clean-resource-not-exist"); + } } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupCaseReviewResourceService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupCaseReviewResourceService.java index 426341f251..a6cd630653 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupCaseReviewResourceService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupCaseReviewResourceService.java @@ -38,9 +38,4 @@ public class CleanupCaseReviewResourceService implements CleanupProjectResourceS caseReviewModuleMapper.deleteByExample(caseReviewModuleExample); } - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关用例评审报告资源"); - - } } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupFunctionalCaseResourceService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupFunctionalCaseResourceService.java index 63940ac43e..57339f14fb 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupFunctionalCaseResourceService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CleanupFunctionalCaseResourceService.java @@ -3,7 +3,6 @@ package io.metersphere.functional.service; import io.metersphere.functional.domain.FunctionalCaseModuleExample; import io.metersphere.functional.mapper.ExtFunctionalCaseMapper; import io.metersphere.functional.mapper.FunctionalCaseModuleMapper; -import io.metersphere.sdk.util.LogUtils; import io.metersphere.system.service.CleanupProjectResourceService; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; @@ -39,9 +38,5 @@ public class CleanupFunctionalCaseResourceService implements CleanupProjectResou functionalCaseModuleExample.createCriteria().andProjectIdEqualTo(projectId); functionalCaseModuleMapper.deleteByExample(functionalCaseModuleExample); } - - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关报告资源"); - } + } diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CleanupResourceTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CleanupResourceTests.java index 2e0af0df79..431fe0e166 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CleanupResourceTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CleanupResourceTests.java @@ -12,7 +12,7 @@ import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.SqlConfig; -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @AutoConfigureMockMvc public class CleanupResourceTests { @@ -27,9 +27,4 @@ public class CleanupResourceTests { resourceService.deleteResources("project_clean_gyq"); } - @Test - @Order(2) - public void testCleanupReportResource() throws Exception { - resourceService.cleanReportResources("test"); - } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupApplicationResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupApplicationResourceService.java index 2e274f466f..4819c05952 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupApplicationResourceService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupApplicationResourceService.java @@ -2,7 +2,6 @@ package io.metersphere.project.service; import io.metersphere.project.domain.ProjectApplicationExample; import io.metersphere.project.mapper.ProjectApplicationMapper; -import io.metersphere.sdk.util.LogUtils; import io.metersphere.system.schedule.ScheduleService; import io.metersphere.system.service.CleanupProjectResourceService; import jakarta.annotation.Resource; @@ -27,8 +26,4 @@ public class CleanupApplicationResourceService implements CleanupProjectResource projectApplicationMapper.deleteByExample(example); } - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关报告资源"); - } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java index 3c679cce13..82867c599f 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java @@ -47,9 +47,4 @@ public class CleanupEnvironmentResourceService implements CleanupProjectResource } - @Override - public void cleanReportResources(String projectId) { - - } - } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupMessageTaskService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupMessageTaskService.java index c44f45ef50..a1db58487d 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupMessageTaskService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupMessageTaskService.java @@ -36,8 +36,4 @@ public class CleanupMessageTaskService implements CleanupProjectResourceService LogUtils.info("删除当前项目[" + projectId + "]相关消息管理资源"); } - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关消息管理报告资源"); - } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupRobotResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupRobotResourceService.java index 4e0ea41b6d..613cea5362 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupRobotResourceService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupRobotResourceService.java @@ -2,8 +2,8 @@ package io.metersphere.project.service; import io.metersphere.project.domain.ProjectRobotExample; import io.metersphere.project.mapper.ProjectRobotMapper; -import io.metersphere.system.service.CleanupProjectResourceService; import io.metersphere.sdk.util.LogUtils; +import io.metersphere.system.service.CleanupProjectResourceService; import jakarta.annotation.Resource; import org.springframework.stereotype.Component; @@ -20,9 +20,4 @@ public class CleanupRobotResourceService implements CleanupProjectResourceServic robotMapper.deleteByExample(projectExample); LogUtils.info("删除当前项目[" + projectId + "]相关消息机器人资源"); } - - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关消息机器人报告资源"); - } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupVersionResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupVersionResourceService.java index dea6d11a02..ff8883423c 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupVersionResourceService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupVersionResourceService.java @@ -21,6 +21,7 @@ public class CleanupVersionResourceService implements CleanupProjectResourceServ private ProjectVersionMapper projectVersionMapper; @Resource private ProjectApplicationMapper projectApplicationMapper; + @Override public void deleteResources(String projectId) { // 删除所有项目版本 @@ -32,8 +33,4 @@ public class CleanupVersionResourceService implements CleanupProjectResourceServ LogUtils.info("清理当前项目[" + projectId + "]相关版本资源"); } - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关报告资源"); - } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java index fe4e69e7ea..517c9040b6 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java @@ -159,6 +159,7 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje fileModuleRepositoryMapper.deleteByExample(repositoryExample); } + public void deleteModule(List deleteIds) { if (CollectionUtils.isEmpty(deleteIds)) { return; @@ -199,7 +200,6 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje /** * 查找当前项目下模块每个节点对应的资源统计 - * */ public Map getModuleCountMap(String projectId, String storage, List moduleCountDTOList) { @@ -242,10 +242,6 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje } } - @Override - public void cleanReportResources(String projectId) { - // nothing to do - } public Map getModuleNameMapByIds(List moduleIds) { if (CollectionUtils.isEmpty(moduleIds)) { diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupEnvironmentTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupEnvironmentTests.java index 1488693282..90c989b1ec 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupEnvironmentTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupEnvironmentTests.java @@ -16,7 +16,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @AutoConfigureMockMvc public class CleanupEnvironmentTests { @@ -27,6 +27,7 @@ public class CleanupEnvironmentTests { private EnvironmentGroupMapper environmentGroupMapper; @Resource private EnvironmentGroupRelationMapper environmentGroupRelationMapper; + @Autowired public CleanupEnvironmentTests(ProjectServiceInvoker serviceInvoker) { this.serviceInvoker = serviceInvoker; @@ -52,7 +53,6 @@ public class CleanupEnvironmentTests { environmentGroupRelation.setProjectId("test"); environmentGroupRelationMapper.insert(environmentGroupRelation); serviceInvoker.invokeServices("test"); - cleanupEnvironmentResourceService.cleanReportResources("test"); } } diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupRobotResourceTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupRobotResourceTests.java index 25fa7f3663..1c1e443abb 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupRobotResourceTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/CleanupRobotResourceTests.java @@ -1,7 +1,6 @@ package io.metersphere.project.controller; import io.metersphere.project.domain.ProjectRobot; - import io.metersphere.project.service.CleanupRobotResourceService; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.util.JSON; @@ -45,12 +44,7 @@ public class CleanupRobotResourceTests extends BaseTest { List projectRobotAfters = getList(); Assertions.assertTrue(CollectionUtils.isEmpty(projectRobotAfters)); } - - @Test - @Order(2) - public void testCleanupReportResource() throws Exception { - resourceService.cleanReportResources("test"); - } + private List getList() throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(ROBOT_LIST + "test") diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/param/CleanupMessageTaskResourceTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/param/CleanupMessageTaskResourceTests.java index 73be1b5d29..718c994828 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/param/CleanupMessageTaskResourceTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/param/CleanupMessageTaskResourceTests.java @@ -8,7 +8,10 @@ import io.metersphere.system.base.BaseTest; import io.metersphere.system.controller.handler.ResultHolder; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; @@ -24,7 +27,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @AutoConfigureMockMvc public class CleanupMessageTaskResourceTests extends BaseTest { @@ -41,18 +44,6 @@ public class CleanupMessageTaskResourceTests extends BaseTest { } } - @Test - @Order(2) - public void testCleanupResourceNoMessage() throws Exception { - resourceService.cleanReportResources("test1"); - } - - @Test - @Order(3) - public void testCleanupReportResource() throws Exception { - resourceService.cleanReportResources("test"); - } - private List getList() throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/test") .header(SessionConstants.HEADER_TOKEN, sessionId) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java index 81e1215749..5f5d88be6a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java @@ -106,4 +106,13 @@ public class OperationLogModule { //测试计划 public static final String TEST_PLAN = "TEST_PLAN"; public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE"; + + // 个人信息-基本信息 + public static final String PERSONAL_INFORMATION_BASE_INFO = "PERSONAL_INFORMATION_BASE_INFO"; + // 个人信息-密码设置 + public static final String PERSONAL_INFORMATION_PSW = "PERSONAL_INFORMATION_PSW"; + // 个人信息-本地执行 + public static final String PERSONAL_INFORMATION_LOCAL_EXECUTE = "PERSONAL_INFORMATION_LOCAL_EXECUTE"; + // 个人信息-三方平台账号 + public static final String PERSONAL_INFORMATION_TRIPARTITE = "PERSONAL_INFORMATION_TRIPARTITE"; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupProjectResourceService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupProjectResourceService.java index fbd8b114c5..6be2a66a5b 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupProjectResourceService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupProjectResourceService.java @@ -7,9 +7,4 @@ public interface CleanupProjectResourceService { void deleteResources(String projectId); - /** - * 清理报告资源 - * @param projectId - */ - void cleanReportResources(String projectId); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupTemplateResourceService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupTemplateResourceService.java index 58893e5563..b700a79d72 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupTemplateResourceService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CleanupTemplateResourceService.java @@ -11,6 +11,7 @@ public class CleanupTemplateResourceService implements CleanupProjectResourceSer private BaseCustomFieldService baseCustomFieldService; @Resource private BaseStatusFlowSettingService baseStatusFlowSettingService; + @Override public void deleteResources(String projectId) { baseTemplateService.deleteByScopeId(projectId); @@ -18,6 +19,4 @@ public class CleanupTemplateResourceService implements CleanupProjectResourceSer baseStatusFlowSettingService.deleteByScopeId(projectId); } - @Override - public void cleanReportResources(String projectId) {} } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java index bd65c19cac..aa6ca79c82 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java @@ -46,7 +46,7 @@ public class UserLocalConfigService { .projectId(OperationLogConstants.SYSTEM) .organizationId(OperationLogConstants.SYSTEM) .type(OperationLogType.ADD.name()) - .module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_CONFIG) + .module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_EXECUTE) .method(HttpMethodConstants.POST.name()) .path("/user/local/config/add") .sourceId(userLocalConfig.getId()) @@ -111,5 +111,16 @@ public class UserLocalConfigService { UserLocalConfig userLocalConfig = checkResourceById(request.getId()); userLocalConfig.setUserUrl(request.getUserUrl()); userLocalConfigMapper.updateByPrimaryKeySelective(userLocalConfig); + LogDTO dto = LogDTOBuilder.builder() + .projectId(OperationLogConstants.SYSTEM) + .organizationId(OperationLogConstants.SYSTEM) + .type(OperationLogType.UPDATE.name()) + .module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_EXECUTE) + .method(HttpMethodConstants.POST.name()) + .path("/user/local/config/update") + .sourceId(userLocalConfig.getId()) + .originalValue(JSON.toJSONBytes(userLocalConfig)) + .build().getLogDTO(); + operationLogService.add(dto); } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java index 56db699e70..85db51cf22 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java @@ -91,7 +91,7 @@ public class UserLogService { .projectId(OperationLogConstants.SYSTEM) .organizationId(OperationLogConstants.SYSTEM) .type(OperationLogType.UPDATE.name()) - .module(OperationLogModule.PERSONAL_INFORMATION_PERSONAL_SETTINGS) + .module(OperationLogModule.PERSONAL_INFORMATION_PSW) .method(HttpMethodConstants.POST.name()) .path("/personal/update-password") .sourceId(request.getId()) @@ -122,7 +122,7 @@ public class UserLogService { .projectId(OperationLogConstants.SYSTEM) .organizationId(OperationLogConstants.SYSTEM) .type(OperationLogType.UPDATE.name()) - .module(OperationLogModule.PERSONAL_INFORMATION_PERSONAL_SETTINGS) + .module(OperationLogModule.PERSONAL_INFORMATION_BASE_INFO) .method(HttpMethodConstants.POST.name()) .path("/personal/update-info") .sourceId(request.getId()) @@ -262,6 +262,7 @@ public class UserLogService { } operationLogService.batchAdd(logs); } + public void batchAddOrgLog(UserRoleBatchRelationRequest request, String operator) { List logs = new ArrayList<>(); List userIds = userToolService.getBatchUserIds(request); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java index 7f6fdc5314..0276b257f8 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserPlatformAccountService.java @@ -68,7 +68,7 @@ public class UserPlatformAccountService { userExtend.setId(userId); userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo)); userExtendMapper.insertSelective(userExtend); - } else if (userExtend.getPlatformInfo() == null){ + } else if (userExtend.getPlatformInfo() == null) { userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo)); userExtendMapper.updateByPrimaryKeySelective(userExtend); } else { @@ -82,7 +82,7 @@ public class UserPlatformAccountService { .projectId(OperationLogConstants.SYSTEM) .organizationId(OperationLogConstants.SYSTEM) .type(OperationLogType.UPDATE.name()) - .module(OperationLogModule.PERSONAL_INFORMATION_APIKEYS) + .module(OperationLogModule.PERSONAL_INFORMATION_TRIPARTITE) .method(HttpMethodConstants.GET.name()) .path("/user/platform/save") .sourceId(userId) @@ -93,8 +93,9 @@ public class UserPlatformAccountService { /** * 获取个人三方平台账号 + * * @param userId 用户ID - * @param orgId 组织ID + * @param orgId 组织ID * @return 三方平台账号 */ public Map get(String userId, String orgId) { diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/mock/CleanupTestResourceService.java b/backend/services/system-setting/src/test/java/io/metersphere/system/mock/CleanupTestResourceService.java index eb2bb373cb..c50f70c5d7 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/mock/CleanupTestResourceService.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/mock/CleanupTestResourceService.java @@ -1,7 +1,7 @@ package io.metersphere.system.mock; -import io.metersphere.system.service.CleanupProjectResourceService; import io.metersphere.sdk.util.LogUtils; +import io.metersphere.system.service.CleanupProjectResourceService; import org.springframework.stereotype.Component; @Component @@ -12,8 +12,4 @@ public class CleanupTestResourceService implements CleanupProjectResourceService LogUtils.info("删除当前项目[" + projectId + "]TEST资源"); } - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]TEST报告资源"); - } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/CleanupPlanResourceService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/CleanupPlanResourceService.java index f90360b178..13f429b3e9 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/CleanupPlanResourceService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/CleanupPlanResourceService.java @@ -12,8 +12,4 @@ public class CleanupPlanResourceService implements CleanupProjectResourceService LogUtils.info("删除当前项目[" + projectId + "]相关测试计划资源"); } - @Override - public void cleanReportResources(String projectId) { - LogUtils.info("清理当前项目[" + projectId + "]相关测试计划报告资源"); - } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanModuleService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanModuleService.java index 423bbe1b8f..9a27bcf6cd 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanModuleService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanModuleService.java @@ -50,7 +50,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP return super.buildTreeAndCountResource(fileModuleList, true, Translator.get("default.module")); } - public List getTreeOnlyIdsAndResourceCount(String projectId, List moduleCountDTOList) { + public List getTreeOnlyIdsAndResourceCount(String projectId, List moduleCountDTOList) { //节点内容只有Id和parentId List fileModuleList = extTestPlanModuleMapper.selectIdAndParentIdByProjectId(projectId); return super.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true, Translator.get("default.module")); @@ -70,7 +70,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP testPlanModule.setUpdateUser(operator); testPlanModuleMapper.insert(testPlanModule); //记录日志 - testPlanModuleLogService.saveAddLog(testPlanModule, operator,requestUrl,requestMethod); + testPlanModuleLogService.saveAddLog(testPlanModule, operator, requestUrl, requestMethod); return testPlanModule.getId(); } @@ -111,7 +111,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP example.clear(); } - public void update(TestPlanModuleUpdateRequest request, String userId,String requestUrl,String requestMethod) { + public void update(TestPlanModuleUpdateRequest request, String userId, String requestUrl, String requestMethod) { TestPlanModule module = testPlanModuleMapper.selectByPrimaryKey(request.getId()); TestPlanModule updateModule = new TestPlanModule(); updateModule.setId(request.getId()); @@ -123,7 +123,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP testPlanModuleMapper.updateByPrimaryKeySelective(updateModule); TestPlanModule newModule = testPlanModuleMapper.selectByPrimaryKey(request.getId()); //记录日志 - testPlanModuleLogService.saveUpdateLog(module, newModule, module.getProjectId(), userId,requestUrl,requestMethod); + testPlanModuleLogService.saveUpdateLog(module, newModule, module.getProjectId(), userId, requestUrl, requestMethod); } @@ -154,7 +154,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP } } - public void moveNode(NodeMoveRequest request, String currentUser,String requestUrl,String requestMethod) { + public void moveNode(NodeMoveRequest request, String currentUser, String requestUrl, String requestMethod) { NodeSortDTO nodeSortDTO = super.getNodeSortDTO(request, extTestPlanModuleMapper::selectBaseModuleById, @@ -171,12 +171,11 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP } super.sort(nodeSortDTO); //记录日志 - testPlanModuleLogService.saveMoveLog(nodeSortDTO, currentUser,requestUrl,requestMethod); + testPlanModuleLogService.saveMoveLog(nodeSortDTO, currentUser, requestUrl, requestMethod); } /** * 查找当前项目下模块每个节点对应的资源统计 - * */ public Map getModuleCountMap(String projectId, List moduleCountDTOList) { @@ -219,11 +218,6 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP } } - @Override - public void cleanReportResources(String projectId) { - // nothing to do - } - public String getNameById(String id) { return extTestPlanModuleMapper.selectNameById(id); } diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/CleanupResourceTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/CleanupResourceTests.java index 2406c5fc0f..172816ddbd 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/CleanupResourceTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/CleanupResourceTests.java @@ -10,7 +10,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @AutoConfigureMockMvc public class CleanupResourceTests { @@ -22,10 +22,4 @@ public class CleanupResourceTests { public void testCleanupResource() throws Exception { resourceService.deleteResources("test"); } - - @Test - @Order(2) - public void testCleanupReportResource() throws Exception { - resourceService.cleanReportResources("test"); - } }