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) {
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);
}
}

View File

@ -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 {

View File

@ -585,7 +585,7 @@ public class OrganizationService {
List<String> 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 -> {

View File

@ -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())