From 50ee81300b4a882ee1efca8aa89d0a9521b54094 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Thu, 10 Aug 2023 16:58:54 +0800 Subject: [PATCH] fix: fix resourcePool and update userRole --- .../metersphere/sdk/service/TestResourcePoolService.java | 7 +++++++ .../system/controller/OrganizationController.java | 4 ++-- .../io/metersphere/system/service/OrganizationService.java | 2 +- .../system/controller/TestResourcePoolControllerTests.java | 5 ++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java index 8584bcfbcb..548fa00c9a 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/TestResourcePoolService.java @@ -340,11 +340,18 @@ public class TestResourcePoolService { if (testResourcePool == null) { throw new MSException(Translator.get("test_resource_pool_not_exists")); } + testResourcePool.setUpdateTime(System.currentTimeMillis()); if (testResourcePool.getEnable()) { testResourcePool.setEnable(false); } else { testResourcePool.setEnable(true); } + TestResourcePoolBlob testResourcePoolBlob = testResourcePoolBlobMapper.selectByPrimaryKey(testResourcePoolId); + byte[] configuration = testResourcePoolBlob.getConfiguration(); + String testResourceDTOStr = new String(configuration); + TestResourceDTO testResourceDTO = JSON.parseObject(testResourceDTOStr, TestResourceDTO.class); + checkApiConfig(testResourceDTO, testResourcePool, testResourcePool.getType()); + checkLoadConfig(testResourceDTO, testResourcePool, testResourcePool.getType()); testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool); } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationController.java index 5e0c2e8b29..f3d84e766c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationController.java @@ -28,9 +28,9 @@ import org.springframework.web.bind.annotation.*; import java.util.List; /** - * @author song-cc-rock + * @author guoyuqi */ -@Tag(name = "组织") +@Tag(name = "组织-成员") @RestController @RequestMapping("/organization") public class OrganizationController { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java index 70dea93ce7..2fea6e7e92 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java @@ -585,7 +585,7 @@ public class OrganizationService { List userRoleInDBInOrgIds = userRoleMap.values().stream().map(UserRole::getId).collect(Collectors.toList()); //删除旧的关系 UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample(); - userRoleRelationExample.createCriteria().andUserIdEqualTo(memberId).andRoleIdIn(userRoleInDBInOrgIds); + userRoleRelationExample.createCriteria().andUserIdEqualTo(memberId).andSourceIdEqualTo(organizationId); userRoleRelationMapper.deleteByExample(userRoleRelationExample); UserRoleRelationMapper userRoleRelationMapper = sqlSession.getMapper(UserRoleRelationMapper.class); userRoleInDBInOrgIds.forEach(userRoleId -> { diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java index edfdff89ea..eec8d0f942 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java @@ -527,7 +527,10 @@ class TestResourcePoolControllerTests extends BaseTest { @Test @Order(21) void unableTestResourcePoolSuccess() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/set/enable/104") + MvcResult testPoolBlob = this.addTestResourcePoolSuccess("test_pool_blob3", false, true, true, false, false, ResourcePoolTypeEnum.K8S.name()); + TestResourcePool testResourcePoolRequest1 = getResult(testPoolBlob); + String id = testResourcePoolRequest1.getId(); + mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/set/enable/"+id) .header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken)) .andExpect(status().isOk())