fix(测试计划): 接口用例批量修改环境为环境组未生效

--bug=1008300 --user=lyh 【测试跟踪】测试计划-接口用例,批量编辑,修改环境-选择环境组,没有生效
https://www.tapd.cn/55049933/s/1073876
This commit is contained in:
shiziyuan9527 2021-11-24 10:52:34 +08:00 committed by shiziyuan9527
parent 8a0b3da88a
commit c2e9d63a1b
3 changed files with 14 additions and 2 deletions

View File

@ -23,4 +23,6 @@ public class TestPlanApiCaseBatchRequest extends TestPlanTestCase {
private Map<String, String> projectEnvMap;
private ApiCaseBatchCondition condition;
private String environmentType;
private String environmentGroupId;
}

View File

@ -233,12 +233,20 @@ public class TestPlanApiCaseService {
Map<String, String> rows = request.getSelectRows();
Set<String> ids = rows.keySet();
request.setIds(new ArrayList<>(ids));
Map<String, String> env = request.getProjectEnvMap();
Map<String, String> env = new HashMap<>();
String environmentType = request.getEnvironmentType();
String environmentGroupId = request.getEnvironmentGroupId();
if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
env = request.getProjectEnvMap();
} else if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name()) && StringUtils.isNotBlank(environmentGroupId)) {
env = environmentGroupProjectService.getEnvMap(environmentGroupId);
}
if (env != null && !env.isEmpty()) {
Map<String, String> finalEnv = env;
ids.forEach(id -> {
TestPlanApiCase apiCase = new TestPlanApiCase();
apiCase.setId(id);
apiCase.setEnvironmentId(env.get(rows.get(id)));
apiCase.setEnvironmentId(finalEnv.get(rows.get(id)));
testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase);
});
}

View File

@ -542,6 +542,8 @@ export default {
let dataRows = response.data;
let map = new Map();
param.projectEnvMap = strMapToObj(form.projectEnvMap);
param.environmentType = form.environmentType;
param.environmentGroupId = form.envGroupId;
dataRows.forEach(row => {
map[row.id] = row.projectId;
});