fix: fix resourcePool and update userRole

This commit is contained in:
guoyuqi 2023-08-10 16:58:54 +08:00 committed by 刘瑞斌
parent fb81ab845a
commit 50ee81300b
4 changed files with 14 additions and 4 deletions

View File

@ -340,11 +340,18 @@ public class TestResourcePoolService {
if (testResourcePool == null) { if (testResourcePool == null) {
throw new MSException(Translator.get("test_resource_pool_not_exists")); throw new MSException(Translator.get("test_resource_pool_not_exists"));
} }
testResourcePool.setUpdateTime(System.currentTimeMillis());
if (testResourcePool.getEnable()) { if (testResourcePool.getEnable()) {
testResourcePool.setEnable(false); testResourcePool.setEnable(false);
} else { } else {
testResourcePool.setEnable(true); 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); testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool);
} }
} }

View File

@ -28,9 +28,9 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
/** /**
* @author song-cc-rock * @author guoyuqi
*/ */
@Tag(name = "组织") @Tag(name = "组织-成员")
@RestController @RestController
@RequestMapping("/organization") @RequestMapping("/organization")
public class OrganizationController { public class OrganizationController {

View File

@ -585,7 +585,7 @@ public class OrganizationService {
List<String> userRoleInDBInOrgIds = userRoleMap.values().stream().map(UserRole::getId).collect(Collectors.toList()); List<String> userRoleInDBInOrgIds = userRoleMap.values().stream().map(UserRole::getId).collect(Collectors.toList());
//删除旧的关系 //删除旧的关系
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample(); UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
userRoleRelationExample.createCriteria().andUserIdEqualTo(memberId).andRoleIdIn(userRoleInDBInOrgIds); userRoleRelationExample.createCriteria().andUserIdEqualTo(memberId).andSourceIdEqualTo(organizationId);
userRoleRelationMapper.deleteByExample(userRoleRelationExample); userRoleRelationMapper.deleteByExample(userRoleRelationExample);
UserRoleRelationMapper userRoleRelationMapper = sqlSession.getMapper(UserRoleRelationMapper.class); UserRoleRelationMapper userRoleRelationMapper = sqlSession.getMapper(UserRoleRelationMapper.class);
userRoleInDBInOrgIds.forEach(userRoleId -> { userRoleInDBInOrgIds.forEach(userRoleId -> {

View File

@ -527,7 +527,10 @@ class TestResourcePoolControllerTests extends BaseTest {
@Test @Test
@Order(21) @Order(21)
void unableTestResourcePoolSuccess() throws Exception { 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.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)) .header(SessionConstants.CSRF_TOKEN, csrfToken))
.andExpect(status().isOk()) .andExpect(status().isOk())