From 9183fdcb0885e3ee0cec8450cf32f765a5624210 Mon Sep 17 00:00:00 2001 From: zhangyong Date: Tue, 1 Nov 2022 14:05:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(UI=E8=87=AA=E5=8A=A8=E5=8C=96):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=BC=80=E6=BA=90=E7=89=88=E4=BB=BB=E5=8A=A1=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/BaseInformationSchemaTableMapper.java | 8 ++++ .../ext/BaseInformationSchemaTableMapper.xml | 9 ++++ .../base/mapper/ext/BaseTaskMapper.java | 2 +- .../base/mapper/ext/BaseTaskMapper.xml | 42 ++++++++++--------- .../metersphere/task/service/TaskService.java | 17 +++++++- 5 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.java create mode 100644 framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.xml diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.java new file mode 100644 index 0000000000..31902525da --- /dev/null +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.java @@ -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); +} \ No newline at end of file diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.xml b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.xml new file mode 100644 index 0000000000..7f707347cd --- /dev/null +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseInformationSchemaTableMapper.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.java index 0ff58a56cc..fa20d608b8 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.java @@ -8,7 +8,7 @@ import java.util.List; public interface BaseTaskMapper { - List getTasks(@Param("request") TaskCenterRequest request); + List getTasks(@Param("request") TaskCenterRequest request, @Param("uiPermission") Boolean uiPermission); int getRunningTasks(@Param("request") TaskCenterRequest request); diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.xml b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.xml index 336885e773..aaee059fac 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.xml +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/base/mapper/ext/BaseTaskMapper.xml @@ -87,27 +87,29 @@ AND t.user_id = #{request.executor} ) - 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 - executionTime, t.trigger_mode AS triggerMode ,t.status AS executionStatus - FROM ui_scenario_report t INNER JOIN `user` t1 ON t.user_id = t1.id LEFT JOIN test_resource_pool t2 ON - t.actuator = t2.id - WHERE to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) AND t.execute_type !='Debug' AND t.execute_type - !='Marge' AND t.project_id IN - - #{id} - - - AND t.trigger_mode = #{request.triggerMode} + + 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 + executionTime, t.trigger_mode AS triggerMode ,t.status AS executionStatus + FROM ui_scenario_report t INNER JOIN `user` t1 ON t.user_id = t1.id LEFT JOIN test_resource_pool t2 ON + t.actuator = t2.id + WHERE to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) AND t.execute_type !='Debug' AND t.execute_type + !='Marge' AND t.project_id IN + + #{id} + + + AND t.trigger_mode = #{request.triggerMode} + + + AND t.status = #{request.executionStatus} + + + AND t.user_id = #{request.executor} + + ) - - AND t.status = #{request.executionStatus} - - - AND t.user_id = #{request.executor} - - ) )tt ORDER BY tt.executionTime DESC diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java index 65d88d2b3f..f276a19958 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/task/service/TaskService.java @@ -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 getOwnerProjectIds(String userId) { Set 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; + } }