fix(测试用例): 修复用例导出未生成日志问题
--bug=1045099 --user=王旭 【测试用例】用例导出为xmind/excel-未生成系统日志 https://www.tapd.cn/55049933/s/1562443
This commit is contained in:
parent
ccdd19d521
commit
a52a69a99e
|
@ -237,7 +237,7 @@ public class FunctionalCaseController {
|
|||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public FunctionalCaseImportResponse preCheckXMind(@RequestPart("request") FunctionalCaseImportRequest request, @RequestPart(value = "file", required = false) MultipartFile file) {
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
return functionalCaseFileService.preCheckXMind(request,user, file);
|
||||
return functionalCaseFileService.preCheckXMind(request, user, file);
|
||||
}
|
||||
|
||||
|
||||
|
@ -274,7 +274,7 @@ public class FunctionalCaseController {
|
|||
@Operation(summary = "用例管理-功能用例-excel导出")
|
||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_EXPORT)
|
||||
public String testCaseExport(@Validated @RequestBody FunctionalCaseExportRequest request) {
|
||||
return functionalCaseFileService.export(SessionUtils.getUserId(), request);
|
||||
return functionalCaseFileService.export(SessionUtils.getUserId(), request, SessionUtils.getCurrentOrganizationId());
|
||||
}
|
||||
|
||||
@GetMapping("/stop/{taskId}")
|
||||
|
@ -314,7 +314,7 @@ public class FunctionalCaseController {
|
|||
@Operation(summary = "用例管理-功能用例-xmind导出")
|
||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_EXPORT)
|
||||
public String caseExportXmind(@Validated @RequestBody FunctionalCaseExportRequest request) {
|
||||
return functionalCaseXmindService.exportFunctionalCaseXmind(request, SessionUtils.getUserId());
|
||||
return functionalCaseXmindService.exportFunctionalCaseXmind(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId());
|
||||
}
|
||||
|
||||
@GetMapping(value = "/check/export-task")
|
||||
|
|
|
@ -48,6 +48,8 @@ import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
|||
import io.metersphere.system.dto.sdk.TemplateDTO;
|
||||
import io.metersphere.system.excel.domain.ExcelErrData;
|
||||
import io.metersphere.system.excel.utils.EasyExcelExporter;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import io.metersphere.system.manager.ExportTaskManager;
|
||||
import io.metersphere.system.mapper.SystemParameterMapper;
|
||||
import io.metersphere.system.service.FileService;
|
||||
|
@ -111,6 +113,8 @@ public class FunctionalCaseFileService {
|
|||
private ExportTaskMapper exportTaskMapper;
|
||||
private static final String XLSX = "xlsx";
|
||||
private static final String ZIP = "zip";
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
/**
|
||||
* 下载excel导入模板
|
||||
|
@ -403,10 +407,10 @@ public class FunctionalCaseFileService {
|
|||
}
|
||||
}
|
||||
|
||||
public String export(String userId, FunctionalCaseExportRequest request) {
|
||||
public String export(String userId, FunctionalCaseExportRequest request, String orgId) {
|
||||
try {
|
||||
exportCheck(request, userId);
|
||||
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportFunctionalCaseZip(request, userId));
|
||||
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportFunctionalCaseZip(request, userId, orgId));
|
||||
return exportTask.getId();
|
||||
} catch (InterruptedException e) {
|
||||
LogUtils.error("导出失败:" + e);
|
||||
|
@ -427,7 +431,7 @@ public class FunctionalCaseFileService {
|
|||
*
|
||||
* @param request
|
||||
*/
|
||||
public String exportFunctionalCaseZip(FunctionalCaseExportRequest request, String userId) {
|
||||
public String exportFunctionalCaseZip(FunctionalCaseExportRequest request, String userId, String orgId) {
|
||||
File tmpDir = null;
|
||||
String fileType = "";
|
||||
try {
|
||||
|
@ -454,7 +458,8 @@ public class FunctionalCaseFileService {
|
|||
fileType = XLSX;
|
||||
uploadFileToMinio(fileType, singeFile, request.getFileId());
|
||||
}
|
||||
functionalCaseLogService.exportExcelLog(request);
|
||||
LogDTO logDTO = functionalCaseLogService.exportExcelLog(request, "excel", userId, orgId);
|
||||
operationLogService.add(logDTO);
|
||||
List<ExportTask> exportTasks = getExportTasks(request.getProjectId(), userId);
|
||||
String taskId;
|
||||
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import io.metersphere.sdk.util.JSON;
|
|||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -180,7 +179,7 @@ public class FunctionalCaseLogService {
|
|||
}
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 恢复项目
|
||||
*
|
||||
|
@ -429,18 +428,17 @@ public class FunctionalCaseLogService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public LogDTO exportExcelLog(FunctionalCaseExportRequest request) {
|
||||
public LogDTO exportExcelLog(FunctionalCaseExportRequest request, String url, String userId, String orgId) {
|
||||
LogDTO dto = new LogDTO(
|
||||
request.getProjectId(),
|
||||
null,
|
||||
orgId,
|
||||
request.getFileId(),
|
||||
null,
|
||||
userId,
|
||||
OperationLogType.EXPORT.name(),
|
||||
OperationLogModule.FUNCTIONAL_CASE,
|
||||
"");
|
||||
dto.setHistory(true);
|
||||
dto.setPath("/functional/case/export/excel");
|
||||
dto.setPath("/functional/case/export/" + url);
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
return dto;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import io.metersphere.sdk.util.Translator;
|
|||
import io.metersphere.system.constants.ExportConstants;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import io.metersphere.system.manager.ExportTaskManager;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -61,6 +63,8 @@ public class FunctionalCaseXmindService {
|
|||
@Resource
|
||||
private FunctionalCaseLogService functionalCaseLogService;
|
||||
private static final String XMIND = "xmind";
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
public void downloadXmindTemplate(String projectId, HttpServletResponse response) {
|
||||
List<TemplateCustomFieldDTO> customFields = functionalCaseFileService.getCustomFields(projectId);
|
||||
|
@ -96,10 +100,10 @@ public class FunctionalCaseXmindService {
|
|||
*
|
||||
* @param request
|
||||
*/
|
||||
public String exportFunctionalCaseXmind(FunctionalCaseExportRequest request, String userId) {
|
||||
public String exportFunctionalCaseXmind(FunctionalCaseExportRequest request, String userId, String orgId) {
|
||||
try {
|
||||
functionalCaseFileService.exportCheck(request, userId);
|
||||
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportXmind(request, userId));
|
||||
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportXmind(request, userId, orgId));
|
||||
return exportTask.getId();
|
||||
} catch (InterruptedException e) {
|
||||
LogUtils.error("导出失败:" + e);
|
||||
|
@ -108,7 +112,7 @@ public class FunctionalCaseXmindService {
|
|||
|
||||
}
|
||||
|
||||
private String exportXmind(FunctionalCaseExportRequest request, String userId) {
|
||||
private String exportXmind(FunctionalCaseExportRequest request, String userId, String orgId) {
|
||||
//获取导出的ids集合
|
||||
List<String> ids = functionalCaseService.doSelectIds(request, request.getProjectId());
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
|
@ -128,7 +132,8 @@ public class FunctionalCaseXmindService {
|
|||
XmindExportUtil.export(xmindData, request, tmpFile, templateCustomFields);
|
||||
functionalCaseFileService.uploadFileToMinio(XMIND, tmpFile, request.getFileId());
|
||||
|
||||
functionalCaseLogService.exportExcelLog(request);
|
||||
LogDTO logDTO = functionalCaseLogService.exportExcelLog(request, "xmind", userId, orgId);
|
||||
operationLogService.add(logDTO);
|
||||
List<ExportTask> exportTasks = functionalCaseFileService.getExportTasks(request.getProjectId(), userId);
|
||||
String taskId;
|
||||
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
||||
|
|
Loading…
Reference in New Issue