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.TestCaseExcelDataFactory;
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.utils.EasyExcelExporter;
import io.metersphere.excel.utils.FunctionCaseImportEnum;
@ -146,6 +144,9 @@ public class TestCaseService {
testCase.setUpdateTime(System.currentTimeMillis());
checkTestCustomNum(testCase);
testCase.setNum(getNextNum(testCase.getProjectId()));
if (StringUtils.isBlank(testCase.getCustomNum())) {
testCase.setCustomNum(testCase.getNum().toString());
}
testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
testCase.setDemandId(testCase.getDemandId());
testCase.setDemandName(testCase.getDemandName());
@ -1209,14 +1210,19 @@ public class TestCaseService {
return;
}
TestCaseExample example = new TestCaseExample();
List<String> editIds = data.stream()
.filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20)
.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 -> {
if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) {
item.setNodeId("");
@ -1227,7 +1233,7 @@ public class TestCaseService {
item.setMaintainer(SessionUtils.getUserId());
addTestCase(item);
} else {
TestCaseWithBLOBs dbCase = testCaseMap.get(item.getId());
TestCaseWithBLOBs dbCase = finalTestCaseMap.get(item.getId());
if (editCustomFieldsPriority(dbCase, item.getPriority())) {
item.setCustomFields(dbCase.getCustomFields());
};

View File

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

View File

@ -65,7 +65,7 @@
</el-tooltip>
<el-tooltip :content="$t('test_track.case.unlink')"
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'"
@click="deleteIssue(scope.row)"
/>