From 7d336eafc3a5bdcc4d677c677e35389c78638dfd Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 31 Jan 2024 19:20:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=9F=A5=E8=AF=A2=E6=96=87=E4=BB=B6=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1034982 --user=宋天阳 【文件管理】-文件添加标签不生效 https://www.tapd.cn/55049933/s/1457535 --- .../main/resources/i18n/project.properties | 1 + .../resources/i18n/project_en_US.properties | 3 +- .../resources/i18n/project_zh_CN.properties | 1 + .../resources/i18n/project_zh_TW.properties | 1 + .../project/mapper/ExtFileMetadataMapper.xml | 30 ++++++++++++++++--- .../project/service/FileMetadataService.java | 2 +- .../project/service/ModuleTreeService.java | 4 +-- .../FileManagementControllerTests.java | 27 ++++++++++++++++- 8 files changed, 60 insertions(+), 9 deletions(-) diff --git a/backend/framework/sdk/src/main/resources/i18n/project.properties b/backend/framework/sdk/src/main/resources/i18n/project.properties index d457e11f00..34b7e3756e 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project.properties @@ -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=更新了关联了文件 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties index 6a77155ed7..b6d057e6ac 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties @@ -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 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties index c204c3cd1d..93815eb8cf 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties @@ -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=更新了关联了文件 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties index c2a8b75f44..10b306c482 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties @@ -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=更新了關聯了文件 diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml index 8b1d5ad666..333fcb9a04 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml +++ b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.xml @@ -1,9 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + - 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, diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java index 58bb016af5..809389e6e9 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java @@ -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()); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java index 9494f90214..7b6f590834 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java @@ -66,7 +66,7 @@ public abstract class ModuleTreeService { lastSize = traverseList.size(); List 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()); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementControllerTests.java index 376d7d3e1c..4851d38c72 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementControllerTests.java @@ -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> result = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), Pager.class); + List 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);