refactor(接口测试): 优化接口定时清理报告的逻辑
This commit is contained in:
parent
15fc7e84ae
commit
25fc319557
|
@ -33,8 +33,8 @@ public class ApiDefinitionModuleController {
|
||||||
@Operation(summary = "接口测试-接口管理-模块-查找模块")
|
@Operation(summary = "接口测试-接口管理-模块-查找模块")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
|
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
|
||||||
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||||
public List<BaseTreeNode> getTree(@RequestBody @Validated ApiModuleRequest request) {
|
public List<BaseTreeNode> getTreeAndRequest(@RequestBody @Validated ApiModuleRequest request) {
|
||||||
return apiDefinitionModuleService.getTree(request, false);
|
return apiDefinitionModuleService.getTree(request, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
|
@ -97,4 +97,12 @@ public class ApiDefinitionModuleController {
|
||||||
public EnvApiTreeDTO envTree(@RequestBody @Validated EnvApiModuleRequest request) {
|
public EnvApiTreeDTO envTree(@RequestBody @Validated EnvApiModuleRequest request) {
|
||||||
return apiDefinitionModuleService.envTree(request);
|
return apiDefinitionModuleService.envTree(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/only/tree")
|
||||||
|
@Operation(summary = "接口测试-接口管理-模块-不包含请求数据的模块树")
|
||||||
|
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
|
||||||
|
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||||
|
public List<BaseTreeNode> getTree(@RequestBody @Validated ApiModuleRequest request) {
|
||||||
|
return apiDefinitionModuleService.getTree(request, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class ApiReportShareService {
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
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)
|
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||||
public void validateExpired(ShareInfo shareInfo) {
|
public void validateExpired(ShareInfo shareInfo) {
|
||||||
|
|
|
@ -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<String, String> 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<String> 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<String> 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<String> 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<String> 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,12 +3,8 @@ package io.metersphere.api.service;
|
||||||
import io.metersphere.api.domain.*;
|
import io.metersphere.api.domain.*;
|
||||||
import io.metersphere.api.mapper.*;
|
import io.metersphere.api.mapper.*;
|
||||||
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
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.DefaultRepositoryDir;
|
||||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
|
||||||
import io.metersphere.sdk.domain.ShareInfoExample;
|
import io.metersphere.sdk.domain.ShareInfoExample;
|
||||||
import io.metersphere.sdk.mapper.ShareInfoMapper;
|
import io.metersphere.sdk.mapper.ShareInfoMapper;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
@ -28,12 +24,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static io.metersphere.sdk.util.ShareUtil.getCleanDate;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class CleanupApiResourceService implements CleanupProjectResourceService {
|
public class CleanupApiResourceServiceImpl implements CleanupProjectResourceService {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
||||||
|
@ -88,12 +81,8 @@ public class CleanupApiResourceService implements CleanupProjectResourceService
|
||||||
@Resource
|
@Resource
|
||||||
private ShareInfoMapper shareInfoMapper;
|
private ShareInfoMapper shareInfoMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectApplicationMapper projectApplicationMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiDefinitionSwaggerMapper apiDefinitionSwaggerMapper;
|
private ApiDefinitionSwaggerMapper apiDefinitionSwaggerMapper;
|
||||||
|
|
||||||
private static final String DEFAULT = "30D";
|
|
||||||
|
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,46 +108,6 @@ public class CleanupApiResourceService implements CleanupProjectResourceService
|
||||||
shareInfoMapper.deleteByExample(example);
|
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<ProjectApplication> 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<String> 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<String> 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) {
|
private void delScenarioModule(String projectId) {
|
||||||
ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample();
|
ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample();
|
||||||
apiScenarioModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
apiScenarioModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
|
@ -61,10 +61,13 @@ public class ApiDefinitionModuleService extends ModuleTreeService {
|
||||||
@Resource
|
@Resource
|
||||||
private ApiTestCaseService apiTestCaseService;
|
private ApiTestCaseService apiTestCaseService;
|
||||||
|
|
||||||
public List<BaseTreeNode> getTree(ApiModuleRequest request, boolean deleted) {
|
public List<BaseTreeNode> getTree(ApiModuleRequest request, boolean deleted, boolean containRequest) {
|
||||||
//接口的树结构是 模块:子模块+接口 接口为非delete状态的
|
//接口的树结构是 模块:子模块+接口 接口为非delete状态的
|
||||||
List<BaseTreeNode> fileModuleList = extApiDefinitionModuleMapper.selectBaseByRequest(request);
|
List<BaseTreeNode> fileModuleList = extApiDefinitionModuleMapper.selectBaseByRequest(request);
|
||||||
List<BaseTreeNode> baseTreeNodes = super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_API));
|
List<BaseTreeNode> baseTreeNodes = super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_API));
|
||||||
|
if (!containRequest) {
|
||||||
|
return baseTreeNodes;
|
||||||
|
}
|
||||||
List<ApiTreeNode> apiTreeNodeList = extApiDefinitionModuleMapper.selectApiDataByRequest(request, deleted);
|
List<ApiTreeNode> apiTreeNodeList = extApiDefinitionModuleMapper.selectApiDataByRequest(request, deleted);
|
||||||
return apiDebugModuleService.getBaseTreeNodes(apiTreeNodeList, baseTreeNodes);
|
return apiDebugModuleService.getBaseTreeNodes(apiTreeNodeList, baseTreeNodes);
|
||||||
|
|
||||||
|
|
|
@ -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_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_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_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 BAD_REQUEST_MATCHER = status().isBadRequest();
|
||||||
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||||
private static Project project;
|
private static Project project;
|
||||||
|
@ -953,6 +954,10 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
|
||||||
this.setProtocol("HTTP");
|
this.setProtocol("HTTP");
|
||||||
this.setProjectId(project.getId());
|
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);
|
String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||||
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
||||||
|
|
|
@ -2,12 +2,11 @@ package io.metersphere.api.controller;
|
||||||
|
|
||||||
import io.metersphere.api.domain.*;
|
import io.metersphere.api.domain.*;
|
||||||
import io.metersphere.api.mapper.*;
|
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.definition.ApiReportService;
|
||||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
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.ApiReportStatus;
|
||||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||||
import io.metersphere.sdk.constants.ScheduleType;
|
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 org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
@ -34,7 +35,7 @@ import java.util.List;
|
||||||
public class CleanupApiTests {
|
public class CleanupApiTests {
|
||||||
private final ProjectServiceInvoker serviceInvoker;
|
private final ProjectServiceInvoker serviceInvoker;
|
||||||
@Resource
|
@Resource
|
||||||
private CleanupApiResourceService cleanupApiResourceService;
|
private CleanupApiResourceServiceImpl cleanupApiResourceServiceImpl;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -52,11 +53,7 @@ public class CleanupApiTests {
|
||||||
@Resource
|
@Resource
|
||||||
private ScheduleMapper scheduleMapper;
|
private ScheduleMapper scheduleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectApplicationMapper projectApplicationMapper;
|
private CleanupApiReportServiceImpl cleanupApiReportServiceImpl;
|
||||||
@Resource
|
|
||||||
private ApiReportMapper apiReportMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CleanupApiTests(ProjectServiceInvoker serviceInvoker) {
|
public CleanupApiTests(ProjectServiceInvoker serviceInvoker) {
|
||||||
|
@ -144,7 +141,7 @@ public class CleanupApiTests {
|
||||||
initReportData("test");
|
initReportData("test");
|
||||||
initScheduleData();
|
initScheduleData();
|
||||||
serviceInvoker.invokeServices("test");
|
serviceInvoker.invokeServices("test");
|
||||||
cleanupApiResourceService.deleteResources("test");
|
cleanupApiResourceServiceImpl.deleteResources("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initScheduleData() {
|
private void initScheduleData() {
|
||||||
|
@ -169,21 +166,9 @@ public class CleanupApiTests {
|
||||||
@Order(2)
|
@Order(2)
|
||||||
public void testCleanupReport() throws Exception {
|
public void testCleanupReport() throws Exception {
|
||||||
initReportData("test-clean-project");
|
initReportData("test-clean-project");
|
||||||
cleanupApiResourceService.cleanReportResources("test-clean-project");
|
Map<String, String> map = new HashMap<>();
|
||||||
ApiReportExample apiReportExample = new ApiReportExample();
|
map.put(ProjectApplicationType.API.API_CLEAN_REPORT.name(), "1D");
|
||||||
apiReportExample.createCriteria().andProjectIdEqualTo("test-clean-project");
|
cleanupApiReportServiceImpl.cleanReport(map, "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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initReportData(String projectId) {
|
private void initReportData(String projectId) {
|
||||||
|
|
|
@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -55,12 +55,6 @@ public class CleanupBugResourceService implements CleanupProjectResourceService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关缺陷测试报告资源");
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getBugIds(String projectId) {
|
private List<String> getBugIds(String projectId) {
|
||||||
BugExample example = new BugExample();
|
BugExample example = new BugExample();
|
||||||
example.createCriteria().andProjectIdEqualTo(projectId);
|
example.createCriteria().andProjectIdEqualTo(projectId);
|
||||||
|
|
|
@ -33,7 +33,5 @@ public class CleanBugResourceServiceTests extends BaseTest {
|
||||||
void test() {
|
void test() {
|
||||||
serviceInvoker.invokeServices("default-project-for-clean-resource");
|
serviceInvoker.invokeServices("default-project-for-clean-resource");
|
||||||
serviceInvoker.invokeServices("default-project-for-clean-resource-not-exist");
|
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,4 @@ public class CleanupCaseReviewResourceService implements CleanupProjectResourceS
|
||||||
caseReviewModuleMapper.deleteByExample(caseReviewModuleExample);
|
caseReviewModuleMapper.deleteByExample(caseReviewModuleExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关用例评审报告资源");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package io.metersphere.functional.service;
|
||||||
import io.metersphere.functional.domain.FunctionalCaseModuleExample;
|
import io.metersphere.functional.domain.FunctionalCaseModuleExample;
|
||||||
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
|
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
|
||||||
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
|
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -40,8 +39,4 @@ public class CleanupFunctionalCaseResourceService implements CleanupProjectResou
|
||||||
functionalCaseModuleMapper.deleteByExample(functionalCaseModuleExample);
|
functionalCaseModuleMapper.deleteByExample(functionalCaseModuleExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,4 @@ public class CleanupResourceTests {
|
||||||
resourceService.deleteResources("project_clean_gyq");
|
resourceService.deleteResources("project_clean_gyq");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(2)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package io.metersphere.project.service;
|
||||||
|
|
||||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
|
||||||
import io.metersphere.system.schedule.ScheduleService;
|
import io.metersphere.system.schedule.ScheduleService;
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -27,8 +26,4 @@ public class CleanupApplicationResourceService implements CleanupProjectResource
|
||||||
projectApplicationMapper.deleteByExample(example);
|
projectApplicationMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,4 @@ public class CleanupEnvironmentResourceService implements CleanupProjectResource
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,4 @@ public class CleanupMessageTaskService implements CleanupProjectResourceService
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]相关消息管理资源");
|
LogUtils.info("删除当前项目[" + projectId + "]相关消息管理资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关消息管理报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package io.metersphere.project.service;
|
||||||
|
|
||||||
import io.metersphere.project.domain.ProjectRobotExample;
|
import io.metersphere.project.domain.ProjectRobotExample;
|
||||||
import io.metersphere.project.mapper.ProjectRobotMapper;
|
import io.metersphere.project.mapper.ProjectRobotMapper;
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -20,9 +20,4 @@ public class CleanupRobotResourceService implements CleanupProjectResourceServic
|
||||||
robotMapper.deleteByExample(projectExample);
|
robotMapper.deleteByExample(projectExample);
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]相关消息机器人资源");
|
LogUtils.info("删除当前项目[" + projectId + "]相关消息机器人资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关消息机器人报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class CleanupVersionResourceService implements CleanupProjectResourceServ
|
||||||
private ProjectVersionMapper projectVersionMapper;
|
private ProjectVersionMapper projectVersionMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectApplicationMapper projectApplicationMapper;
|
private ProjectApplicationMapper projectApplicationMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteResources(String projectId) {
|
public void deleteResources(String projectId) {
|
||||||
// 删除所有项目版本
|
// 删除所有项目版本
|
||||||
|
@ -32,8 +33,4 @@ public class CleanupVersionResourceService implements CleanupProjectResourceServ
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关版本资源");
|
LogUtils.info("清理当前项目[" + projectId + "]相关版本资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,7 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
||||||
fileModuleRepositoryMapper.deleteByExample(repositoryExample);
|
fileModuleRepositoryMapper.deleteByExample(repositoryExample);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteModule(List<String> deleteIds) {
|
public void deleteModule(List<String> deleteIds) {
|
||||||
if (CollectionUtils.isEmpty(deleteIds)) {
|
if (CollectionUtils.isEmpty(deleteIds)) {
|
||||||
return;
|
return;
|
||||||
|
@ -199,7 +200,6 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找当前项目下模块每个节点对应的资源统计
|
* 查找当前项目下模块每个节点对应的资源统计
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Map<String, Long> getModuleCountMap(String projectId, String storage, List<ModuleCountDTO> moduleCountDTOList) {
|
public Map<String, Long> getModuleCountMap(String projectId, String storage, List<ModuleCountDTO> moduleCountDTOList) {
|
||||||
|
|
||||||
|
@ -242,10 +242,6 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getModuleNameMapByIds(List<String> moduleIds) {
|
public Map<String, String> getModuleNameMapByIds(List<String> moduleIds) {
|
||||||
if (CollectionUtils.isEmpty(moduleIds)) {
|
if (CollectionUtils.isEmpty(moduleIds)) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class CleanupEnvironmentTests {
|
||||||
private EnvironmentGroupMapper environmentGroupMapper;
|
private EnvironmentGroupMapper environmentGroupMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private EnvironmentGroupRelationMapper environmentGroupRelationMapper;
|
private EnvironmentGroupRelationMapper environmentGroupRelationMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CleanupEnvironmentTests(ProjectServiceInvoker serviceInvoker) {
|
public CleanupEnvironmentTests(ProjectServiceInvoker serviceInvoker) {
|
||||||
this.serviceInvoker = serviceInvoker;
|
this.serviceInvoker = serviceInvoker;
|
||||||
|
@ -52,7 +53,6 @@ public class CleanupEnvironmentTests {
|
||||||
environmentGroupRelation.setProjectId("test");
|
environmentGroupRelation.setProjectId("test");
|
||||||
environmentGroupRelationMapper.insert(environmentGroupRelation);
|
environmentGroupRelationMapper.insert(environmentGroupRelation);
|
||||||
serviceInvoker.invokeServices("test");
|
serviceInvoker.invokeServices("test");
|
||||||
cleanupEnvironmentResourceService.cleanReportResources("test");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package io.metersphere.project.controller;
|
package io.metersphere.project.controller;
|
||||||
|
|
||||||
import io.metersphere.project.domain.ProjectRobot;
|
import io.metersphere.project.domain.ProjectRobot;
|
||||||
|
|
||||||
import io.metersphere.project.service.CleanupRobotResourceService;
|
import io.metersphere.project.service.CleanupRobotResourceService;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
@ -46,11 +45,6 @@ public class CleanupRobotResourceTests extends BaseTest {
|
||||||
Assertions.assertTrue(CollectionUtils.isEmpty(projectRobotAfters));
|
Assertions.assertTrue(CollectionUtils.isEmpty(projectRobotAfters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(2)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ProjectRobot> getList() throws Exception {
|
private List<ProjectRobot> getList() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(ROBOT_LIST + "test")
|
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(ROBOT_LIST + "test")
|
||||||
|
|
|
@ -8,7 +8,10 @@ import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
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.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -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<MessageTaskDTO> getList() throws Exception {
|
private List<MessageTaskDTO> getList() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/test")
|
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/test")
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
|
|
|
@ -106,4 +106,13 @@ public class OperationLogModule {
|
||||||
//测试计划
|
//测试计划
|
||||||
public static final String TEST_PLAN = "TEST_PLAN";
|
public static final String TEST_PLAN = "TEST_PLAN";
|
||||||
public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE";
|
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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,4 @@ public interface CleanupProjectResourceService {
|
||||||
|
|
||||||
void deleteResources(String projectId);
|
void deleteResources(String projectId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 清理报告资源
|
|
||||||
* @param projectId
|
|
||||||
*/
|
|
||||||
void cleanReportResources(String projectId);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ public class CleanupTemplateResourceService implements CleanupProjectResourceSer
|
||||||
private BaseCustomFieldService baseCustomFieldService;
|
private BaseCustomFieldService baseCustomFieldService;
|
||||||
@Resource
|
@Resource
|
||||||
private BaseStatusFlowSettingService baseStatusFlowSettingService;
|
private BaseStatusFlowSettingService baseStatusFlowSettingService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteResources(String projectId) {
|
public void deleteResources(String projectId) {
|
||||||
baseTemplateService.deleteByScopeId(projectId);
|
baseTemplateService.deleteByScopeId(projectId);
|
||||||
|
@ -18,6 +19,4 @@ public class CleanupTemplateResourceService implements CleanupProjectResourceSer
|
||||||
baseStatusFlowSettingService.deleteByScopeId(projectId);
|
baseStatusFlowSettingService.deleteByScopeId(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class UserLocalConfigService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.ADD.name())
|
.type(OperationLogType.ADD.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_CONFIG)
|
.module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_EXECUTE)
|
||||||
.method(HttpMethodConstants.POST.name())
|
.method(HttpMethodConstants.POST.name())
|
||||||
.path("/user/local/config/add")
|
.path("/user/local/config/add")
|
||||||
.sourceId(userLocalConfig.getId())
|
.sourceId(userLocalConfig.getId())
|
||||||
|
@ -111,5 +111,16 @@ public class UserLocalConfigService {
|
||||||
UserLocalConfig userLocalConfig = checkResourceById(request.getId());
|
UserLocalConfig userLocalConfig = checkResourceById(request.getId());
|
||||||
userLocalConfig.setUserUrl(request.getUserUrl());
|
userLocalConfig.setUserUrl(request.getUserUrl());
|
||||||
userLocalConfigMapper.updateByPrimaryKeySelective(userLocalConfig);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class UserLogService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.UPDATE.name())
|
.type(OperationLogType.UPDATE.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_PERSONAL_SETTINGS)
|
.module(OperationLogModule.PERSONAL_INFORMATION_PSW)
|
||||||
.method(HttpMethodConstants.POST.name())
|
.method(HttpMethodConstants.POST.name())
|
||||||
.path("/personal/update-password")
|
.path("/personal/update-password")
|
||||||
.sourceId(request.getId())
|
.sourceId(request.getId())
|
||||||
|
@ -122,7 +122,7 @@ public class UserLogService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.UPDATE.name())
|
.type(OperationLogType.UPDATE.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_PERSONAL_SETTINGS)
|
.module(OperationLogModule.PERSONAL_INFORMATION_BASE_INFO)
|
||||||
.method(HttpMethodConstants.POST.name())
|
.method(HttpMethodConstants.POST.name())
|
||||||
.path("/personal/update-info")
|
.path("/personal/update-info")
|
||||||
.sourceId(request.getId())
|
.sourceId(request.getId())
|
||||||
|
@ -262,6 +262,7 @@ public class UserLogService {
|
||||||
}
|
}
|
||||||
operationLogService.batchAdd(logs);
|
operationLogService.batchAdd(logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void batchAddOrgLog(UserRoleBatchRelationRequest request, String operator) {
|
public void batchAddOrgLog(UserRoleBatchRelationRequest request, String operator) {
|
||||||
List<LogDTO> logs = new ArrayList<>();
|
List<LogDTO> logs = new ArrayList<>();
|
||||||
List<String> userIds = userToolService.getBatchUserIds(request);
|
List<String> userIds = userToolService.getBatchUserIds(request);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class UserPlatformAccountService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.UPDATE.name())
|
.type(OperationLogType.UPDATE.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_APIKEYS)
|
.module(OperationLogModule.PERSONAL_INFORMATION_TRIPARTITE)
|
||||||
.method(HttpMethodConstants.GET.name())
|
.method(HttpMethodConstants.GET.name())
|
||||||
.path("/user/platform/save")
|
.path("/user/platform/save")
|
||||||
.sourceId(userId)
|
.sourceId(userId)
|
||||||
|
@ -93,6 +93,7 @@ public class UserPlatformAccountService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取个人三方平台账号
|
* 获取个人三方平台账号
|
||||||
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param orgId 组织ID
|
* @param orgId 组织ID
|
||||||
* @return 三方平台账号
|
* @return 三方平台账号
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package io.metersphere.system.mock;
|
package io.metersphere.system.mock;
|
||||||
|
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -12,8 +12,4 @@ public class CleanupTestResourceService implements CleanupProjectResourceService
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]TEST资源");
|
LogUtils.info("删除当前项目[" + projectId + "]TEST资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]TEST报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,4 @@ public class CleanupPlanResourceService implements CleanupProjectResourceService
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]相关测试计划资源");
|
LogUtils.info("删除当前项目[" + projectId + "]相关测试计划资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关测试计划报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,6 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找当前项目下模块每个节点对应的资源统计
|
* 查找当前项目下模块每个节点对应的资源统计
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Map<String, Long> getModuleCountMap(String projectId, List<ModuleCountDTO> moduleCountDTOList) {
|
public Map<String, Long> getModuleCountMap(String projectId, List<ModuleCountDTO> 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) {
|
public String getNameById(String id) {
|
||||||
return extTestPlanModuleMapper.selectNameById(id);
|
return extTestPlanModuleMapper.selectNameById(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,4 @@ public class CleanupResourceTests {
|
||||||
public void testCleanupResource() throws Exception {
|
public void testCleanupResource() throws Exception {
|
||||||
resourceService.deleteResources("test");
|
resourceService.deleteResources("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(2)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue