fix(UI自动化): 修复开源版任务中心报错问题
This commit is contained in:
parent
05d8ec8302
commit
4fbadfa421
|
@ -0,0 +1,8 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface BaseInformationSchemaTableMapper {
|
||||
|
||||
String checkExist(@Param("tableName") String tableName);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.BaseInformationSchemaTableMapper">
|
||||
<select id="checkExist" resultType="java.lang.String">
|
||||
select TABLE_NAME
|
||||
from information_schema.TABLES
|
||||
where TABLE_NAME = #{tableName}
|
||||
</select>
|
||||
</mapper>
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
|
||||
public interface BaseTaskMapper {
|
||||
|
||||
List<TaskCenterDTO> getTasks(@Param("request") TaskCenterRequest request);
|
||||
List<TaskCenterDTO> getTasks(@Param("request") TaskCenterRequest request, @Param("uiPermission") Boolean uiPermission);
|
||||
|
||||
int getRunningTasks(@Param("request") TaskCenterRequest request);
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
AND t.user_id = #{request.executor}
|
||||
</if>
|
||||
)
|
||||
<if test="uiPermission">
|
||||
UNION ALL
|
||||
(SELECT t.id,t.name AS name ,'UI_SCENARIO' AS
|
||||
executionModule,t.report_type, ifnull(t2.name,'LOCAL') AS actuator, t1.`name` AS executor,t.create_time AS
|
||||
|
@ -108,6 +109,7 @@
|
|||
AND t.user_id = #{request.executor}
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
)tt ORDER BY tt.executionTime DESC
|
||||
</select>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.task.service;
|
||||
|
||||
import io.metersphere.base.mapper.ext.BaseInformationSchemaTableMapper;
|
||||
import io.metersphere.base.mapper.ext.BaseScheduleMapper;
|
||||
import io.metersphere.base.mapper.ext.BaseTaskMapper;
|
||||
import io.metersphere.commons.constants.MicroServiceName;
|
||||
|
@ -30,6 +31,8 @@ public class TaskService {
|
|||
@Resource
|
||||
private BaseScheduleMapper baseScheduleMapper;
|
||||
@Resource
|
||||
private BaseInformationSchemaTableMapper baseInformationSchemaTableMapper;
|
||||
@Resource
|
||||
private BaseCheckPermissionService baseCheckPermissionService;
|
||||
@Resource
|
||||
private MicroService microService;
|
||||
|
@ -38,6 +41,7 @@ public class TaskService {
|
|||
private static final String PERF = "PERFORMANCE";
|
||||
|
||||
private static final String UI = "UI_SCENARIO";
|
||||
private static final String UI_SCENARIO_REPORT = "ui_scenario_report";
|
||||
|
||||
public List<String> getOwnerProjectIds(String userId) {
|
||||
Set<String> userRelatedProjectIds = null;
|
||||
|
@ -56,7 +60,7 @@ public class TaskService {
|
|||
if (CollectionUtils.isEmpty(request.getProjects())) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return baseTaskMapper.getTasks(request);
|
||||
return baseTaskMapper.getTasks(request,checkUiPermission());
|
||||
}
|
||||
|
||||
public int getRunningTasks(TaskCenterRequest request) {
|
||||
|
@ -110,4 +114,15 @@ public class TaskService {
|
|||
microService.postForData(MicroServiceName.API_TEST, "/api/automation/stop/batch", reportIds);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkUiPermission(){
|
||||
try {
|
||||
String uiScenarioReport = baseInformationSchemaTableMapper.checkExist(UI_SCENARIO_REPORT);
|
||||
if(StringUtils.isNotEmpty(uiScenarioReport)){
|
||||
return true;
|
||||
}
|
||||
}catch (Exception e){
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue