fix(测试跟踪): 未启动过UI模块,删除测试计划报告会报sql错误

--bug=1028038 --user=陈建星 [测试跟踪] github #25722测试计划删除报错,Internal exception occured, please check logs or contact administrator. https://www.tapd.cn/55049933/s/1397882
This commit is contained in:
jianxing 2023-07-26 14:39:06 +08:00 committed by jianxing
parent 4872ee619d
commit b7d59b1665
3 changed files with 8 additions and 3 deletions

View File

@ -4,6 +4,6 @@
<select id="checkExist" resultType="java.lang.String">
select TABLE_NAME
from information_schema.TABLES
where TABLE_NAME = #{tableName}
where TABLE_NAME = #{tableName} limit 1
</select>
</mapper>

View File

@ -173,7 +173,7 @@ public class TaskService {
}
}
private boolean checkUiPermission() {
public boolean checkUiPermission() {
try {
String uiScenarioReport = baseInformationSchemaTableMapper.checkExist(UI_SCENARIO_REPORT);
if (StringUtils.isNotEmpty(uiScenarioReport)) {

View File

@ -33,6 +33,7 @@ import io.metersphere.service.BaseProjectService;
import io.metersphere.service.BaseUserService;
import io.metersphere.service.IssuesService;
import io.metersphere.service.ServiceUtils;
import io.metersphere.task.service.TaskService;
import io.metersphere.utils.BatchProcessingUtil;
import io.metersphere.utils.DiscoveryUtil;
import io.metersphere.utils.LoggerUtil;
@ -85,7 +86,7 @@ public class TestPlanReportService {
@Resource
private TestPlanPrincipalMapper testPlanPrincipalMapper;
@Resource
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
private TaskService taskService;
@Resource
private TestResourcePoolMapper testResourcePoolMapper;
@Resource
@ -926,6 +927,10 @@ public class TestPlanReportService {
//删除执行测试计划产生的UI报告
private void deleteUiReportByTestPlanExecute(List<String> testPlanReportIdList) {
if (CollectionUtils.isNotEmpty(testPlanReportIdList)) {
// 如果 UI 的表没有初始化则不删除
if (!taskService.checkUiPermission()) {
return;
}
List<String> scenarioReportIds = extTestPlanReportContentMapper.selectUiReportByTestPlanReportIds(testPlanReportIdList);
if (CollectionUtils.isNotEmpty(scenarioReportIds)) {
try {