fix(项目设置): 添加和修改更新测试计划的定时任务设置没有记录操作日志

--bug=1012974 --user=王孝刚 [接口测试]github#13226添加和修改更新测试计划的定时任务设置没有记录操作日志
https://www.tapd.cn/55049933/s/1152998
This commit is contained in:
wxg0103 2022-05-05 17:44:33 +08:00 committed by halo-ci-bot[bot]
parent b37e9a8c86
commit b7475709e2
17 changed files with 181 additions and 58 deletions

View File

@ -279,11 +279,13 @@ public class ApiAutomationController {
}
@PostMapping(value = "/schedule/update")
@MsAuditLog(module = OperLogModule.API_AUTOMATION_SCHEDULE, type = OperLogConstants.UPDATE, title = "#request.name", beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
public void updateSchedule(@RequestBody Schedule request) {
apiAutomationService.updateSchedule(request);
}
@PostMapping(value = "/schedule/create")
@MsAuditLog(module = OperLogModule.API_AUTOMATION_SCHEDULE, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ApiAutomationService.class)
public void createSchedule(@RequestBody ScheduleRequest request) {
apiAutomationService.createSchedule(request);
}

View File

@ -39,6 +39,7 @@ import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.api.AutomationReference;
import io.metersphere.log.vo.schedule.ScheduleReference;
import io.metersphere.plugin.core.MsTestElement;
import io.metersphere.service.*;
import io.metersphere.track.dto.TestPlanDTO;
@ -57,6 +58,8 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.jorphan.collections.HashTree;
import org.apache.jorphan.collections.ListedHashTree;
import org.mybatis.spring.SqlSessionUtils;
import org.quartz.JobKey;
import org.quartz.TriggerKey;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -91,6 +94,8 @@ public class ApiAutomationService {
@Resource
private ScheduleService scheduleService;
@Resource
private ScheduleMapper scheduleMapper;
@Resource
private ApiScenarioReportService apiReportService;
@Resource
private ExtTestPlanMapper extTestPlanMapper;
@ -1050,8 +1055,16 @@ public class ApiAutomationService {
}
public void updateSchedule(Schedule request) {
JobKey jobKey = null;
TriggerKey triggerKey = null;
Class clazz = null;
scheduleService.editSchedule(request);
jobKey = ApiScenarioTestJob.getJobKey(request.getResourceId());
triggerKey = ApiScenarioTestJob.getTriggerKey(request.getResourceId());
clazz = ApiScenarioTestJob.class;
request.setJob(ApiScenarioTestJob.class.getName());
this.addOrUpdateApiScenarioCronJob(request);
scheduleService.resetJob(request, jobKey, triggerKey, clazz);
}
private void addOrUpdateApiScenarioCronJob(Schedule request) {
@ -1655,6 +1668,12 @@ public class ApiAutomationService {
}
public String getLogDetails(String id) {
Schedule bloB = scheduleMapper.selectByPrimaryKey(id);
if (bloB != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloB, ScheduleReference.scheduleColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(bloB.getId()), bloB.getProjectId(), bloB.getName(), bloB.getUserId(), columns);
return JSON.toJSONString(details);
}
ApiScenarioWithBLOBs bloBs = apiScenarioMapper.selectByPrimaryKey(id);
if (bloBs != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloBs, AutomationReference.automationColumns);
@ -1691,6 +1710,16 @@ public class ApiAutomationService {
return null;
}
public String getLogDetails(ScheduleRequest request) {
Schedule bloBs = scheduleService.getScheduleByResource(request.getResourceId(), request.getGroup());
if (bloBs != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloBs, ScheduleReference.scheduleColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(bloBs.getId()), bloBs.getProjectId(), bloBs.getName(), bloBs.getUserId(), columns);
return JSON.toJSONString(details);
}
return null;
}
@Async
public void resetApiScenarioReferenceId() {
LogUtil.info("Reset apiScenarioReferenceId is start.");

View File

@ -13,10 +13,12 @@ public class OperLogModule {
public static final String WORKSPACE_TEMPLATE_SETTINGS_CASE = "WORKSPACE_TEMPLATE_SETTINGS_CASE";
public static final String WORKSPACE_MEMBER = "WORKSPACE_MEMBER";
public static final String API_AUTOMATION = "API_AUTOMATION";
public static final String API_AUTOMATION_SCHEDULE = "API_AUTOMATION_SCHEDULE";
public static final String API_AUTOMATION_REPORT = "API_AUTOMATION_REPORT";
public static final String API_DEFINITION = "API_DEFINITION";
public static final String API_DEFINITION_CASE = "API_DEFINITION_CASE";
public static final String TRACK_TEST_PLAN = "TRACK_TEST_PLAN";
public static final String TRACK_TEST_PLAN_SCHEDULE = "TRACK_TEST_PLAN_SCHEDULE";
public static final String TRACK_BUG = "TRACK_BUG";
public static final String TRACK_TEST_CASE_REVIEW = "TRACK_TEST_CASE_REVIEW";
public static final String TRACK_TEST_CASE = "TRACK_TEST_CASE";

View File

@ -4,9 +4,12 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.service.ApiAutomationService;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.dto.ScheduleDao;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.ScheduleService;
import org.springframework.web.bind.annotation.*;
@ -34,11 +37,13 @@ public class ScheduleController {
}
@PostMapping(value = "/update")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN_SCHEDULE, type = OperLogConstants.UPDATE, title = "#request.name", beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = ScheduleService.class)
public void updateSchedule(@RequestBody Schedule request) {
scheduleService.updateSchedule(request);
}
@PostMapping(value = "/create")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN_SCHEDULE, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ScheduleService.class)
public void createSchedule(@RequestBody ScheduleRequest request) {
scheduleService.createSchedule(request);
}

View File

@ -0,0 +1,23 @@
package io.metersphere.log.vo.schedule;
import java.util.LinkedHashMap;
import java.util.Map;
public class ScheduleReference {
public static Map<String, String> scheduleColumns = new LinkedHashMap<>();
static {
scheduleColumns.clear();
scheduleColumns.put("name", "定时任务名称");
scheduleColumns.put("type", "定时任务类型");
scheduleColumns.put("value", "cron表达式");
scheduleColumns.put("group", "用例类型");
scheduleColumns.put("enable", "定时任务状态");
scheduleColumns.put("userId", "创建人");
scheduleColumns.put("config", "定时任务配置");
// 需要深度对比的字段可以支持多个req1,req2
scheduleColumns.put("ms-dff-col", "config");
}
}

View File

@ -19,6 +19,10 @@ import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.dto.ScheduleDao;
import io.metersphere.job.sechedule.*;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.schedule.ScheduleReference;
import org.apache.commons.lang3.StringUtils;
import org.quartz.JobKey;
import org.quartz.SchedulerException;
@ -344,4 +348,24 @@ public class ScheduleService {
}
}
public String getLogDetails(String id) {
Schedule bloB = scheduleMapper.selectByPrimaryKey(id);
if (bloB != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloB, ScheduleReference.scheduleColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(bloB.getId()), bloB.getProjectId(), bloB.getName(), bloB.getUserId(), columns);
return JSON.toJSONString(details);
}
return null;
}
public String getLogDetails(ScheduleRequest request) {
Schedule bloBs = this.getScheduleByResource(request.getResourceId(), request.getGroup());
if (bloBs != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(bloBs, ScheduleReference.scheduleColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(bloBs.getId()), bloBs.getProjectId(), bloBs.getName(), bloBs.getUserId(), columns);
return JSON.toJSONString(details);
}
return null;
}
}

@ -1 +1 @@
Subproject commit b9bbc67a4e477bb0f6a169c27f8e9ea8060c1e1d
Subproject commit 04012284cd9cd16dd6270f01e71ec4714d67babf

View File

@ -250,11 +250,13 @@ ssl_file_error=Failed to load the certification file, please check the certifica
#log
api_definition=Api definition
api_definition_case=Api definition case
api_automation_schedule=Api automation schedule
api_automation=Api automation
api_automation_report=Test Report
track_test_case=Test case
track_test_case_review=Case review
track_test_plan=Test plan
track_test_plan_schedule=Test plan schedule
track_bug=Defect management
track_report=Report
performance_test=Performance test

View File

@ -250,10 +250,12 @@ ssl_file_error=认证文件加载失败,请检查认证文件
api_definition=接口定义
api_definition_case=接口定义用例
api_automation=接口自动化
api_automation_schedule=接口自动化-定时任务
api_automation_report=测试报告
track_test_case=测试用例
track_test_case_review=用例评审
track_test_plan=测试计划
track_test_plan_schedule=测试计划-定时任务
track_bug=缺陷管理
track_report=报告
performance_test=性能测试

View File

@ -249,10 +249,12 @@ ssl_file_error=認證文件加載失敗,請檢查認證文件
api_definition=接口定義
api_definition_case=接口定義用例
api_automation=接口自動化
api_automation_schedule=接口自動化-定時任務
api_automation_report=測試報告
track_test_case=測試用例
track_test_case_review=用例評審
track_test_plan=測試計劃
track_test_plan_schedule=測試計劃-定時任務
track_bug=缺陷管理
track_report=報告
performance_test=性能測試

View File

@ -376,6 +376,8 @@ export default {
let param = {};
param = this.schedule;
param.resourceId = this.testId;
param.name = this.paramRow.name;
param.group = this.scheduleTaskType;
// projectId
if (!param.projectId) {
param.projectId = getCurrentProjectID();
@ -412,7 +414,7 @@ export default {
} else {
param.scheduleFrom = "scenario";
if (param.id) {
url = '/schedule/update';
url = '/api/automation/schedule/update';
}
}

View File

@ -60,30 +60,32 @@ export function LOG_MODULE_MAP(_this) {
let LOG_MODULE_MAP = new Map([
['SYSTEM_PARAMETER_SETTING', _this.$t('operating_log.system_parameter_setting')],
['SYSTEM_TEST_RESOURCE', _this.$t('operating_log.system_test_resource')],
['SYSTEM_USER', _this.$t('operating_log.system_user')],
['SYSTEM_WORKSPACE', _this.$t('operating_log.system_workspace')],
['WORKSPACE_TEMPLATE_SETTINGS', _this.$t('operating_log.workspace_template_settings')],
['WORKSPACE_MESSAGE_SETTINGS', _this.$t('operating_log.workspace_message_settings')],
['WORKSPACE_TEMPLATE_SETTINGS_FIELD', _this.$t('operating_log.workspace_template_settings_field')],
['WORKSPACE_TEMPLATE_SETTINGS_ISSUE', _this.$t('operating_log.workspace_template_settings_issue')],
['WORKSPACE_SERVICE_INTEGRATION', _this.$t('operating_log.workspace_service_integration')],
['WORKSPACE_TEMPLATE_SETTINGS_CASE', _this.$t('operating_log.workspace_template_settings_case')],
['WORKSPACE_MEMBER', _this.$t('operating_log.workspace_member')],
['API_AUTOMATION', _this.$t('operating_log.api_automation')],
['API_AUTOMATION_REPORT', _this.$t('operating_log.api_automation_report')],
['API_DEFINITION', _this.$t('operating_log.api_definition')],
['API_DEFINITION_CASE', _this.$t('operating_log.api_definition_case')],
['TRACK_TEST_PLAN', _this.$t('operating_log.track_test_plan')],
['TRACK_BUG', _this.$t('operating_log.track_bug')],
['TRACK_TEST_CASE_REVIEW', _this.$t('operating_log.track_test_case_review')],
['TRACK_TEST_CASE', _this.$t('operating_log.track_test_case')],
['TRACK_REPORT', _this.$t('operating_log.track_report')],
['AUTH_TITLE', _this.$t('operating_log.auth_title')],
['PROJECT_PROJECT_JAR', _this.$t('operating_log.project_project_jar')],
['PROJECT_ENVIRONMENT_SETTING', _this.$t('operating_log.project_environment_setting')],
['PROJECT_PROJECT_MANAGER', _this.$t('operating_log.project_project_manager')],
['PROJECT_FILE_MANAGEMENT', _this.$t('operating_log.project_file_management')],
['PROJECT_PROJECT_MEMBER', _this.$t('operating_log.project_project_member')],
['SYSTEM_USER', _this.$t('operating_log.system_user')],
['SYSTEM_WORKSPACE', _this.$t('operating_log.system_workspace')],
['WORKSPACE_TEMPLATE_SETTINGS', _this.$t('operating_log.workspace_template_settings')],
['WORKSPACE_MESSAGE_SETTINGS', _this.$t('operating_log.workspace_message_settings')],
['WORKSPACE_TEMPLATE_SETTINGS_FIELD', _this.$t('operating_log.workspace_template_settings_field')],
['WORKSPACE_TEMPLATE_SETTINGS_ISSUE', _this.$t('operating_log.workspace_template_settings_issue')],
['WORKSPACE_SERVICE_INTEGRATION', _this.$t('operating_log.workspace_service_integration')],
['WORKSPACE_TEMPLATE_SETTINGS_CASE', _this.$t('operating_log.workspace_template_settings_case')],
['WORKSPACE_MEMBER', _this.$t('operating_log.workspace_member')],
['API_AUTOMATION', _this.$t('operating_log.api_automation')],
['API_AUTOMATION_SCHEDULE', _this.$t('operating_log.api_automation_schedule')],
['API_AUTOMATION_REPORT', _this.$t('operating_log.api_automation_report')],
['API_DEFINITION', _this.$t('operating_log.api_definition')],
['API_DEFINITION_CASE', _this.$t('operating_log.api_definition_case')],
['TRACK_TEST_PLAN', _this.$t('operating_log.track_test_plan')],
['TRACK_TEST_PLAN_SCHEDULE', _this.$t('operating_log.track_test_plan_schedule')],
['TRACK_BUG', _this.$t('operating_log.track_bug')],
['TRACK_TEST_CASE_REVIEW', _this.$t('operating_log.track_test_case_review')],
['TRACK_TEST_CASE', _this.$t('operating_log.track_test_case')],
['TRACK_REPORT', _this.$t('operating_log.track_report')],
['AUTH_TITLE', _this.$t('operating_log.auth_title')],
['PROJECT_PROJECT_JAR', _this.$t('operating_log.project_project_jar')],
['PROJECT_ENVIRONMENT_SETTING', _this.$t('operating_log.project_environment_setting')],
['PROJECT_PROJECT_MANAGER', _this.$t('operating_log.project_project_manager')],
['PROJECT_FILE_MANAGEMENT', _this.$t('operating_log.project_file_management')],
['PROJECT_PROJECT_MEMBER', _this.$t('operating_log.project_project_member')],
['PERSONAL_INFORMATION_PERSONAL_SETTINGS', _this.$t('operating_log.personal_information_personal_settings')],
['PERSONAL_INFORMATION_APIKEYS', _this.$t('operating_log.personal_information_apikeys')],
['GROUP_PERMISSION', _this.$t('operating_log.group_permission')],
@ -106,22 +108,27 @@ export function SYSLIST() {
value: [i18n.t('permission.project_track_case.name'), 'TRACK_TEST_CASE'],
leaf: true
},
{
label: i18n.t('test_track.review.test_review'),
value: [i18n.t('test_track.review.test_review'), 'TRACK_TEST_CASE_REVIEW'],
leaf: true
},
{
label: i18n.t('test_track.plan.test_plan'),
value: [i18n.t('test_track.plan.test_plan'), 'TRACK_TEST_PLAN'],
leaf: true
},
{
label: i18n.t('test_track.issue.issue_management'),
value: [i18n.t('test_track.issue.issue_management'), 'TRACK_BUG'],
leaf: true
},
{label: i18n.t('commons.report'), value: [i18n.t('commons.report'), 'TRACK_REPORT'], leaf: true}]
{
label: i18n.t('test_track.review.test_review'),
value: [i18n.t('test_track.review.test_review'), 'TRACK_TEST_CASE_REVIEW'],
leaf: true
},
{
label: i18n.t('test_track.plan.test_plan'),
value: [i18n.t('test_track.plan.test_plan'), 'TRACK_TEST_PLAN'],
leaf: true
},
{
label: i18n.t('operating_log.track_test_plan_schedule'),
value: [i18n.t('operating_log.track_test_plan_schedule'), 'TRACK_TEST_PLAN_SCHEDULE'],
leaf: true
},
{
label: i18n.t('test_track.issue.issue_management'),
value: [i18n.t('test_track.issue.issue_management'), 'TRACK_BUG'],
leaf: true
},
{label: i18n.t('commons.report'), value: [i18n.t('commons.report'), 'TRACK_REPORT'], leaf: true}]
},
{
label: i18n.t('commons.api'), value: i18n.t('commons.api'), children: [
@ -130,21 +137,26 @@ export function SYSLIST() {
value: [i18n.t('workstation.table_name.api_definition'), 'API_DEFINITION'],
leaf: true
},
{
label: i18n.t('operating_log.api_definition_case'),
value: [i18n.t('operating_log.api_definition_case'), 'API_DEFINITION_CASE'],
leaf: true
},
{
label: i18n.t('workstation.table_name.api_automation'),
value: [i18n.t('workstation.table_name.api_automation'), 'API_AUTOMATION'],
leaf: true
},
{
label: i18n.t('permission.project_api_report.name'),
value: [i18n.t('permission.project_api_report.name'), 'API_AUTOMATION_REPORT'],
leaf: true
}]
{
label: i18n.t('operating_log.api_definition_case'),
value: [i18n.t('operating_log.api_definition_case'), 'API_DEFINITION_CASE'],
leaf: true
},
{
label: i18n.t('workstation.table_name.api_automation'),
value: [i18n.t('workstation.table_name.api_automation'), 'API_AUTOMATION'],
leaf: true
},
{
label: i18n.t('operating_log.api_automation_schedule'),
value: [i18n.t('operating_log.api_automation_schedule'), 'API_AUTOMATION_SCHEDULE'],
leaf: true
},
{
label: i18n.t('permission.project_api_report.name'),
value: [i18n.t('permission.project_api_report.name'), 'API_AUTOMATION_REPORT'],
leaf: true
}]
},
{
label: i18n.t('workstation.table_name.performance'),
@ -280,6 +292,11 @@ export function WORKSYSLIST() {
value: [i18n.t('test_track.plan.test_plan'), 'TRACK_TEST_PLAN'],
leaf: true
},
{
label: i18n.t('operating_log.track_test_plan_schedule'),
value: [i18n.t('operating_log.track_test_plan_schedule'), 'TRACK_TEST_PLAN_SCHEDULE'],
leaf: true
},
{
label: i18n.t('test_track.issue.issue_management'),
value: [i18n.t('test_track.issue.issue_management'), 'TRACK_BUG'],
@ -304,6 +321,11 @@ export function WORKSYSLIST() {
value: [i18n.t('workstation.table_name.api_automation'), 'API_AUTOMATION'],
leaf: true
},
{
label: i18n.t('operating_log.api_automation_schedule'),
value: [i18n.t('operating_log.api_automation_schedule'), 'API_AUTOMATION_SCHEDULE'],
leaf: true
},
{
label: i18n.t('permission.project_api_report.name'),
value: [i18n.t('permission.project_api_report.name'), 'API_AUTOMATION_REPORT'],

View File

@ -356,6 +356,8 @@ export default {
let param = {};
param = this.schedule;
param.resourceId = this.testId;
param.name = this.paramRow.name;
param.group = this.scheduleTaskType;
// projectId
if (!param.projectId) {
param.projectId = getCurrentProjectID();

@ -1 +1 @@
Subproject commit 1b855b6ac11b593f252b6dd013735372b38d992c
Subproject commit e30c5a16d53a4cc551066b22598e43b2f5d3a6ce

View File

@ -2692,10 +2692,12 @@ export default {
api_definition: "Api definition",
api_definition_case: "Api definition case",
api_automation: "Api automation",
api_automation_schedule: 'Api automation schedule',
api_automation_report: "Test Report",
track_test_case: "Test case",
track_test_case_review: "Case review",
track_test_plan: "Test plan",
track_test_plan_schedule: 'Test plan schedule',
track_bug: "Defect management",
track_report: "Report",
performance_test: "Performance test",

View File

@ -2696,10 +2696,12 @@ export default {
api_definition: "接口定义",
api_definition_case: "接口定义用例",
api_automation: "接口自动化",
api_automation_schedule: "接口自动化-定时任务",
api_automation_report: "测试报告",
track_test_case: "测试用例",
track_test_case_review: "用例评审",
track_test_plan: "测试计划",
track_test_plan_schedule: "测试计划-定时任务",
track_bug: "缺陷管理",
track_report: "报告",
performance_test: "性能测试",

View File

@ -2695,10 +2695,12 @@ export default {
api_definition: "接口定義",
api_definition_case: "接口定義用例",
api_automation: "接口自動化",
api_automation_schedule: '接口自動化-定時任務',
api_automation_report: "測試報告",
track_test_case: "測試用例",
track_test_case_review: "用例評審",
track_test_plan: "測試計劃",
track_test_plan_schedule: "測試計劃-定時任務",
track_bug: "缺陷管理",
track_report: "報告",
performance_test: "性能測試",