fix: 脑图创建用例自定义ID为空

This commit is contained in:
chenjianxing 2021-07-21 16:40:27 +08:00 committed by jianxing
parent babe767188
commit 77afd855ba
3 changed files with 18 additions and 8 deletions

View File

@ -24,8 +24,6 @@ import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.excel.domain.TestCaseExcelData; import io.metersphere.excel.domain.TestCaseExcelData;
import io.metersphere.excel.domain.TestCaseExcelDataFactory; import io.metersphere.excel.domain.TestCaseExcelDataFactory;
import io.metersphere.excel.handler.FunctionCaseTemplateWriteHandler; import io.metersphere.excel.handler.FunctionCaseTemplateWriteHandler;
import io.metersphere.excel.listener.TestCaseDataIgnoreErrorListener;
import io.metersphere.excel.listener.TestCaseDataListener;
import io.metersphere.excel.listener.TestCaseNoModelDataListener; import io.metersphere.excel.listener.TestCaseNoModelDataListener;
import io.metersphere.excel.utils.EasyExcelExporter; import io.metersphere.excel.utils.EasyExcelExporter;
import io.metersphere.excel.utils.FunctionCaseImportEnum; import io.metersphere.excel.utils.FunctionCaseImportEnum;
@ -146,6 +144,9 @@ public class TestCaseService {
testCase.setUpdateTime(System.currentTimeMillis()); testCase.setUpdateTime(System.currentTimeMillis());
checkTestCustomNum(testCase); checkTestCustomNum(testCase);
testCase.setNum(getNextNum(testCase.getProjectId())); testCase.setNum(getNextNum(testCase.getProjectId()));
if (StringUtils.isBlank(testCase.getCustomNum())) {
testCase.setCustomNum(testCase.getNum().toString());
}
testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name()); testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
testCase.setDemandId(testCase.getDemandId()); testCase.setDemandId(testCase.getDemandId());
testCase.setDemandName(testCase.getDemandName()); testCase.setDemandName(testCase.getDemandName());
@ -1209,14 +1210,19 @@ public class TestCaseService {
return; return;
} }
TestCaseExample example = new TestCaseExample();
List<String> editIds = data.stream() List<String> editIds = data.stream()
.filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20) .filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20)
.map(TestCaseWithBLOBs::getId).collect(Collectors.toList()); .map(TestCaseWithBLOBs::getId).collect(Collectors.toList());
example.createCriteria().andIdIn(editIds);
List<TestCaseWithBLOBs> testCaseWithBLOBs = testCaseMapper.selectByExampleWithBLOBs(example);
Map<String, TestCaseWithBLOBs> testCaseMap = testCaseWithBLOBs.stream().collect(Collectors.toMap(TestCaseWithBLOBs::getId, t -> t));
Map<String, TestCaseWithBLOBs> testCaseMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(editIds)) {
TestCaseExample example = new TestCaseExample();
example.createCriteria().andIdIn(editIds);
List<TestCaseWithBLOBs> testCaseWithBLOBs = testCaseMapper.selectByExampleWithBLOBs(example);
testCaseMap = testCaseWithBLOBs.stream().collect(Collectors.toMap(TestCaseWithBLOBs::getId, t -> t));
}
Map<String, TestCaseWithBLOBs> finalTestCaseMap = testCaseMap;
data.forEach(item -> { data.forEach(item -> {
if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) { if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) {
item.setNodeId(""); item.setNodeId("");
@ -1227,7 +1233,7 @@ public class TestCaseService {
item.setMaintainer(SessionUtils.getUserId()); item.setMaintainer(SessionUtils.getUserId());
addTestCase(item); addTestCase(item);
} else { } else {
TestCaseWithBLOBs dbCase = testCaseMap.get(item.getId()); TestCaseWithBLOBs dbCase = finalTestCaseMap.get(item.getId());
if (editCustomFieldsPriority(dbCase, item.getPriority())) { if (editCustomFieldsPriority(dbCase, item.getPriority())) {
item.setCustomFields(dbCase.getCustomFields()); item.setCustomFields(dbCase.getCustomFields());
}; };

View File

@ -149,4 +149,8 @@ export default {
</script> </script>
<style scoped> <style scoped>
/deep/ .el-table--border, .el-table--group {
border: 0px;
}
</style> </style>

View File

@ -65,7 +65,7 @@
</el-tooltip> </el-tooltip>
<el-tooltip :content="$t('test_track.case.unlink')" <el-tooltip :content="$t('test_track.case.unlink')"
placement="top" :enterable="false"> placement="top" :enterable="false">
<el-button type="danger" icon="el-icon-delete" size="mini" <el-button type="danger" icon="el-icon-unlock" size="mini"
circle :disabled="scope.row.platform !== 'Local'" circle :disabled="scope.row.platform !== 'Local'"
@click="deleteIssue(scope.row)" @click="deleteIssue(scope.row)"
/> />