diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java index baf37b2e70..800f27464d 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java @@ -10,9 +10,6 @@ import io.metersphere.sdk.constants.HttpMethodConstants; import io.metersphere.sdk.constants.InternalUserRole; import io.metersphere.sdk.constants.OperationLogConstants; import io.metersphere.sdk.constants.UserRoleType; -import io.metersphere.system.log.dto.LogDTO; -import io.metersphere.system.dto.sdk.OptionDTO; -import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; @@ -20,12 +17,15 @@ import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.*; import io.metersphere.system.dto.*; +import io.metersphere.system.dto.request.ProjectAddMemberBatchRequest; +import io.metersphere.system.dto.sdk.OptionDTO; +import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.system.invoker.ProjectServiceInvoker; 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.mapper.*; -import io.metersphere.system.dto.request.ProjectAddMemberBatchRequest; import io.metersphere.system.uid.IDGenerator; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; @@ -349,7 +349,7 @@ public class CommonProjectService { project.setModuleSetting(null); projectDTO.setModuleIds(new ArrayList<>()); } - + project.setOrganizationId(null); projectMapper.updateByPrimaryKeySelective(project); return projectDTO; } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java index a8c3a12855..29daad50b5 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java @@ -590,7 +590,7 @@ public class OrganizationProjectControllerTests extends BaseTest { // 校验日志 checkLog(projectId, OperationLogType.ADD); //用户id为空 - project = this.generatorUpdate("organizationId", "projectId2", "organization-TestNameUserIdIsNull", "Edit name", true, new ArrayList<>()); + project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, "projectId2", "organization-TestNameUserIdIsNull", "Edit name", true, new ArrayList<>()); mvcResult = this.responsePost(updateProject, project); result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class); currentProject = projectMapper.selectByPrimaryKey(project.getId()); @@ -605,7 +605,7 @@ public class OrganizationProjectControllerTests extends BaseTest { Assertions.assertEquals(projectExtend.getModuleSetting(), CollectionUtils.isEmpty(project.getModuleIds()) ? null : JSON.toJSONString(project.getModuleIds())); // 修改模块设置 - project = this.generatorUpdate("organizationId", "projectId2", "org-Module", "Edit name", true, new ArrayList<>()); + project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, "projectId2", "org-Module", "Edit name", true, new ArrayList<>()); moduleIds = new ArrayList<>(); moduleIds.add("apiTest"); moduleIds.add("uiTest"); @@ -624,7 +624,7 @@ public class OrganizationProjectControllerTests extends BaseTest { Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleIds)); //设置资源池 - project = this.generatorUpdate("organizationId", "projectId3", "org-updatePools", "org-updatePools", true, new ArrayList<>()); + project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, "projectId3", "org-updatePools", "org-updatePools", true, new ArrayList<>()); project.setResourcePoolIds(List.of("resourcePoolId","resourcePoolId1")); mvcResult = this.responsePost(updateProject, project); result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class); @@ -649,22 +649,22 @@ public class OrganizationProjectControllerTests extends BaseTest { @Order(8) public void testUpdateProjectError() throws Exception { //项目名称存在 500 - UpdateProjectRequest project = this.generatorUpdate("organizationId", "projectId1","org-Module", "description", true, List.of("admin")); + UpdateProjectRequest project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, "projectId1", "org-Module", "description", true, List.of("admin")); this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER); //参数组织Id为空 project = this.generatorUpdate(null, "projectId",null, null, true , List.of("admin")); this.requestPost(updateProject, project, BAD_REQUEST_MATCHER); //项目Id为空 - project = this.generatorUpdate("organizationId", null,null, null, true, List.of("admin")); + project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, null, null, null, true, List.of("admin")); this.requestPost(updateProject, project, BAD_REQUEST_MATCHER); //项目名称为空 - project = this.generatorUpdate("organizationId", "projectId",null, null, true, List.of("admin")); + project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, "projectId", null, null, true, List.of("admin")); this.requestPost(updateProject, project, BAD_REQUEST_MATCHER); //项目不存在 - project = this.generatorUpdate("organizationId", "1111","123", null, true, List.of("admin")); + project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, "1111", "123", null, true, List.of("admin")); this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER); //资源池不存在 - project = this.generatorUpdate("organizationId", "projectId","org-Module-pool", null, true, List.of("admin")); + project = this.generatorUpdate(DEFAULT_ORGANIZATION_ID, "projectId", "org-Module-pool", null, true, List.of("admin")); project.setResourcePoolIds(List.of("resourcePoolId3")); this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER);