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) { public List<OptionDTO> getPoolOptions(String projectId) {
checkProjectNotExist(projectId); List<TestResourcePool> pools = getPoolOption(projectId);
List<String> poolIds = getPoolIds(projectId); return pools.stream().map(pool -> {
if (CollectionUtils.isEmpty(poolIds)) { OptionDTO option = new OptionDTO();
return new ArrayList<>(); option.setId(pool.getId());
} option.setName(pool.getName());
TestResourcePoolExample example = new TestResourcePoolExample(); return option;
TestResourcePoolExample.Criteria criteria = example.createCriteria(); }).toList();
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();
} }
public static Project checkResourceExist(String id) { public static Project checkResourceExist(String id) {

View File

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