diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java index 87c2b1ee33..a6963d2935 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java @@ -41,9 +41,6 @@ import io.metersphere.sdk.util.Translator; import io.metersphere.system.dto.LogInsertModule; import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.SessionUser; -import io.metersphere.system.log.constants.OperationLogModule; -import io.metersphere.system.log.constants.OperationLogType; -import io.metersphere.system.log.dto.LogDTO; import io.metersphere.system.log.service.OperationLogService; import io.metersphere.system.service.UserLoginService; import io.metersphere.system.uid.IDGenerator; @@ -564,18 +561,16 @@ public class TestPlanApiCaseService extends TestPlanResourceService { @Override public void associateCollection(String planId, Map> collectionAssociates, SessionUser user) { List testPlanApiCaseList = new ArrayList<>(); - List logDTOS = new ArrayList<>(); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId); //处理数据 - handleApiData(collectionAssociates.get(AssociateCaseType.API), user, testPlanApiCaseList, testPlan, logDTOS); - handleApiCaseData(collectionAssociates.get(AssociateCaseType.API_CASE), user, testPlanApiCaseList, testPlan, logDTOS); + handleApiData(collectionAssociates.get(AssociateCaseType.API), user, testPlanApiCaseList, testPlan); + handleApiCaseData(collectionAssociates.get(AssociateCaseType.API_CASE), user, testPlanApiCaseList, testPlan); if (CollectionUtils.isNotEmpty(testPlanApiCaseList)) { testPlanApiCaseMapper.batchInsert(testPlanApiCaseList); - operationLogService.batchAdd(logDTOS); } } - private void handleApiCaseData(List apiCaseList, SessionUser user, List testPlanApiCaseList, TestPlan testPlan, List logDTOS) { + private void handleApiCaseData(List apiCaseList, SessionUser user, List testPlanApiCaseList, TestPlan testPlan) { if (CollectionUtils.isNotEmpty(apiCaseList)) { List ids = apiCaseList.stream().flatMap(item -> item.getIds().stream()).toList(); ApiTestCaseExample example = new ApiTestCaseExample(); @@ -586,13 +581,13 @@ public class TestPlanApiCaseService extends TestPlanResourceService { if (CollectionUtils.isNotEmpty(apiCaseIds)) { List apiTestCases = apiTestCaseList.stream().filter(item -> apiCaseIds.contains(item.getId())).toList(); Map apiTestCaseMap = apiTestCases.stream().collect(Collectors.toMap(ApiTestCase::getId, Function.identity())); - buildTestPlanApiCase(testPlan, apiCaseIds, apiTestCaseMap, apiCase.getCollectionId(), user, testPlanApiCaseList, logDTOS); + buildTestPlanApiCase(testPlan, apiCaseIds, apiTestCaseMap, apiCase.getCollectionId(), user, testPlanApiCaseList); } }); } } - private void handleApiData(List apiCaseList, SessionUser user, List testPlanApiCaseList, TestPlan testPlan, List logDTOS) { + private void handleApiData(List apiCaseList, SessionUser user, List testPlanApiCaseList, TestPlan testPlan) { if (CollectionUtils.isNotEmpty(apiCaseList)) { List ids = apiCaseList.stream().flatMap(item -> item.getIds().stream()).toList(); boolean isRepeat = testPlanConfigService.isRepeatCase(testPlan.getId()); @@ -607,7 +602,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService { Map> apiTestCaseMapIds = apiTestCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId, Collectors.mapping(ApiTestCase::getId, Collectors.toList()))); Collections.reverse(apiCaseIds); apiCaseIds.forEach(apiCaseId -> { - buildTestPlanApiCase(testPlan, apiTestCaseMapIds.get(apiCaseId), apiTestCaseMap, apiCase.getCollectionId(), user, testPlanApiCaseList, logDTOS); + buildTestPlanApiCase(testPlan, apiTestCaseMapIds.get(apiCaseId), apiTestCaseMap, apiCase.getCollectionId(), user, testPlanApiCaseList); }); } }); @@ -623,7 +618,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService { * @param user * @param testPlanApiCaseList */ - private void buildTestPlanApiCase(TestPlan testPlan, List ids, Map apiTestCases, String collectionId, SessionUser user, List testPlanApiCaseList, List logDTOS) { + private void buildTestPlanApiCase(TestPlan testPlan, List ids, Map apiTestCases, String collectionId, SessionUser user, List testPlanApiCaseList) { super.checkCollection(testPlan.getId(), collectionId, CaseType.API_CASE.getKey()); AtomicLong nextOrder = new AtomicLong(getNextOrder(collectionId)); Collections.reverse(ids); @@ -641,25 +636,9 @@ public class TestPlanApiCaseService extends TestPlanResourceService { testPlanApiCase.setExecuteUser(apiTestCase.getCreateUser()); testPlanApiCase.setLastExecResult(ExecStatus.PENDING.name()); testPlanApiCaseList.add(testPlanApiCase); - buildLog(logDTOS, testPlan, user, apiTestCase); }); } - private void buildLog(List logDTOS, TestPlan testPlan, SessionUser user, ApiTestCase apiTestCase) { - LogDTO dto = new LogDTO( - testPlan.getProjectId(), - user.getLastOrganizationId(), - testPlan.getId(), - user.getId(), - OperationLogType.ASSOCIATE.name(), - OperationLogModule.TEST_PLAN, - Translator.get("log.test_plan.api_case") + ":" + apiTestCase.getName()); - dto.setHistory(true); - dto.setPath("/test-plan/mind/data/edit"); - dto.setMethod(HttpMethodConstants.POST.name()); - logDTOS.add(dto); - } - @Override public void initResourceDefaultCollection(String planId, List defaultCollections) { TestPlanCollectionDTO defaultCollection = defaultCollections.stream().filter(collection -> StringUtils.equals(collection.getType(), CaseType.API_CASE.getKey()) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java index be8a533fff..56b51ea716 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java @@ -40,9 +40,6 @@ import io.metersphere.sdk.util.Translator; import io.metersphere.system.dto.LogInsertModule; import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.SessionUser; -import io.metersphere.system.log.constants.OperationLogModule; -import io.metersphere.system.log.constants.OperationLogType; -import io.metersphere.system.log.dto.LogDTO; import io.metersphere.system.service.UserLoginService; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.utils.ServiceUtils; @@ -177,15 +174,14 @@ public class TestPlanApiScenarioService extends TestPlanResourceService { @Override public void associateCollection(String planId, Map> collectionAssociates, SessionUser user) { List testPlanApiScenarioList = new ArrayList<>(); - List logDTOS = new ArrayList<>(); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId); - handleApiScenarioData(collectionAssociates.get(AssociateCaseType.API_SCENARIO), user, testPlanApiScenarioList, testPlan, logDTOS); + handleApiScenarioData(collectionAssociates.get(AssociateCaseType.API_SCENARIO), user, testPlanApiScenarioList, testPlan); if (CollectionUtils.isNotEmpty(testPlanApiScenarioList)) { testPlanApiScenarioMapper.batchInsert(testPlanApiScenarioList); } } - private void handleApiScenarioData(List apiScenarioList, SessionUser user, List testPlanApiScenarioList, TestPlan testPlan, List logDTOS) { + private void handleApiScenarioData(List apiScenarioList, SessionUser user, List testPlanApiScenarioList, TestPlan testPlan) { if (CollectionUtils.isNotEmpty(apiScenarioList)) { List ids = apiScenarioList.stream().flatMap(item -> item.getIds().stream()).toList(); ApiScenarioExample scenarioExample = new ApiScenarioExample(); @@ -197,7 +193,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService { List scenarios = apiScenarios.stream().filter(item -> apiScenarioIds.contains(item.getId())).toList(); // 生成map key为id value为scenario Map scenarioMap = scenarios.stream().collect(Collectors.toMap(ApiScenario::getId, Function.identity())); - buildTestPlanApiScenario(testPlan, apiScenarioIds, scenarioMap, apiScenario.getCollectionId(), user, testPlanApiScenarioList, logDTOS); + buildTestPlanApiScenario(testPlan, apiScenarioIds, scenarioMap, apiScenario.getCollectionId(), user, testPlanApiScenarioList); } }); } @@ -212,7 +208,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService { * @param user * @param testPlanApiScenarioList */ - private void buildTestPlanApiScenario(TestPlan testPlan, List ids, Map scenarios, String collectionId, SessionUser user, List testPlanApiScenarioList, List logDTOS) { + private void buildTestPlanApiScenario(TestPlan testPlan, List ids, Map scenarios, String collectionId, SessionUser user, List testPlanApiScenarioList) { super.checkCollection(testPlan.getId(), collectionId, CaseType.SCENARIO_CASE.getKey()); AtomicLong nextOrder = new AtomicLong(getNextOrder(collectionId)); Collections.reverse(ids); @@ -231,25 +227,9 @@ public class TestPlanApiScenarioService extends TestPlanResourceService { testPlanApiScenario.setExecuteUser(scenario.getCreateUser()); testPlanApiScenario.setLastExecResult(ExecStatus.PENDING.name()); testPlanApiScenarioList.add(testPlanApiScenario); - buildLog(logDTOS, testPlan, user, scenario); }); } - private void buildLog(List logDTOS, TestPlan testPlan, SessionUser user, ApiScenario scenario) { - LogDTO dto = new LogDTO( - testPlan.getProjectId(), - user.getLastOrganizationId(), - testPlan.getId(), - user.getId(), - OperationLogType.ASSOCIATE.name(), - OperationLogModule.TEST_PLAN, - Translator.get("log.test_plan.api_scenario") + ":" + scenario.getName()); - dto.setHistory(true); - dto.setPath("/test-plan/mind/data/edit"); - dto.setMethod(HttpMethodConstants.POST.name()); - logDTOS.add(dto); - } - @Override public void initResourceDefaultCollection(String planId, List defaultCollections) { TestPlanCollectionDTO defaultCollection = defaultCollections.stream().filter(collection -> StringUtils.equals(collection.getType(), CaseType.SCENARIO_CASE.getKey()) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java index 441fc59c33..e0e87f4a38 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java @@ -759,14 +759,12 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { public void associateCollection(String planId, Map> collectionAssociates, SessionUser user) { List testPlanFunctionalCaseList = new ArrayList<>(); List functionalList = collectionAssociates.get(AssociateCaseType.FUNCTIONAL); - List logDTOS = new ArrayList<>(); if (CollectionUtils.isNotEmpty(functionalList)) { TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId); - functionalList.forEach(functional -> buildTestPlanFunctionalCase(testPlan, functional, user, testPlanFunctionalCaseList, logDTOS)); + functionalList.forEach(functional -> buildTestPlanFunctionalCase(testPlan, functional, user, testPlanFunctionalCaseList)); } if (CollectionUtils.isNotEmpty(testPlanFunctionalCaseList)) { testPlanFunctionalCaseMapper.batchInsert(testPlanFunctionalCaseList); - operationLogService.batchAdd(logDTOS); } } @@ -778,7 +776,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { * @param user * @param testPlanFunctionalCaseList */ - private void buildTestPlanFunctionalCase(TestPlan testPlan, BaseCollectionAssociateRequest functional, SessionUser user, List testPlanFunctionalCaseList, List logDTOS) { + private void buildTestPlanFunctionalCase(TestPlan testPlan, BaseCollectionAssociateRequest functional, SessionUser user, List testPlanFunctionalCaseList) { super.checkCollection(testPlan.getId(), functional.getCollectionId(), CaseType.FUNCTIONAL_CASE.getKey()); List functionalIds = functional.getIds(); if (CollectionUtils.isNotEmpty(functionalIds)) { @@ -802,26 +800,10 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { testPlanFunctionalCase.setExecuteUser(functionalCase.getCreateUser()); testPlanFunctionalCase.setLastExecResult(ExecStatus.PENDING.name()); testPlanFunctionalCaseList.add(testPlanFunctionalCase); - buildLog(logDTOS, testPlan, user, functionalCase); }); } } - private void buildLog(List logDTOS, TestPlan testPlan, SessionUser user, FunctionalCase functionalCase) { - LogDTO dto = new LogDTO( - testPlan.getProjectId(), - user.getLastOrganizationId(), - testPlan.getId(), - user.getId(), - OperationLogType.ASSOCIATE.name(), - OperationLogModule.TEST_PLAN, - Translator.get("log.test_plan.functional_case") + ":" + functionalCase.getName()); - dto.setHistory(true); - dto.setPath("/test-plan/mind/data/edit"); - dto.setMethod(HttpMethodConstants.POST.name()); - logDTOS.add(dto); - } - @Override public void initResourceDefaultCollection(String planId, List defaultCollections) { TestPlanCollectionDTO defaultCollection = defaultCollections.stream().filter(collection -> StringUtils.equals(collection.getType(), CaseType.FUNCTIONAL_CASE.getKey()) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java index a7527b12ae..ad62bf0cbf 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceLogService.java @@ -88,23 +88,6 @@ public class TestPlanResourceLogService { } - public void saveDisassociateLog(TestPlan module, @Validated ResourceLogInsertModule logInsertModule) { - Project project = projectMapper.selectByPrimaryKey(module.getProjectId()); - LogDTO dto = LogDTOBuilder.builder() - .projectId(module.getProjectId()) - .organizationId(project.getOrganizationId()) - .type(OperationLogType.DISASSOCIATE.name()) - .module(logModule) - .method(logInsertModule.getRequestMethod()) - .path(logInsertModule.getRequestUrl()) - .sourceId(module.getId()) - .content(generateContent(module.getName(), logInsertModule.getResourceType(), "disassociate")) - .createUser(logInsertModule.getOperator()) - .build().getLogDTO(); - operationLogService.add(dto); - } - - public void saveAssociateLog(TestPlan module, @Validated ResourceLogInsertModule logInsertModule) { Project project = projectMapper.selectByPrimaryKey(module.getProjectId()); LogDTO dto = LogDTOBuilder.builder() diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java index 5deecd40cd..b516f8a923 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java @@ -57,7 +57,6 @@ public abstract class TestPlanResourceService extends TestPlanSortService { TestPlanResourceAssociationParam associationParam = new TestPlanResourceAssociationParam(associationIdList, testPlan.getProjectId(), testPlan.getId(), testPlan.getNum(), logInsertModule.getOperator()); disassociate.accept(associationParam); response.setAssociationCount(associationIdList.size()); - testPlanResourceLogService.saveDisassociateLog(testPlan, new ResourceLogInsertModule(resourceType, logInsertModule)); } return response; }