fix(测试跟踪): 关联附件未记录日志问题及左侧模块树拖动问题

--bug=1024041 --user=宋昌昌 【测试跟踪】变更记录,关联附件操作,没有变更记录 https://www.tapd.cn/55049933/s/1346960
This commit is contained in:
song-cc-rock 2023-03-08 15:37:25 +08:00 committed by jianxing
parent 04372f4848
commit d1ec4175e7
4 changed files with 130 additions and 17 deletions

View File

@ -38,7 +38,7 @@
</span>
<el-tooltip class="item" effect="dark" :content="data.name" placement="top-start" :open-delay="1000">
<span v-if="!data.isEdit" class="node-title" v-text="isDefault(data) ? showBySubStr(getLocalDefaultName()) : showBySubStr(data.name)" :case-num="getCaseNum(data)"/>
<span v-if="!data.isEdit" class="node-title" v-text="isDefault(data) ? getLocalDefaultName() : data.name" :case-num="getCaseNum(data)"/>
</el-tooltip>
<span v-if="!disabled" class="node-operate child">
@ -128,7 +128,7 @@
</span>
<el-tooltip class="item" effect="dark" :content="data.name" placement="top-start" :open-delay="1000">
<span v-if="!data.isEdit" class="node-title" v-text="isDefault(data) ? showBySubStr(getLocalDefaultName()) : showBySubStr(data.name)" :case-num="getCaseNum(data)"/>
<span v-if="!data.isEdit" class="node-title" v-text="isDefault(data) ? getLocalDefaultName() : data.name" :case-num="getCaseNum(data)"/>
</el-tooltip>
@ -193,7 +193,6 @@
<script>
import MsLeft2RightContainer from "../MsLeft2RightContainer";
import { Message } from 'element-ui';
export default {
name: "MsNodeTree",
@ -652,13 +651,6 @@ export default {
return this.$t('commons.module_title');
}
},
showBySubStr(text) {
if (text.toString().length > 7) {
return text.toString().substring(0, 7) + "...";
} else {
return text.toString();
}
},
getCaseNum(data) {
if (this.showCaseNum && data.caseNum) {
return " (" + data.caseNum + ")";
@ -712,11 +704,11 @@ export default {
}
.node-title {
width: 0px;
width: 0;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1 1 auto;
padding: 0px 9px;
padding: 0 9px;
overflow: hidden;
font-family: 'PingFang SC';
font-style: normal;
@ -744,7 +736,7 @@ export default {
.node-operate > i {
color: #409eff;
margin: 0px 5px;
margin: 0 5px;
}
.name-input {
@ -766,6 +758,10 @@ export default {
color: transparent;
}
.el-tree-node__content > .el-tree-node__expand-icon {
padding: 9px 6px 6px 6px;
}
:deep(.el-tree-node__content) {
width: auto;
height: 40px;
@ -808,8 +804,8 @@ export default {
.drag {
position: relative;
left: -38px;
top: 2px;
left: -40px;
top: 0;
width: 0;
}
@ -857,7 +853,7 @@ export default {
.module-more-operate {
margin-left: 10px;
margin-top: 0px;
margin-top: 0;
}
.search-input {

View File

@ -73,11 +73,13 @@ public class AttachmentController {
}
@PostMapping("/metadata/relate")
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, title = "#request.belongType", content = "#msClass.getLogDetails(#request.belongId, #request.belongType, #request.metadataRefIds, true)", msClass = AttachmentService.class)
public void relate(@RequestBody AttachmentRequest request) {
attachmentService.relate(request);
}
@PostMapping("/metadata/unrelated")
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, title = "#request.belongType", beforeEvent = "#msClass.getLogDetails(#request.belongId, #request.belongType, #request.metadataRefIds)", msClass = AttachmentService.class)
public void unrelated(@RequestBody AttachmentRequest request) {
attachmentService.unrelated(request);
}

View File

@ -642,6 +642,13 @@ public class AttachmentService {
return JSON.toJSONString(details);
}
/**
* 删除文件操作记录
*
* @param attachmentId
* @param attachmentType
* @return
*/
public String getLogDetails(String attachmentId, String attachmentType) {
FileAttachmentMetadata fileAttachmentMetadata = fileAttachmentMetadataMapper.selectByPrimaryKey(attachmentId);
if (fileAttachmentMetadata == null) {
@ -658,4 +665,112 @@ public class AttachmentService {
return this.getLogDetails(relationId, attachmentType, fileName, true);
}
/**
* 关联文件的操作记录
*
* @param sourceId
* @param type
* @param refIds 关联或取消关联的文件ID
* @return
*/
public String getLogDetails(String sourceId, String type, List refIds, Boolean isRelate) {
String projectId = null;
String createUser = null;
if (StringUtils.isBlank(sourceId) || StringUtils.isBlank(type) || CollectionUtils.isEmpty(refIds)) {
return null;
}
if (AttachmentType.ISSUE.type().equals(type)) {
IssuesWithBLOBs issues = issuesMapper.selectByPrimaryKey(sourceId);
if (issues == null) {
return null;
}
projectId = issues.getProjectId();
createUser = issues.getCreator();
} else if (AttachmentType.TEST_CASE.type().equals(type)) {
TestCaseWithBLOBs testCase = testCaseMapper.selectByPrimaryKey(sourceId);
if (testCase == null) {
return null;
}
projectId = testCase.getProjectId();
createUser = testCase.getCreateUser();
}
AttachmentRequest attachmentRequest = new AttachmentRequest();
attachmentRequest.setBelongId(sourceId);
attachmentRequest.setBelongType(type);
List<FileAttachmentMetadata> originFiles = listMetadata(attachmentRequest);
List<String> fileNames = new LinkedList<>();
if (CollectionUtils.isNotEmpty(originFiles)) {
fileNames = originFiles.stream().map(FileAttachmentMetadata::getName).collect(Collectors.toList());
}
String after;
String before;
FileMetadataExample example = new FileMetadataExample();
example.createCriteria().andIdIn(refIds);
List<FileMetadata> fileMetadata = fileMetadataMapper.selectByExample(example);
List<String> refNames = fileMetadata.stream().map(FileMetadata::getName).collect(Collectors.toList());
after = String.join(",", fileNames);
List<String> unRelateFiles = fileNames.stream().filter(filename -> !refNames.contains(filename)).collect(Collectors.toList());
before = String.join(",", unRelateFiles);
List<DetailColumn> columns = new ArrayList<>();
DetailColumn column = new DetailColumn("附件", "files", before, after);
columns.add(column);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(sourceId), projectId, createUser, columns);
return JSON.toJSONString(details);
}
/**
* 取消关联文件的操作记录
*
* @param sourceId
* @param type
* @param refIds 关联或取消关联的文件ID
* @return
*/
public String getLogDetails(String sourceId, String type, List refIds) {
String projectId = null;
String createUser = null;
if (StringUtils.isBlank(sourceId) || StringUtils.isBlank(type) || CollectionUtils.isEmpty(refIds)) {
return null;
}
if (AttachmentType.ISSUE.type().equals(type)) {
IssuesWithBLOBs issues = issuesMapper.selectByPrimaryKey(sourceId);
if (issues == null) {
return null;
}
projectId = issues.getProjectId();
createUser = issues.getCreator();
} else if (AttachmentType.TEST_CASE.type().equals(type)) {
TestCaseWithBLOBs testCase = testCaseMapper.selectByPrimaryKey(sourceId);
if (testCase == null) {
return null;
}
projectId = testCase.getProjectId();
createUser = testCase.getCreateUser();
}
AttachmentRequest attachmentRequest = new AttachmentRequest();
attachmentRequest.setBelongId(sourceId);
attachmentRequest.setBelongType(type);
List<FileAttachmentMetadata> originFiles = listMetadata(attachmentRequest);
List<String> fileNames = new LinkedList<>();
if (CollectionUtils.isNotEmpty(originFiles)) {
fileNames = originFiles.stream().map(FileAttachmentMetadata::getName).collect(Collectors.toList());
}
String after;
String before;
before = String.join(",", fileNames);
List<String> unRelateFiles = originFiles.stream().filter(originFile -> !StringUtils.equals(originFile.getId(), refIds.get(0).toString()))
.map(FileAttachmentMetadata::getName).collect(Collectors.toList());
after = String.join(",", unRelateFiles);
List<DetailColumn> columns = new ArrayList<>();
DetailColumn column = new DetailColumn("附件", "files", before, after);
columns.add(column);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(sourceId), projectId, createUser, columns);
return JSON.toJSONString(details);
}
}

View File

@ -14,7 +14,7 @@
:auto-save="!readOnly"
trigger="hover"
:contentObject="{
content: isCustomNum ? form.customNum : form.num,
content: isCustomNum ? form.customNum.toString() : form.num.toString(),
contentType: 'INPUT',
}"
:readonlyHoverEvent="!readOnly"