fix: 导入测试用例报错

This commit is contained in:
chenjianxing 2021-09-17 10:39:58 +08:00 committed by jianxing
parent 0171d1ece0
commit 8912941bea
2 changed files with 6 additions and 3 deletions

View File

@ -252,7 +252,7 @@
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
${order.name} ${order.type}
`${order.name}` ${order.type}
</foreach>
</if>
</select>

View File

@ -598,11 +598,12 @@ public class TestCaseService {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
Project project = projectService.getProjectById(projectId);
TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);
Long nextOrder = ServiceUtils.getNextOrder(projectId, extTestCaseMapper::getLastOrder);
if (!testCases.isEmpty()) {
AtomicInteger sort = new AtomicInteger();
AtomicInteger num = new AtomicInteger();
num.set(getNextNum(projectId) + testCases.size());
testCases.forEach(testcase -> {
for (TestCaseWithBLOBs testcase: testCases) {
testcase.setId(UUID.randomUUID().toString());
testcase.setCreateUser(SessionUtils.getUserId());
testcase.setCreateTime(System.currentTimeMillis());
@ -615,8 +616,10 @@ public class TestCaseService {
testcase.setCustomNum(String.valueOf(number));
}
testcase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
testcase.setOrder(nextOrder);
mapper.insert(testcase);
});
nextOrder += 5000;
}
}
sqlSession.flushStatements();
}