fix(项目管理): 修复文件管理没有查询文件标签的缺陷

--bug=1034982 --user=宋天阳 【文件管理】-文件添加标签不生效 https://www.tapd.cn/55049933/s/1457535
This commit is contained in:
song-tianyang 2024-01-31 19:20:00 +08:00 committed by 刘瑞斌
parent bae6ab8b2a
commit 7d336eafc3
8 changed files with 60 additions and 9 deletions

View File

@ -472,6 +472,7 @@ file.log.previous=之前
file.log.upload=上传
file.log.repository.add=添加了存储库文件
file.log.re-upload=重新上传了文件
file.log.upload_file=上传了文件
file.log.pull=拉取了文件
file.log.association=关联了文件
file.log.association.update=更新了关联了文件

View File

@ -507,7 +507,8 @@ file.log.next=next
file.log.previous=behind
file.log.upload=upload
file.log.repository.add=Add repository file
file.log.re-upload=re-upload file
file.log.re-upload=Re-upload file
file.log.upload_file=Upload file
file.log.pull=Pull file
file.log.association=has association file
file.log.association.update=updated file

View File

@ -507,6 +507,7 @@ file.log.previous=之前
file.log.upload=上传
file.log.repository.add=添加了存储库文件
file.log.re-upload=重新上传了文件
file.log.upload_file=上传了文件
file.log.pull=拉取了文件
file.log.association=关联了文件
file.log.association.update=更新了关联了文件

View File

@ -507,6 +507,7 @@ file.log.previous=之前
file.log.upload=上傳
file.log.repository.add=添加了存儲庫文件
file.log.re-upload=重新上傳了文件
file.log.upload_file=上傳了文件
file.log.pull=拉取了文件
file.log.association=關聯了文件
file.log.association.update=更新了關聯了文件

View File

@ -1,9 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.project.mapper.ExtFileMetadataMapper">
<resultMap id="BaseResultMap" type="io.metersphere.project.domain.FileMetadata">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="size" jdbcType="BIGINT" property="size"/>
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
<result column="project_id" jdbcType="VARCHAR" property="projectId"/>
<result column="storage" jdbcType="VARCHAR" property="storage"/>
<result column="create_user" jdbcType="VARCHAR" property="createUser"/>
<result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
<result column="tags" jdbcType="VARCHAR" property="tags" typeHandler="io.metersphere.handler.ListTypeHandler"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="module_id" jdbcType="VARCHAR" property="moduleId"/>
<result column="path" jdbcType="VARCHAR" property="path"/>
<result column="latest" jdbcType="BIT" property="latest"/>
<result column="enable" jdbcType="BIT" property="enable"/>
<result column="ref_id" jdbcType="VARCHAR" property="refId"/>
<result column="file_version" jdbcType="VARCHAR" property="fileVersion"/>
</resultMap>
<select id="selectByKeywordAndFileType"
parameterType="io.metersphere.project.dto.filemanagement.FileManagementQuery"
resultType="io.metersphere.project.domain.FileMetadata">
resultMap="BaseResultMap">
SELECT
f.id,
updateUser.name as updateUser,
@ -142,13 +164,13 @@
WHERE f.project_id = #{projectId}
AND f.storage = #{storage}
</select>
<select id="getById" resultType="io.metersphere.project.domain.FileMetadata">
<select id="getById" resultMap="BaseResultMap">
SELECT f.id,
f.module_id,
f.create_time,
f.update_time,
updateUser.name as updateUser,
createUser.name AS createUser,
updateUser.name as update_user,
createUser.name AS create_user,
f.name,
f.type,
f.tags,

View File

@ -656,7 +656,7 @@ public class FileMetadataService {
FileMetadataRepository fileRepository = fileIdMap.get(item.getId());
if (fileRepository == null) {
fileVersionResponse.setUpdateHistory(Translator.get("file.log.re-upload"));
fileVersionResponse.setUpdateHistory(Translator.get("file.log.upload_file"));
} else {
fileVersionResponse.setUpdateHistory(fileRepository.getCommitMessage());
}

View File

@ -66,7 +66,7 @@ public abstract class ModuleTreeService {
lastSize = traverseList.size();
List<BaseTreeNode> notMatchedList = new ArrayList<>();
for (BaseTreeNode treeNode : traverseList) {
if (!baseTreeNodeMap.containsKey(treeNode.getParentId()) && !StringUtils.equals(treeNode.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
if (!baseTreeNodeMap.containsKey(treeNode.getParentId()) && !StringUtils.equalsIgnoreCase(treeNode.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
notMatchedList.add(treeNode);
continue;
}
@ -127,7 +127,7 @@ public abstract class ModuleTreeService {
sortParam.setOperator(MOVE_POS_OPERATOR_LATEST);
previousNode = selectPosNodeFunc.apply(sortParam);
} else {
if (StringUtils.equals(dropNode.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
if (StringUtils.equalsIgnoreCase(dropNode.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
parentModule = new BaseModule(ModuleConstants.ROOT_NODE_PARENT_ID, ModuleConstants.ROOT_NODE_PARENT_ID, 0, dragNode.getProjectId(), ModuleConstants.ROOT_NODE_PARENT_ID);
} else {
parentModule = selectIdNodeFunc.apply(dropNode.getParentId());

View File

@ -175,10 +175,11 @@ public class FileManagementControllerTests extends BaseTest {
//测试a1无法获取存储库详情
this.requestGet(String.format(FileManagementRequestUtils.URL_FILE_REPOSITORY_INFO, a1Node.getId())).andExpect(status().is5xxServerError());
//根目录下创建节点a2和a3在a1下创建子节点a1-b1
//根目录下创建节点a2和a3在a1下创建子节点a1-b1 parentId设置为小写
request = new FileModuleCreateRequest();
request.setProjectId(project.getId());
request.setName("a2");
request.setParentId("none");
this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_MODULE_ADD, request);
request.setName("a3");
@ -1123,6 +1124,30 @@ public class FileManagementControllerTests extends BaseTest {
LOG_CHECK_LIST.add(
new CheckLogModel(updateRequest.getId(), OperationLogType.UPDATE, FileManagementRequestUtils.URL_FILE_UPDATE)
);
//检查表格里查询到的有没有tag
FileUpdateRequest finalUpdateRequest = updateRequest;
FileMetadataTableRequest request = new FileMetadataTableRequest() {{
this.setCurrent(1);
this.setPageSize(10);
this.setProjectId(project.getId());
this.setKeyword(finalUpdateRequest.getName());
}};
MvcResult pageResult = this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_PAGE, request);
String returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Pager<List<FileInformationResponse>> result = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), Pager.class);
List<FileInformationResponse> fileList = JSON.parseArray(JSON.toJSONString(result.getList()), FileInformationResponse.class);
for (FileInformationResponse response : fileList) {
if (StringUtils.equals(response.getId(), updateRequest.getId())) {
Assertions.assertTrue(response.getTags().contains("tag1"));
}
}
//检查get接口能不能获取到
MvcResult fileTypeResult = this.requestGetWithOkAndReturn(String.format(FileManagementRequestUtils.URL_FILE, updateRequest.getId()));
returnData = fileTypeResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
FileInformationResponse dto = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), FileInformationResponse.class);
Assertions.assertTrue(dto.getTags().contains("tag1"));
//只改描述
oldFileMetadata = fileMetadataMapper.selectByPrimaryKey(updateFileId);