fix(接口测试): 接口执行资源池校验问题

This commit is contained in:
song-cc-rock 2024-10-16 10:41:35 +08:00 committed by Craftsman
parent 49af0211e3
commit 98e38ffefc
2 changed files with 16 additions and 19 deletions

View File

@ -171,18 +171,13 @@ public class ProjectService {
}
public List<OptionDTO> getPoolOptions(String projectId) {
checkProjectNotExist(projectId);
List<String> poolIds = getPoolIds(projectId);
if (CollectionUtils.isEmpty(poolIds)) {
return new ArrayList<>();
}
TestResourcePoolExample example = new TestResourcePoolExample();
TestResourcePoolExample.Criteria criteria = example.createCriteria();
criteria.andIdIn(poolIds).andEnableEqualTo(true).andDeletedEqualTo(false);
List<TestResourcePool> testResourcePools = testResourcePoolMapper.selectByExample(example);
return testResourcePools.stream().map(testResourcePool ->
new OptionDTO(testResourcePool.getId(), testResourcePool.getName())
).toList();
List<TestResourcePool> pools = getPoolOption(projectId);
return pools.stream().map(pool -> {
OptionDTO option = new OptionDTO();
option.setId(pool.getId());
option.setName(pool.getName());
return option;
}).toList();
}
public static Project checkResourceExist(String id) {

View File

@ -688,14 +688,16 @@ public class CommonProjectService {
* @return
*/
public boolean validateProjectResourcePool(TestResourcePool resourcePool, String projectId) {
ProjectTestResourcePoolExample example = new ProjectTestResourcePoolExample();
example.createCriteria()
.andProjectIdEqualTo(projectId)
.andTestResourcePoolIdEqualTo(resourcePool.getId());
if (projectTestResourcePoolMapper.countByExample(example) < 1) {
return false;
}
Project project = projectMapper.selectByPrimaryKey(projectId);
if (!project.getAllResourcePool()) {
ProjectTestResourcePoolExample example = new ProjectTestResourcePoolExample();
example.createCriteria()
.andProjectIdEqualTo(projectId)
.andTestResourcePoolIdEqualTo(resourcePool.getId());
if (projectTestResourcePoolMapper.countByExample(example) < 1) {
return false;
}
}
// 校验组织是否有权限
return testResourcePoolService.validateOrgResourcePool(resourcePool, project.getOrganizationId());
}