From 45cdc8cc3689054e5a8da27b1f01a4ebb4446bb6 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 1 Nov 2023 15:01:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=BA=93=E6=9F=A5=E8=AF=A2=E5=92=8C=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=BA=93=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sdk/constants/ModuleConstants.java | 2 + .../functional/utils/FileBaseUtils.java | 8 +- .../controller/FileManagementController.java | 25 +-- .../controller/FileModuleController.java | 4 +- .../controller/FilePreviewController.java | 14 +- .../controller/FileRepositoryController.java | 43 +++++ .../filemanagement/FileManagementPageDTO.java | 39 ----- .../filemanagement/FileManagementQuery.java | 51 ++++++ .../request}/FileBatchMoveRequest.java | 2 +- .../request}/FileBatchProcessRequest.java | 3 +- .../request}/FileMetadataTableRequest.java | 2 +- .../request}/FileModuleCreateRequest.java | 2 +- .../request}/FileModuleUpdateRequest.java | 2 +- .../request}/FileReUploadRequest.java | 2 +- .../request}/FileUpdateRequest.java | 2 +- .../request}/FileUploadRequest.java | 2 +- .../FileInformationResponse.java} | 6 +- .../project/mapper/ExtFileMetadataMapper.java | 12 +- .../project/mapper/ExtFileMetadataMapper.xml | 12 +- .../project/mapper/ExtFileModuleMapper.java | 2 +- .../project/mapper/ExtFileModuleMapper.xml | 3 +- .../service/FileManagementService.java | 8 +- .../project/service/FileMetadataService.java | 36 ++--- .../project/service/FileModuleService.java | 27 ++-- .../service/FileRepositoryService.java | 30 ++++ .../project/service/ModuleTreeService.java | 14 ++ .../FileManagementControllerTests.java | 33 ++-- ...leManagementPermissionControllerTests.java | 2 +- .../FileRepositoryControllerTest.java | 148 ++++++++++++++++++ .../utils/FileManagementBaseUtils.java | 11 +- .../utils/FileManagementRequestUtils.java | 8 + 31 files changed, 400 insertions(+), 155 deletions(-) create mode 100644 backend/services/project-management/src/main/java/io/metersphere/project/controller/FileRepositoryController.java delete mode 100644 backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementPageDTO.java create mode 100644 backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementQuery.java rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileBatchMoveRequest.java (85%) rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileBatchProcessRequest.java (90%) rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileMetadataTableRequest.java (91%) rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileModuleCreateRequest.java (93%) rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileModuleUpdateRequest.java (90%) rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileReUploadRequest.java (82%) rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileUpdateRequest.java (92%) rename backend/services/project-management/src/main/java/io/metersphere/project/{request/filemanagement => dto/filemanagement/request}/FileUploadRequest.java (89%) rename backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/{FileInformationDTO.java => response/FileInformationResponse.java} (93%) create mode 100644 backend/services/project-management/src/main/java/io/metersphere/project/service/FileRepositoryService.java create mode 100644 backend/services/project-management/src/test/java/io/metersphere/project/controller/filemanagement/FileRepositoryControllerTest.java diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ModuleConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ModuleConstants.java index a6b6dc4236..e23c9fb247 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ModuleConstants.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ModuleConstants.java @@ -7,6 +7,8 @@ public class ModuleConstants { public static final String ROOT_NODE_PARENT_ID = "none"; //默认节点类型 public static final String NODE_TYPE_DEFAULT = "module"; + //Git节点类型 + public static final String NODE_TYPE_GIT = "git"; //GitHub节点类型 public static final String NODE_TYPE_GITHUB = "GitHub"; //Gitee节点类型 diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/utils/FileBaseUtils.java b/backend/services/case-management/src/test/java/io/metersphere/functional/utils/FileBaseUtils.java index 40f3f347f3..78dff553c1 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/utils/FileBaseUtils.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/utils/FileBaseUtils.java @@ -1,9 +1,9 @@ package io.metersphere.functional.utils; -import io.metersphere.project.dto.filemanagement.FileInformationDTO; -import io.metersphere.project.request.filemanagement.FileMetadataTableRequest; -import io.metersphere.system.dto.sdk.BaseTreeNode; +import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest; +import io.metersphere.project.dto.filemanagement.response.FileInformationResponse; import io.metersphere.sdk.util.JSON; +import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.utils.Pager; import org.apache.commons.collections4.CollectionUtils; import org.junit.jupiter.api.Assertions; @@ -96,7 +96,7 @@ public class FileBaseUtils { } } - public static void checkFilePage(Pager> tableData, Map moduleCount, FileMetadataTableRequest request, boolean hasData) { + public static void checkFilePage(Pager> tableData, Map moduleCount, FileMetadataTableRequest request, boolean hasData) { //返回值的页码和当前页码相同 Assertions.assertEquals(tableData.getCurrent(), request.getCurrent()); //返回的数据量不超过规定要返回的数据量相同 diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileManagementController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileManagementController.java index dd947aeeaf..c3c2110bde 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileManagementController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileManagementController.java @@ -1,12 +1,11 @@ package io.metersphere.project.controller; -import io.metersphere.project.dto.filemanagement.FileInformationDTO; -import io.metersphere.project.request.filemanagement.*; +import io.metersphere.project.dto.filemanagement.request.*; +import io.metersphere.project.dto.filemanagement.response.FileInformationResponse; import io.metersphere.project.service.FileManagementService; import io.metersphere.project.service.FileMetadataService; import io.metersphere.sdk.constants.PermissionConstants; -import io.metersphere.sdk.exception.MSException; -import io.metersphere.sdk.util.Translator; +import io.metersphere.sdk.constants.StorageType; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; @@ -35,20 +34,20 @@ public class FileManagementController { @Operation(summary = "项目管理-文件管理-获取已存在的文件类型") @RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ) public List getFileType(@PathVariable String projectId) { - return fileMetadataService.getFileType(projectId); + return fileMetadataService.getFileType(projectId, StorageType.MINIO.name()); } @PostMapping("/page") @Operation(summary = "项目管理-文件管理-表格分页查询文件") @RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ) - public Pager> page(@Validated @RequestBody FileMetadataTableRequest request) { + public Pager> page(@Validated @RequestBody FileMetadataTableRequest request) { return fileMetadataService.page(request); } @GetMapping("/get/{id}") @Operation(summary = "项目管理-文件管理-查看文件详情") @RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ) - public FileInformationDTO page(@PathVariable String id) { + public FileInformationResponse page(@PathVariable String id) { return fileMetadataService.get(id); } @@ -63,23 +62,15 @@ public class FileManagementController { @PostMapping("/upload") @Operation(summary = "项目管理-文件管理-上传文件") @RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_ADD) - public String upload(@Validated @RequestPart("request") FileUploadRequest request, @RequestPart(value = "file", required = false) MultipartFile uploadFile) { - try { + public String upload(@Validated @RequestPart("request") FileUploadRequest request, @RequestPart(value = "file", required = false) MultipartFile uploadFile) throws Exception { return fileMetadataService.upload(request, SessionUtils.getUserId(), uploadFile); - } catch (Exception e) { - throw new MSException(Translator.get("upload.file.error"), e); - } } @PostMapping("/re-upload") @Operation(summary = "项目管理-文件管理-重新上传文件") @RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_UPDATE) - public String reUpload(@Validated @RequestPart("request") FileReUploadRequest request, @RequestPart(value = "file", required = false) MultipartFile uploadFile) { - try { + public String reUpload(@Validated @RequestPart("request") FileReUploadRequest request, @RequestPart(value = "file", required = false) MultipartFile uploadFile) throws Exception { return fileMetadataService.reUpload(request, SessionUtils.getUserId(), uploadFile); - } catch (Exception e) { - throw new MSException(Translator.get("upload.file.error"), e); - } } @GetMapping(value = "/download/{id}") diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileModuleController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileModuleController.java index 378f5180a8..4bb33b6739 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileModuleController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileModuleController.java @@ -1,7 +1,7 @@ package io.metersphere.project.controller; -import io.metersphere.project.request.filemanagement.FileModuleCreateRequest; -import io.metersphere.project.request.filemanagement.FileModuleUpdateRequest; +import io.metersphere.project.dto.filemanagement.request.FileModuleCreateRequest; +import io.metersphere.project.dto.filemanagement.request.FileModuleUpdateRequest; import io.metersphere.project.service.FileModuleService; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.system.dto.sdk.BaseTreeNode; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/FilePreviewController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FilePreviewController.java index d2095c70f3..6d674f894a 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/FilePreviewController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FilePreviewController.java @@ -1,6 +1,6 @@ package io.metersphere.project.controller; -import io.metersphere.project.dto.filemanagement.FileInformationDTO; +import io.metersphere.project.dto.filemanagement.response.FileInformationResponse; import io.metersphere.project.service.FileMetadataService; import io.metersphere.project.service.PermissionCheckService; import io.metersphere.sdk.constants.PermissionConstants; @@ -29,12 +29,12 @@ public class FilePreviewController { @GetMapping(value = "/original/{userId}/{fileId}") @Operation(summary = "预览原图") public ResponseEntity originalImg(@PathVariable String userId,@PathVariable String fileId) { - FileInformationDTO fileInformationDTO = fileMetadataService.get(fileId); - if (StringUtils.isEmpty(fileInformationDTO.getId())) { + FileInformationResponse fileInformationResponse = fileMetadataService.get(fileId); + if (StringUtils.isEmpty(fileInformationResponse.getId())) { throw new MSException("file.not.exist"); } //检查权限 - if(permissionCheckService.userHasProjectPermission(userId,fileInformationDTO.getProjectId(),PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_DOWNLOAD)){ + if (permissionCheckService.userHasProjectPermission(userId, fileInformationResponse.getProjectId(), PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_DOWNLOAD)) { return fileMetadataService.downloadById(fileId); }else { throw new MSException("http_result_forbidden"); @@ -44,12 +44,12 @@ public class FilePreviewController { @GetMapping(value = "/compressed/{userId}/{fileId}") @Operation(summary = "预览缩略图") public ResponseEntity compressedImg(@PathVariable String userId,@PathVariable String fileId) { - FileInformationDTO fileInformationDTO = fileMetadataService.get(fileId); - if (StringUtils.isEmpty(fileInformationDTO.getId())) { + FileInformationResponse fileInformationResponse = fileMetadataService.get(fileId); + if (StringUtils.isEmpty(fileInformationResponse.getId())) { throw new MSException("file.not.exist"); } //检查权限 - if(permissionCheckService.userHasProjectPermission(userId,fileInformationDTO.getProjectId(),PermissionConstants.PROJECT_FILE_MANAGEMENT_READ)){ + if (permissionCheckService.userHasProjectPermission(userId, fileInformationResponse.getProjectId(), PermissionConstants.PROJECT_FILE_MANAGEMENT_READ)) { return fileMetadataService.downloadPreviewImgById(fileId); }else { throw new MSException("http_result_forbidden"); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileRepositoryController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileRepositoryController.java new file mode 100644 index 0000000000..ae19e60aeb --- /dev/null +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/FileRepositoryController.java @@ -0,0 +1,43 @@ +package io.metersphere.project.controller; + +import io.metersphere.project.service.FileMetadataService; +import io.metersphere.project.service.FileRepositoryService; +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.sdk.constants.StorageType; +import io.metersphere.system.dto.sdk.BaseTreeNode; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Tag(name = "项目管理-文件管理-存储库") +@RestController +@RequestMapping("/project/file/repository") +public class FileRepositoryController { + + @Resource + private FileRepositoryService fileRepositoryService; + @Resource + private FileMetadataService fileMetadataService; + + @GetMapping("/list/{projectId}") + @Operation(summary = "项目管理-文件管理-存储库-存储库列表") + @RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ) + public List getTree(@PathVariable String projectId) { + return fileRepositoryService.getTree(projectId); + } + + + @GetMapping(value = "/file-type/{projectId}") + @Operation(summary = "项目管理-文件管理-获取已存在的存储库文件类型") + @RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ) + public List getFileType(@PathVariable String projectId) { + return fileMetadataService.getFileType(projectId, StorageType.GIT.name()); + } +} diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementPageDTO.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementPageDTO.java deleted file mode 100644 index 51b38342db..0000000000 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementPageDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.metersphere.project.dto.filemanagement; - -import io.metersphere.project.request.filemanagement.FileBatchProcessRequest; -import io.metersphere.project.request.filemanagement.FileMetadataTableRequest; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.apache.commons.collections4.MapUtils; - -import java.util.List; - -@Data -@NoArgsConstructor -public class FileManagementPageDTO { - public String projectId; - public String keyword; - public List moduleIds; - public String fileType; - public String operator; - - public FileManagementPageDTO(FileBatchProcessRequest batchProcessDTO) { - this.projectId = batchProcessDTO.getProjectId(); - this.keyword = batchProcessDTO.getCondition().getKeyword(); - this.moduleIds = batchProcessDTO.getModuleIds(); - this.fileType = batchProcessDTO.getFileType(); - if (MapUtils.isNotEmpty(batchProcessDTO.getCondition().getCombine())) { - this.operator = batchProcessDTO.getCondition().getCombine().get("createUser").toString(); - } - } - - public FileManagementPageDTO(FileMetadataTableRequest batchProcessDTO) { - this.projectId = batchProcessDTO.getProjectId(); - this.keyword = batchProcessDTO.getKeyword(); - this.moduleIds = batchProcessDTO.getModuleIds(); - this.fileType = batchProcessDTO.getFileType(); - if (MapUtils.isNotEmpty(batchProcessDTO.getCombine()) && batchProcessDTO.getCombine().get("createUser") != null) { - this.operator = batchProcessDTO.getCombine().get("createUser").toString(); - } - } -} diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementQuery.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementQuery.java new file mode 100644 index 0000000000..75d1116041 --- /dev/null +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileManagementQuery.java @@ -0,0 +1,51 @@ +package io.metersphere.project.dto.filemanagement; + +import io.metersphere.project.dto.filemanagement.request.FileBatchProcessRequest; +import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest; +import io.metersphere.sdk.constants.StorageType; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.collections4.MapUtils; + +import java.util.List; + +@Data +@NoArgsConstructor +public class FileManagementQuery { + public String projectId; + public String keyword; + public List moduleIds; + public String fileType; + public String operator; + public String storage = StorageType.MINIO.name(); + + public FileManagementQuery(FileBatchProcessRequest batchProcessDTO) { + this.projectId = batchProcessDTO.getProjectId(); + this.keyword = batchProcessDTO.getCondition().getKeyword(); + this.moduleIds = batchProcessDTO.getModuleIds(); + this.fileType = batchProcessDTO.getFileType(); + if (MapUtils.isNotEmpty(batchProcessDTO.getCondition().getCombine())) { + if (batchProcessDTO.getCondition().getCombine().get("createUser") != null) { + this.operator = batchProcessDTO.getCondition().getCombine().get("createUser").toString(); + } + if (batchProcessDTO.getCondition().getCombine().get("storage") != null) { + this.storage = batchProcessDTO.getCondition().getCombine().get("storage").toString(); + } + } + } + + public FileManagementQuery(FileMetadataTableRequest batchProcessDTO) { + this.projectId = batchProcessDTO.getProjectId(); + this.keyword = batchProcessDTO.getKeyword(); + this.moduleIds = batchProcessDTO.getModuleIds(); + this.fileType = batchProcessDTO.getFileType(); + if (MapUtils.isNotEmpty(batchProcessDTO.getCombine())) { + if (batchProcessDTO.getCombine().get("createUser") != null) { + this.operator = batchProcessDTO.getCombine().get("createUser").toString(); + } + if (batchProcessDTO.getCombine().get("storage") != null) { + this.storage = batchProcessDTO.getCombine().get("storage").toString(); + } + } + } +} diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileBatchMoveRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileBatchMoveRequest.java similarity index 85% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileBatchMoveRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileBatchMoveRequest.java index 17f9ab7797..ac6c9cc88e 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileBatchMoveRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileBatchMoveRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileBatchProcessRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileBatchProcessRequest.java similarity index 90% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileBatchProcessRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileBatchProcessRequest.java index 1b629428b4..3157765913 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileBatchProcessRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileBatchProcessRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.metersphere.system.dto.table.TableBatchProcessDTO; import io.swagger.v3.oas.annotations.media.Schema; @@ -19,4 +19,5 @@ public class FileBatchProcessRequest extends TableBatchProcessDTO { @Schema(description = "模块ID") private List moduleIds; + } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileMetadataTableRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileMetadataTableRequest.java similarity index 91% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileMetadataTableRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileMetadataTableRequest.java index 0702bb305f..61eef0e03c 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileMetadataTableRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileMetadataTableRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.metersphere.system.dto.sdk.BasePageRequest; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileModuleCreateRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileModuleCreateRequest.java similarity index 93% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileModuleCreateRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileModuleCreateRequest.java index 70fb9f1742..cbe8ea0f84 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileModuleCreateRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileModuleCreateRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.metersphere.sdk.constants.ModuleConstants; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileModuleUpdateRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileModuleUpdateRequest.java similarity index 90% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileModuleUpdateRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileModuleUpdateRequest.java index 30f74d975c..356b77c9f4 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileModuleUpdateRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileModuleUpdateRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileReUploadRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileReUploadRequest.java similarity index 82% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileReUploadRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileReUploadRequest.java index e60e411c0f..7e06719af1 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileReUploadRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileReUploadRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileUpdateRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUpdateRequest.java similarity index 92% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileUpdateRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUpdateRequest.java index 86d6983999..bf121ecf1c 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileUpdateRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUpdateRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileUploadRequest.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUploadRequest.java similarity index 89% rename from backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileUploadRequest.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUploadRequest.java index d3f28d1e54..75b05ca4b0 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/request/filemanagement/FileUploadRequest.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/request/FileUploadRequest.java @@ -1,4 +1,4 @@ -package io.metersphere.project.request.filemanagement; +package io.metersphere.project.dto.filemanagement.request; import io.metersphere.sdk.constants.ModuleConstants; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileInformationDTO.java b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/response/FileInformationResponse.java similarity index 93% rename from backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileInformationDTO.java rename to backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/response/FileInformationResponse.java index 0b9e8278ae..93f71a298f 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/FileInformationDTO.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/dto/filemanagement/response/FileInformationResponse.java @@ -1,4 +1,4 @@ -package io.metersphere.project.dto.filemanagement; +package io.metersphere.project.dto.filemanagement.response; import io.metersphere.project.domain.FileMetadata; import io.metersphere.sdk.util.JSON; @@ -12,7 +12,7 @@ import java.util.List; @Data @NoArgsConstructor -public class FileInformationDTO { +public class FileInformationResponse { @Schema(description = "ID") private String id; @@ -55,7 +55,7 @@ public class FileInformationDTO { @Schema(description = "启用/禁用(jar文件)") private boolean enable; - public FileInformationDTO(FileMetadata fileMetadata) { + public FileInformationResponse(FileMetadata fileMetadata) { if (fileMetadata != null) { this.id = fileMetadata.getId(); this.projectId = fileMetadata.getProjectId(); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.java b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.java index 800340fbf7..9ab04eef9e 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtFileMetadataMapper.java @@ -2,19 +2,19 @@ package io.metersphere.project.mapper; import io.metersphere.project.domain.FileMetadata; import io.metersphere.project.dto.ModuleCountDTO; -import io.metersphere.project.dto.filemanagement.FileManagementPageDTO; +import io.metersphere.project.dto.filemanagement.FileManagementQuery; import org.apache.ibatis.annotations.Param; import java.util.List; public interface ExtFileMetadataMapper { - List selectByKeywordAndFileType(FileManagementPageDTO fileManagementPageDTO); + List selectByKeywordAndFileType(FileManagementQuery fileManagementQuery); - List selectRefIdByKeywordAndFileType(FileManagementPageDTO fileManagementPageDTO); + List selectRefIdByKeywordAndFileType(FileManagementQuery fileManagementQuery); - List countModuleIdByKeywordAndFileType(FileManagementPageDTO fileManagementPageDTO); + List countModuleIdByKeywordAndFileType(FileManagementQuery fileManagementQuery); - long countMyFile(FileManagementPageDTO fileManagementPageDTO); + long countMyFile(FileManagementQuery fileManagementQuery); FileMetadata getById(String id); @@ -28,5 +28,5 @@ public interface ExtFileMetadataMapper { List selectRefIdByModuleIds(@Param("moduleIds") List moduleIds); - List selectFileTypeByProjectId(String projectId); + List selectFileTypeByProjectId(@Param("projectId") String projectId, @Param("storage") String storage); } 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 9ba6e4bf3d..72c7838450 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 @@ -2,7 +2,7 @@ SELECT id, name, parent_id AS parentId, 'module' AS type FROM file_module - WHERE project_id = #{0} + WHERE project_id = #{projectId} + AND module_type = #{moduleType} ORDER BY pos