fix(用例管理): 详情添加附件日志
--bug=1036645 --user=王旭 【用例管理】功能用例-用例详情-添加附件-未产生变更历史记录 https://www.tapd.cn/55049933/s/1471401
This commit is contained in:
parent
79c382e536
commit
7384228187
|
@ -1,8 +1,12 @@
|
|||
package io.metersphere.functional.controller;
|
||||
|
||||
import io.metersphere.functional.domain.FunctionalCaseAttachment;
|
||||
import io.metersphere.functional.request.*;
|
||||
import io.metersphere.functional.request.AttachmentTransferRequest;
|
||||
import io.metersphere.functional.request.FunctionalCaseAssociationFileRequest;
|
||||
import io.metersphere.functional.request.FunctionalCaseDeleteFileRequest;
|
||||
import io.metersphere.functional.request.FunctionalCaseFileRequest;
|
||||
import io.metersphere.functional.service.FunctionalCaseAttachmentService;
|
||||
import io.metersphere.functional.service.FunctionalCaseLogService;
|
||||
import io.metersphere.project.dto.filemanagement.FileAssociationDTO;
|
||||
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest;
|
||||
|
@ -15,7 +19,9 @@ import io.metersphere.sdk.exception.MSException;
|
|||
import io.metersphere.sdk.util.FileAssociationSourceUtil;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.security.CheckOwner;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
|
@ -147,6 +153,7 @@ public class FunctionalCaseAttachmentController {
|
|||
@Operation(summary = "用例管理-功能用例-上传文件并关联用例")
|
||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateFunctionalCaseFileLog(#request)", msClass = FunctionalCaseLogService.class)
|
||||
public void uploadFile(@Validated @RequestPart("request") FunctionalCaseAssociationFileRequest request, @RequestPart(value = "file", required = false) MultipartFile file) {
|
||||
String userId = SessionUtils.getUserId();
|
||||
functionalCaseAttachmentService.uploadOrAssociationFile(request, file, userId);
|
||||
|
@ -156,6 +163,7 @@ public class FunctionalCaseAttachmentController {
|
|||
@Operation(summary = "用例管理-功能用例-删除文件并取消关联用例")
|
||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.deleteFunctionalCaseFileLog(#request)", msClass = FunctionalCaseLogService.class)
|
||||
public void deleteFile(@Validated @RequestBody FunctionalCaseDeleteFileRequest request) {
|
||||
String userId = SessionUtils.getUserId();
|
||||
functionalCaseAttachmentService.deleteFile(request, userId);
|
||||
|
|
|
@ -21,7 +21,6 @@ public class FunctionalCaseFileRequest implements Serializable {
|
|||
private String projectId;
|
||||
|
||||
@Schema(description = "用例id",requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{case_review_functional_case.case_id.not_blank}")
|
||||
private String caseId;
|
||||
|
||||
@Schema(description = "文件id",requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
|
|
@ -55,6 +55,55 @@ public class FunctionalCaseLogService {
|
|||
@Resource
|
||||
private BugMapper bugMapper;
|
||||
|
||||
/**
|
||||
* 更新用例 日志
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public LogDTO updateFunctionalCaseFileLog(FunctionalCaseAssociationFileRequest request) {
|
||||
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getCaseId());
|
||||
LogDTO dto = new LogDTO(
|
||||
request.getProjectId(),
|
||||
null,
|
||||
request.getCaseId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.CASE_MANAGEMENT_CASE_UPDATE,
|
||||
historyLogDTO.getFunctionalCase().getName());
|
||||
dto.setHistory(true);
|
||||
dto.setPath("/attachment/upload/file");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request));
|
||||
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新用例 日志
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public LogDTO deleteFunctionalCaseFileLog(FunctionalCaseDeleteFileRequest request) {
|
||||
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getCaseId());
|
||||
LogDTO dto = new LogDTO(
|
||||
request.getProjectId(),
|
||||
null,
|
||||
request.getCaseId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.CASE_MANAGEMENT_CASE_UPDATE,
|
||||
historyLogDTO.getFunctionalCase().getName());
|
||||
dto.setHistory(true);
|
||||
dto.setPath("/attachment/delete/file");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request));
|
||||
dto.setOriginalValue(JSON.toJSONBytes(historyLogDTO));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新用例 日志
|
||||
|
|
Loading…
Reference in New Issue