feat(文件管理): 调用文件修改接口时确保标签不会重复

This commit is contained in:
song-tianyang 2023-11-17 17:13:45 +08:00 committed by 刘瑞斌
parent 8dcef99e4d
commit d0ba083172
3 changed files with 8 additions and 6 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);