feat(系统设置): 上传文件大小限制(接口用例&&性能测试)

--task=1016193 --user=宋昌昌 系统配置支持自定义文件大小限制-后端-V2 https://www.tapd.cn/55049933/s/1576397
This commit is contained in:
song-cc-rock 2024-09-14 10:48:08 +08:00 committed by Craftsman
parent b7e2753c84
commit 36118c79ba
6 changed files with 19 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import io.metersphere.dto.BaseCase;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.RelationshipEdgeDTO;
import io.metersphere.environment.service.BaseEnvironmentService;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
@ -101,7 +102,7 @@ public class ApiDefinitionController {
return apiDefinitionService.listBatch(request);
}
@MsFileLimit
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
@RequiresPermissions(value= {PermissionConstants.PROJECT_API_DEFINITION_READ_CREATE_API, PermissionConstants.PROJECT_API_DEFINITION_READ_COPY_API}, logical = Logical.OR)
@MsAuditLog(module = OperLogModule.API_DEFINITION, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
@ -110,6 +111,7 @@ public class ApiDefinitionController {
return apiDefinitionService.create(request, bodyFiles);
}
@MsFileLimit
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API)
@MsAuditLog(module = OperLogModule.API_DEFINITION, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
@ -182,6 +184,7 @@ public class ApiDefinitionController {
return apiDefinitionService.getById(id);
}
@MsFileLimit
@PostMapping(value = "/run/debug", consumes = {"multipart/form-data"})
@RequiresPermissions(value = {PermissionConstants.PROJECT_API_DEFINITION_READ_DEBUG, PermissionConstants.PROJECT_API_DEFINITION_READ_RUN}, logical = Logical.OR)
@MsAuditLog(module = OperLogModule.API_DEFINITION, type = OperLogConstants.DEBUG, title = "#request.name", project = "#request.projectId")
@ -189,6 +192,7 @@ public class ApiDefinitionController {
return apiDefinitionService.run(request, bodyFiles);
}
@MsFileLimit
@PostMapping(value = "/run", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_RUN)
@MsAuditLog(module = OperLogModule.API_DEFINITION, type = OperLogConstants.EXECUTE, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")

View File

@ -14,6 +14,7 @@ import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
@ -115,6 +116,7 @@ public class ApiTestCaseController {
return returnList;
}
@MsFileLimit
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
@RequiresPermissions(value= {PermissionConstants.PROJECT_API_DEFINITION_READ_CREATE_CASE, PermissionConstants.PROJECT_API_DEFINITION_READ_COPY_CASE}, logical = Logical.OR)
@MsAuditLog(module = OperLogModule.API_DEFINITION_CASE, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ApiTestCaseService.class)
@ -123,6 +125,7 @@ public class ApiTestCaseController {
return apiTestCaseService.create(request, bodyFiles);
}
@MsFileLimit
@PostMapping(value = "/update", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_CASE)
@MsAuditLog(module = OperLogModule.API_DEFINITION_CASE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request)", title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ApiTestCaseService.class)

View File

@ -18,6 +18,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.commons.utils.WebSocketUtil;
import io.metersphere.dto.BaseCase;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
@ -121,6 +122,7 @@ public class ApiScenarioController {
return apiAutomationService.list(request);
}
@MsFileLimit
@PostMapping(value = "/create")
@MsAuditLog(module = OperLogModule.API_AUTOMATION, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiScenarioService.class)
@RequiresPermissions(value = {PermissionConstants.PROJECT_API_SCENARIO_READ_CREATE, PermissionConstants.PROJECT_API_SCENARIO_READ_COPY}, logical = Logical.OR)
@ -129,6 +131,7 @@ public class ApiScenarioController {
return apiAutomationService.create(request, bodyFiles, scenarioFiles);
}
@MsFileLimit
@PostMapping(value = "/update")
@MsAuditLog(module = OperLogModule.API_AUTOMATION, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiScenarioService.class)
@RequiresPermissions(value = {PermissionConstants.PROJECT_API_SCENARIO_READ_EDIT, PermissionConstants.PROJECT_API_SCENARIO_READ_COPY}, logical = Logical.OR)
@ -231,6 +234,7 @@ public class ApiScenarioController {
return apiAutomationService.getScenarioStep(ids);
}
@MsFileLimit
@PostMapping(value = "/run/debug")
@RequiresPermissions(value = {PermissionConstants.PROJECT_API_SCENARIO_READ_DEBUG, PermissionConstants.PROJECT_API_SCENARIO_READ_RUN}, logical = Logical.OR)
@MsAuditLog(module = OperLogModule.API_AUTOMATION, type = OperLogConstants.DEBUG, title = "#request.scenarioName", sourceId = "#request.scenarioId", project = "#request.projectId")
@ -346,6 +350,7 @@ public class ApiScenarioController {
return ResponseEntity.ok().contentType(MediaType.parseMediaType("application/octet-stream")).header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileOperationRequest.getName() + "\"").body(bytes);
}
@MsFileLimit
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_IMPORT_SCENARIO)
@MsAuditLog(module = OperLogModule.API_AUTOMATION, type = OperLogConstants.IMPORT, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")

View File

@ -102,7 +102,7 @@ import {getLicense} from "../../api/license";
import {setLanguage} from "../../i18n";
import {getPlatformParamUrl} from "../../api/qrcode";
import tabQrCode from "../login/tabQrCode.vue";
import {getSystemBaseSetting} from "@/api/system";
import {getSystemBaseSetting} from "../../api/system";
const checkLicense = () => {
return getLicense()

View File

@ -7,6 +7,7 @@ import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.ProjectDTO;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.request.ProjectRequest;
import io.metersphere.service.BaseProjectService;
@ -37,6 +38,7 @@ public class BaseProjectController {
return baseProjectService.getUserProject(request, SessionUtils.getCurrentProjectId());
}
@MsFileLimit
@PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"})
@MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.IMPORT, content = "#msClass.getLogDetails(#projectId)", msClass = BaseProjectService.class)
public List<FileMetadata> uploadFiles(@PathVariable String projectId, @RequestPart(value = "file", required = false) List<MultipartFile> files) {

View File

@ -15,6 +15,7 @@ import io.metersphere.consul.CacheNode;
import io.metersphere.consul.ConsulService;
import io.metersphere.dto.FileOperationRequest;
import io.metersphere.dto.*;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.metadata.service.FileMetadataService;
@ -83,6 +84,7 @@ public class PerformanceTestController {
return performanceTestService.getLoadTestBytestId(testId);
}
@MsFileLimit
@PostMapping(value = "/save", consumes = {"multipart/form-data"})
@MsAuditLog(module = OperLogModule.PERFORMANCE_TEST, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = PerformanceTestService.class)
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_CREATE)
@ -103,6 +105,7 @@ public class PerformanceTestController {
return loadTest;
}
@MsFileLimit
@PostMapping(value = "/edit", consumes = {"multipart/form-data"})
@MsAuditLog(module = OperLogModule.PERFORMANCE_TEST, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = PerformanceTestService.class)
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_EDIT)