From 8cce2c6a7ba222945c821004327158e59a4ae771 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 17 Aug 2022 11:30:33 +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=E7=AE=A1=E7=90=86=E9=87=8D=E6=9E=84=E5=90=8E?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtFileMetadataMapper.xml | 4 ++-- .../controller/FileMetadataController.java | 12 ++++++------ .../controller/FileModuleController.java | 2 +- .../metadata/service/FileMetadataService.java | 15 +++++++++++++++ .../metadata/service/FileModuleService.java | 8 -------- .../db/migration/V129__2.1.0__release.sql | 11 +++++++---- .../scenario/variable/CsvFileUpload.vue | 2 +- .../components/body/ApiBodyFileUpload.vue | 2 +- .../definition/components/module/ApiModule.vue | 6 ------ .../project/menu/file/module/FileModule.vue | 17 +++++------------ 10 files changed, 38 insertions(+), 41 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtFileMetadataMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtFileMetadataMapper.xml index 89406a9bb2..83a49af144 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtFileMetadataMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtFileMetadataMapper.xml @@ -3,7 +3,7 @@ diff --git a/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java b/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java index ab965f8662..45d3651a9c 100644 --- a/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java +++ b/backend/src/main/java/io/metersphere/metadata/controller/FileMetadataController.java @@ -42,13 +42,12 @@ public class FileMetadataController { } @PostMapping(value = "/create") - @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.IMPORT, content = "#msClass.getLogDetails(#projectId)", msClass = FileMetadataService.class) + @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = FileMetadataService.class) public List create(@RequestPart("request") FileMetadata request, @RequestPart(value = "file", required = false) List files) { return fileMetadataService.create(request, files); } @PostMapping(value = "/upload") - @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.IMPORT, content = "#msClass.getLogDetails(#projectId)", msClass = FileMetadataService.class) public FileMetadata upload(@RequestPart("request") FileMetadata request, @RequestPart(value = "file", required = false) List files) { return fileMetadataService.reLoad(request, files); } @@ -72,13 +71,12 @@ public class FileMetadataController { } @GetMapping(value = "/delete/{fileId}") - @MsAuditLog(module = OperLogModule.PROJECT_PROJECT_MANAGER, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#fileId)", msClass = FileMetadataService.class) + @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#fileId)", msClass = FileMetadataService.class) public void deleteFile(@PathVariable String fileId) { fileMetadataService.deleteFile(fileId); } @PostMapping(value = "/delete/batch") - @MsAuditLog(module = OperLogModule.PROJECT_PROJECT_MANAGER, type = OperLogConstants.BATCH_DEL, beforeEvent = "#msClass.getLogDetails(#fileId)", msClass = FileMetadataService.class) public void deleteBatch(@RequestBody List ids) { fileMetadataService.deleteBatch(ids); } @@ -89,17 +87,19 @@ public class FileMetadataController { } @PostMapping(value = "/move") + @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = FileMetadataService.class) public void move(@RequestBody MoveFIleMetadataRequest request) { fileMetadataService.move(request); } @PostMapping(value = "/update") + @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = FileMetadataService.class) public void update(@RequestBody FileMetadata request) { fileMetadataService.update(request); } - @PostMapping(value = "/api/upload", consumes = {"multipart/form-data"}) - public void apiUpload(@RequestPart("request") DumpFileRequest request, @RequestPart(value = "files", required = false) List files) { + @PostMapping(value = "/dump/file", consumes = {"multipart/form-data"}) + public void dumpFile(@RequestPart("request") DumpFileRequest request, @RequestPart(value = "files", required = false) List files) { fileMetadataService.dumpFile(request, files); } diff --git a/backend/src/main/java/io/metersphere/metadata/controller/FileModuleController.java b/backend/src/main/java/io/metersphere/metadata/controller/FileModuleController.java index 276c3637de..b9646b8bfc 100644 --- a/backend/src/main/java/io/metersphere/metadata/controller/FileModuleController.java +++ b/backend/src/main/java/io/metersphere/metadata/controller/FileModuleController.java @@ -41,7 +41,7 @@ public class FileModuleController { } @PostMapping("/delete") - @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#nodeIds)", msClass = FileModule.class) + @MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#nodeIds)", msClass = FileModuleService.class) public int deleteNode(@RequestBody List nodeIds) { return fileModuleService.deleteNode(nodeIds); } diff --git a/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java b/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java index 28637629b2..452250caa3 100644 --- a/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java +++ b/backend/src/main/java/io/metersphere/metadata/service/FileMetadataService.java @@ -1,5 +1,6 @@ package io.metersphere.metadata.service; +import com.alibaba.fastjson.JSON; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtFileMetadataMapper; @@ -9,6 +10,10 @@ import io.metersphere.commons.utils.FileUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.OrderRequest; import io.metersphere.i18n.Translator; +import io.metersphere.log.utils.ReflexObjectUtil; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.system.SystemReference; import io.metersphere.metadata.utils.MetadataUtils; import io.metersphere.metadata.vo.DownloadRequest; import io.metersphere.metadata.vo.DumpFileRequest; @@ -356,4 +361,14 @@ public class FileMetadataService { fileMetadata.createCriteria().andProjectIdEqualTo(projectId).andCreateUserEqualTo(createUser); return fileMetadataMapper.countByExample(fileMetadata); } + + public String getLogDetails(String id) { + FileMetadata fileMetadata = this.getFileMetadataById(id); + if (fileMetadata != null) { + List columns = ReflexObjectUtil.getColumns(fileMetadata, SystemReference.projectColumns); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(fileMetadata.getId()), fileMetadata.getProjectId(), fileMetadata.getName(), null, columns); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/metadata/service/FileModuleService.java b/backend/src/main/java/io/metersphere/metadata/service/FileModuleService.java index 93b2721f04..13bcc708c4 100644 --- a/backend/src/main/java/io/metersphere/metadata/service/FileModuleService.java +++ b/backend/src/main/java/io/metersphere/metadata/service/FileModuleService.java @@ -10,7 +10,6 @@ import io.metersphere.base.mapper.FileModuleMapper; import io.metersphere.base.mapper.ext.ExtFileMetadataMapper; import io.metersphere.base.mapper.ext.ExtFileModuleMapper; import io.metersphere.commons.constants.ApiTestConstants; -import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; @@ -170,10 +169,6 @@ public class FileModuleService extends NodeTreeService { } private void validateNode(FileModule node) { - if (node.getLevel() > TestCaseConstants.MAX_NODE_DEPTH) { - MSException.throwException(Translator.get("test_case_node_level_tip") - + TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level")); - } checkApiModuleExist(node); } @@ -275,9 +270,6 @@ public class FileModuleService extends NodeTreeService { private void buildUpdateDefinition(FileModuleVo rootNode, List updateNodes, String rootPath, String pId, int level) { rootPath = rootPath + rootNode.getName(); - if (level > 8) { - MSException.throwException(Translator.get("node_deep_limit")); - } if ("root".equals(rootNode.getId())) { rootPath = ""; } diff --git a/backend/src/main/resources/db/migration/V129__2.1.0__release.sql b/backend/src/main/resources/db/migration/V129__2.1.0__release.sql index e42d9fc94c..a4d4dbec0b 100644 --- a/backend/src/main/resources/db/migration/V129__2.1.0__release.sql +++ b/backend/src/main/resources/db/migration/V129__2.1.0__release.sql @@ -78,13 +78,13 @@ ALTER TABLE `ui_scenario` ADD INDEX index_project_id_status_module_id (`proje -- V128__2-1-0_feat_file_manage -- file_metadata 新增字段 ALTER TABLE `file_metadata` - ADD storage VARCHAR(50) DEFAULT 'LOCAL' COMMENT '文件存储方式'; + ADD storage VARCHAR(50) DEFAULT NULL COMMENT '文件存储方式'; ALTER TABLE `file_metadata` - ADD create_user VARCHAR(100) DEFAULT '' COMMENT '创建人'; + ADD create_user VARCHAR(100) DEFAULT NULL COMMENT '创建人'; ALTER TABLE `file_metadata` - ADD update_user VARCHAR(100) DEFAULT '' COMMENT '修改人'; + ADD update_user VARCHAR(100) DEFAULT NULL COMMENT '修改人'; ALTER TABLE `file_metadata` ADD tags VARCHAR(2000) DEFAULT NULL COMMENT '标签'; @@ -96,7 +96,7 @@ ALTER TABLE `file_metadata` ADD module_id VARCHAR(50) DEFAULT NULL COMMENT '文件所属模块'; ALTER TABLE `file_metadata` - ADD load_jar TINYINT(1) DEFAULT 1 COMMENT '是否加载jar(开启后用于接口测试执行时使用)'; + ADD load_jar TINYINT(1) DEFAULT 0 COMMENT '是否加载jar(开启后用于接口测试执行时使用)'; ALTER TABLE `file_metadata` ADD path VARCHAR(1000) DEFAULT NULL COMMENT '文件存储路径'; @@ -104,6 +104,9 @@ ALTER TABLE `file_metadata` ALTER TABLE `file_metadata` ADD resource_type VARCHAR(50) DEFAULT NULL COMMENT '资源作用范围,主要兼容2.1版本前的历史数据,后续版本不再产生数据'; +ALTER TABLE api_execution_queue_detail + ADD COLUMN project_ids VARCHAR(2000) DEFAULT "[]" COMMENT '项目ID集合'; + -- 补充索引 ALTER TABLE file_metadata ADD INDEX module_id_index (`module_id`), diff --git a/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue b/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue index 4de4daff23..62ddc0eed0 100644 --- a/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue +++ b/frontend/src/business/components/api/automation/scenario/variable/CsvFileUpload.vue @@ -90,7 +90,7 @@ export default { files.push(this.file.file); } let request = {id: getUUID(), resourceId: this.id, moduleId: moduleId, projectId: getCurrentProjectID(), fileName: this.file.name}; - this.$fileUpload("/file/metadata/api/upload", null, files, request, (response) => { + this.$fileUpload("/file/metadata/dump/file", null, files, request, (response) => { this.$success(this.$t("organization.integration.successful_operation")); }); }, diff --git a/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue b/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue index d49afdcd69..982140707a 100644 --- a/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue +++ b/frontend/src/business/components/api/definition/components/body/ApiBodyFileUpload.vue @@ -79,7 +79,7 @@ export default { files.push(this.file.file); } let request = {id: getUUID(), resourceId: this.id, moduleId: moduleId, projectId: getCurrentProjectID(), fileName: this.file.name}; - this.$fileUpload("/file/metadata/api/upload", null, files, request, (response) => { + this.$fileUpload("/file/metadata/dump/file", null, files, request, (response) => { this.$success(this.$t("organization.integration.successful_operation")); }); }, diff --git a/frontend/src/business/components/api/definition/components/module/ApiModule.vue b/frontend/src/business/components/api/definition/components/module/ApiModule.vue index ad2714c62c..6d3229a5f2 100644 --- a/frontend/src/business/components/api/definition/components/module/ApiModule.vue +++ b/frontend/src/business/components/api/definition/components/module/ApiModule.vue @@ -251,18 +251,12 @@ export default { add(param) { param.projectId = this.projectId; param.protocol = this.condition.protocol; - if (param && param.level >= 9) { - this.list(); - this.$error(this.$t('commons.warning_module_add')); - return; - } else { this.$post("/api/module/add", param, () => { this.$success(this.$t('commons.save_success')); this.list(); }, (error) => { this.list(); }); - } }, remove(nodeIds) { this.$post("/api/module/delete", nodeIds, () => { diff --git a/frontend/src/business/components/project/menu/file/module/FileModule.vue b/frontend/src/business/components/project/menu/file/module/FileModule.vue index 23cacfb818..a0e7f6c81a 100644 --- a/frontend/src/business/components/project/menu/file/module/FileModule.vue +++ b/frontend/src/business/components/project/menu/file/module/FileModule.vue @@ -141,19 +141,12 @@ export default { add(param) { param.projectId = this.projectId; param.protocol = this.condition.protocol; - if (param && param.level >= 9) { + this.$post("/file/module/add", param, () => { + this.$success(this.$t('commons.save_success')); this.list(); - this.$error(this.$t('commons.warning_module_add')); - return; - } else { - this.$post("/file/module/add", param, () => { - this.$success(this.$t('commons.save_success')); - this.list(); - }, (error) => { - this.list(); - }); - } - + }, (error) => { + this.list(); + }); }, remove(nodeIds) { this.$post("/file/module/delete", nodeIds, () => {