fix(任务中心): 修复删除接口定时任务,日志错误问题
--bug=1048117 --user=王旭 【接口测试】定义-导入接口-定时导入-定时任务列表-删除定时任务,查看日志,操作对象错误 https://www.tapd.cn/55049933/s/1598997
This commit is contained in:
parent
bdc539a4a1
commit
6dc3614ec1
|
@ -3,7 +3,9 @@ package io.metersphere.api.controller.definition;
|
|||
import io.metersphere.api.dto.definition.ApiScheduleDTO;
|
||||
import io.metersphere.api.dto.definition.request.ApiScheduleRequest;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionScheduleService;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.security.CheckOwner;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.validation.groups.Created;
|
||||
|
@ -51,7 +53,7 @@ public class ApiDefinitionScheduleController {
|
|||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_IMPORT)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "schedule")
|
||||
public void deleteSchedule(@PathVariable String id) {
|
||||
apiDefinitionScheduleService.deleteSchedule(id);
|
||||
apiDefinitionScheduleService.deleteSchedule(id, SessionUtils.getUserId(), "/api/definition/schedule/delete/", HttpMethodConstants.GET.name(), OperationLogModule.API_TEST_MANAGEMENT_DEFINITION);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get/{id}")
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -182,10 +183,27 @@ public class ApiDefinitionScheduleService {
|
|||
SwaggerUrlImportJob.getTriggerKey(schedule.getResourceId()), SwaggerUrlImportJob.class);
|
||||
}
|
||||
|
||||
public void deleteSchedule(String id) {
|
||||
public void deleteSchedule(String id, String userId, String path, String method, String module) {
|
||||
Schedule schedule = checkScheduleExit(id);
|
||||
apiDefinitionSwaggerMapper.deleteByPrimaryKey(schedule.getResourceId());
|
||||
scheduleService.deleteByResourceId(schedule.getResourceId(), SwaggerUrlImportJob.class.getName());
|
||||
saveLog(schedule, userId, path, method, module, OperationLogType.DELETE.name());
|
||||
}
|
||||
|
||||
private void saveLog(Schedule schedule, String userId, String path, String method, String module, String type) {
|
||||
Optional.ofNullable(schedule).ifPresent(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
item.getProjectId(),
|
||||
projectMapper.selectByPrimaryKey(item.getProjectId()).getOrganizationId(),
|
||||
item.getResourceId(),
|
||||
userId,
|
||||
type,
|
||||
module,
|
||||
Translator.get("api_import_schedule") + ": " + item.getName());
|
||||
dto.setPath(path);
|
||||
dto.setMethod(method);
|
||||
operationLogService.add(dto);
|
||||
});
|
||||
}
|
||||
|
||||
private Schedule checkScheduleExit(String id) {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<ms-base-table v-bind="propsRes" no-disable v-on="propsEvent">
|
||||
<template #status="{ record }">
|
||||
<a-switch
|
||||
v-model:modelValue="record.enable"
|
||||
v-model:model-value="record.enable"
|
||||
type="line"
|
||||
size="small"
|
||||
:before-change="() => handleBeforeEnableChange(record)"
|
||||
|
@ -39,7 +39,7 @@
|
|||
import { MsTableColumn } from '@/components/pure/ms-table/type';
|
||||
import useTable from '@/components/pure/ms-table/useTable';
|
||||
|
||||
import { switchDefinitionSchedule } from '@/api/modules/api-test/management';
|
||||
import { deleteDefinitionSchedule, switchDefinitionSchedule } from '@/api/modules/api-test/management';
|
||||
import { getScheduleProApiCaseList, projectDeleteSchedule } from '@/api/modules/taskCenter/project';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import useModal from '@/hooks/useModal';
|
||||
|
@ -175,7 +175,7 @@
|
|||
maskClosable: false,
|
||||
onBeforeOk: async () => {
|
||||
try {
|
||||
await projectDeleteSchedule(record.id);
|
||||
await deleteDefinitionSchedule(record.id);
|
||||
Message.success(t('common.deleteSuccess'));
|
||||
loadTaskList();
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue