From d0ba08317206ced6a731ddc72619fc75f5b6f9fb Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 17 Nov 2023 17:13:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=97=B6=E7=A1=AE=E4=BF=9D=E6=A0=87=E7=AD=BE=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/filemanagement/request/FileUpdateRequest.java | 5 +++-- .../filemanagement/FileManagementControllerTests.java | 6 +++--- .../FileManagementPermissionControllerTests.java | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUpdateRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUpdateRequest.java index bf121ecf1c..6ab94480b8 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUpdateRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUpdateRequest.java @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import lombok.Data; -import java.util.List; +import java.util.LinkedHashSet; @Data public class FileUpdateRequest { @@ -15,8 +15,9 @@ public class FileUpdateRequest { @Schema(description = "文件名称") private String name; + //注: tags内的数据确保不重复且有序。所以使用这个数据结构接受 @Schema(description = "标签") - private List< + private LinkedHashSet< @NotBlank String> tags; 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 6fac75b9cf..5bd5152748 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 @@ -975,7 +975,7 @@ public class FileManagementControllerTests extends BaseTest { FileUpdateRequest updateRequest = new FileUpdateRequest(); updateRequest.setId(updateFileId); updateRequest.setName("update_" + updateFileId); - updateRequest.setTags(new ArrayList<>() {{ + updateRequest.setTags(new LinkedHashSet<>() {{ this.add("tag1"); }}); updateRequest.setDescription("updateDesc_" + updateFileId); @@ -997,7 +997,7 @@ public class FileManagementControllerTests extends BaseTest { oldFileMetadata = fileMetadataMapper.selectByPrimaryKey(updateFileId); updateRequest = new FileUpdateRequest(); updateRequest.setId(updateFileId); - updateRequest.setTags(new ArrayList<>()); + updateRequest.setTags(new LinkedHashSet<>()); this.requestPostWithOk(FileManagementRequestUtils.URL_FILE_UPDATE, updateRequest); this.checkFileInformation(updateFileId, oldFileMetadata, updateRequest); @@ -1013,7 +1013,7 @@ public class FileManagementControllerTests extends BaseTest { oldFileMetadata = fileMetadataMapper.selectByPrimaryKey(updateFileId); updateRequest = new FileUpdateRequest(); updateRequest.setId(updateFileId); - updateRequest.setTags(new ArrayList<>()); + updateRequest.setTags(new LinkedHashSet<>()); this.requestPostWithOk(FileManagementRequestUtils.URL_FILE_UPDATE, updateRequest); this.checkFileInformation(updateFileId, oldFileMetadata, updateRequest); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementPermissionControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementPermissionControllerTests.java index c151a2427b..e589819e2e 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementPermissionControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileManagementPermissionControllerTests.java @@ -21,6 +21,7 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.Objects; @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -121,7 +122,7 @@ public class FileManagementPermissionControllerTests extends BaseTest { FileUpdateRequest updateRequest = new FileUpdateRequest(); updateRequest.setId(TEST_ID); updateRequest.setName("update_" + TEST_ID); - updateRequest.setTags(new ArrayList<>() {{ + updateRequest.setTags(new LinkedHashSet<>() {{ this.add("tag1"); }}); this.requestPostPermissionTest(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_UPDATE, FileManagementRequestUtils.URL_FILE_UPDATE, updateRequest);