refactor(项目管理): 优化文件管理页面的表格批量处理参数

This commit is contained in:
song-tianyang 2023-09-25 10:14:01 +08:00 committed by 刘瑞斌
parent 1f3245fbcb
commit 766ef37320
2 changed files with 4 additions and 20 deletions

View File

@ -1,38 +1,22 @@
package io.metersphere.project.request.filemanagement; package io.metersphere.project.request.filemanagement;
import io.metersphere.sdk.dto.TableBatchProcessDTO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
public class FileBatchProcessDTO { public class FileBatchProcessDTO extends TableBatchProcessDTO {
@Schema(description = "不处理的ID")
List<String> excludeIds;
@Schema(description = "项目ID") @Schema(description = "项目ID")
@NotBlank(message = "{id must not be blank}") @NotBlank(message = "{id must not be blank}")
private String projectId; private String projectId;
@Schema(description = "选择的ID", requiredMode = Schema.RequiredMode.REQUIRED)
@Valid
private List<
@NotBlank(message = "{id must not be blank}")
String
> selectIds = new ArrayList<>();
@Schema(description = "是否选择所有数据")
private boolean selectAll;
@Schema(description = "文件类型") @Schema(description = "文件类型")
private List<String> fileTypes; private List<String> fileTypes;
@Schema(description = "关键字")
private String keyword;
@Schema(description = "模块ID") @Schema(description = "模块ID")
private List<String> moduleIds; private List<String> moduleIds;
} }

View File

@ -77,7 +77,7 @@ public class FileManagementService {
List<String> processIds = request.getSelectIds(); List<String> processIds = request.getSelectIds();
List<FileMetadata> refFileList = new ArrayList<>(); List<FileMetadata> refFileList = new ArrayList<>();
if (request.isSelectAll()) { if (request.isSelectAll()) {
refFileList = extFileMetadataMapper.selectByKeywordAndFileType(request.getProjectId(), request.getKeyword(), request.getModuleIds(), request.getFileTypes(), true); refFileList = extFileMetadataMapper.selectByKeywordAndFileType(request.getProjectId(), request.getCondition().getKeyword(), request.getModuleIds(), request.getFileTypes(), true);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) { if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
refFileList = refFileList.stream().filter(fileMetadata -> !request.getExcludeIds().contains(fileMetadata.getId())).collect(Collectors.toList()); refFileList = refFileList.stream().filter(fileMetadata -> !request.getExcludeIds().contains(fileMetadata.getId())).collect(Collectors.toList());
} }
@ -98,7 +98,7 @@ public class FileManagementService {
List<String> processIds = request.getSelectIds(); List<String> processIds = request.getSelectIds();
List<FileMetadata> refFileList = new ArrayList<>(); List<FileMetadata> refFileList = new ArrayList<>();
if (request.isSelectAll()) { if (request.isSelectAll()) {
refFileList = extFileMetadataMapper.selectByKeywordAndFileType(request.getProjectId(), request.getKeyword(), request.getModuleIds(), request.getFileTypes(), false); refFileList = extFileMetadataMapper.selectByKeywordAndFileType(request.getProjectId(), request.getCondition().getKeyword(), request.getModuleIds(), request.getFileTypes(), false);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) { if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
refFileList = refFileList.stream().filter(fileMetadata -> !request.getExcludeIds().contains(fileMetadata.getId())).collect(Collectors.toList()); refFileList = refFileList.stream().filter(fileMetadata -> !request.getExcludeIds().contains(fileMetadata.getId())).collect(Collectors.toList());
} }