refactor: spring boot version 2.5.0

This commit is contained in:
Captain.B 2021-05-31 14:31:38 +08:00 committed by 刘瑞斌
parent 808c430839
commit 3ad7519327
17 changed files with 41 additions and 112 deletions

View File

@ -88,6 +88,11 @@
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- flyway --> <!-- flyway -->
<dependency> <dependency>
<groupId>org.flywaydb</groupId> <groupId>org.flywaydb</groupId>

View File

@ -5,6 +5,7 @@ import io.metersphere.config.KafkaProperties;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration; import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
import org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration;
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration; import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
@ -13,7 +14,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(exclude = { @SpringBootApplication(exclude = {
QuartzAutoConfiguration.class, QuartzAutoConfiguration.class,
LdapAutoConfiguration.class LdapAutoConfiguration.class,
Neo4jAutoConfiguration.class
}) })
@ServletComponentScan @ServletComponentScan
@EnableConfigurationProperties({ @EnableConfigurationProperties({

View File

@ -109,17 +109,17 @@ public class APITestController {
} }
@PostMapping(value = "/create", consumes = {"multipart/form-data"}) @PostMapping(value = "/create", consumes = {"multipart/form-data"})
public void create(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public void create(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file", required = false) MultipartFile file, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
apiTestService.create(request, file, bodyFiles); apiTestService.create(request, file, bodyFiles);
} }
@PostMapping(value = "/create/merge", consumes = {"multipart/form-data"}) @PostMapping(value = "/create/merge", consumes = {"multipart/form-data"})
public void mergeCreate(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "selectIds") List<String> selectIds) { public void mergeCreate(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file", required = false) MultipartFile file, @RequestPart(value = "selectIds") List<String> selectIds) {
apiTestService.mergeCreate(request, file, selectIds); apiTestService.mergeCreate(request, file, selectIds);
} }
@PostMapping(value = "/update", consumes = {"multipart/form-data"}) @PostMapping(value = "/update", consumes = {"multipart/form-data"})
public void update(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public void update(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file", required = false) MultipartFile file, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
checkownerService.checkApiTestOwner(request.getId()); checkownerService.checkApiTestOwner(request.getId());
apiTestService.update(request, file, bodyFiles); apiTestService.update(request, file, bodyFiles);
} }
@ -148,7 +148,7 @@ public class APITestController {
} }
@PostMapping(value = "/run/debug", consumes = {"multipart/form-data"}) @PostMapping(value = "/run/debug", consumes = {"multipart/form-data"})
public String runDebug(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public String runDebug(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file", required = false) MultipartFile file, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
return apiTestService.runDebug(request, file, bodyFiles); return apiTestService.runDebug(request, file, bodyFiles);
} }
@ -392,7 +392,7 @@ public class APITestController {
} }
@PostMapping(value = "/genPerformanceTestXml", consumes = {"multipart/form-data"}) @PostMapping(value = "/genPerformanceTestXml", consumes = {"multipart/form-data"})
public JmxInfoDTO genPerformanceTest(@RequestPart("request") RunDefinitionRequest runRequest, @RequestPart(value = "files") List<MultipartFile> bodyFiles) throws Exception { public JmxInfoDTO genPerformanceTest(@RequestPart("request") RunDefinitionRequest runRequest, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) throws Exception {
ParameterConfig config = new ParameterConfig(); ParameterConfig config = new ParameterConfig();
config.setProjectId(runRequest.getProjectId()); config.setProjectId(runRequest.getProjectId());

View File

@ -78,16 +78,16 @@ public class ApiAutomationController {
@PostMapping(value = "/create") @PostMapping(value = "/create")
@MsAuditLog(module = "api_automation", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class) @MsAuditLog(module = "api_automation", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_CREATE) @RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_CREATE)
public ApiScenario create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles, public ApiScenario create(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles", required = false) List<MultipartFile> bodyFiles,
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) { @RequestPart(value = "scenarioFiles", required = false) List<MultipartFile> scenarioFiles) {
return apiAutomationService.create(request, bodyFiles, scenarioFiles); return apiAutomationService.create(request, bodyFiles, scenarioFiles);
} }
@PostMapping(value = "/update") @PostMapping(value = "/update")
@MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class) @MsAuditLog(module = "api_automation", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiAutomationService.class)
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EDIT) @RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ_EDIT)
public void update(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles, public void update(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "bodyFiles", required = false) List<MultipartFile> bodyFiles,
@RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) { @RequestPart(value = "scenarioFiles", required = false) List<MultipartFile> scenarioFiles) {
apiAutomationService.update(request, bodyFiles, scenarioFiles); apiAutomationService.update(request, bodyFiles, scenarioFiles);
} }
@ -156,7 +156,7 @@ public class ApiAutomationController {
@PostMapping(value = "/run/debug") @PostMapping(value = "/run/debug")
@MsAuditLog(module = "api_automation", type = OperLogConstants.DEBUG, title = "#request.scenarioName", project = "#request.projectId") @MsAuditLog(module = "api_automation", type = OperLogConstants.DEBUG, title = "#request.scenarioName", project = "#request.projectId")
public void runDebug(@RequestPart("request") RunDefinitionRequest request, public void runDebug(@RequestPart("request") RunDefinitionRequest request,
@RequestPart(value = "bodyFiles") List<MultipartFile> bodyFiles, @RequestPart(value = "scenarioFiles") List<MultipartFile> scenarioFiles) { @RequestPart(value = "bodyFiles", required = false) List<MultipartFile> bodyFiles, @RequestPart(value = "scenarioFiles", required = false) List<MultipartFile> scenarioFiles) {
request.setExecuteType(ExecuteType.Debug.name()); request.setExecuteType(ExecuteType.Debug.name());
apiAutomationService.debugRun(request, bodyFiles, scenarioFiles); apiAutomationService.debugRun(request, bodyFiles, scenarioFiles);
} }

View File

@ -97,7 +97,7 @@ public class ApiDefinitionController {
@PostMapping(value = "/create", consumes = {"multipart/form-data"}) @PostMapping(value = "/create", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_CREATE_API) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_CREATE_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class) @MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
public ApiDefinitionWithBLOBs create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public ApiDefinitionWithBLOBs create(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
checkPermissionService.checkProjectOwner(request.getProjectId()); checkPermissionService.checkProjectOwner(request.getProjectId());
return apiDefinitionService.create(request, bodyFiles); return apiDefinitionService.create(request, bodyFiles);
} }
@ -105,7 +105,7 @@ public class ApiDefinitionController {
@PostMapping(value = "/update", consumes = {"multipart/form-data"}) @PostMapping(value = "/update", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_EDIT_API)
@MsAuditLog(module = "api_definition", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class) @MsAuditLog(module = "api_definition", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = ApiDefinitionService.class)
public ApiDefinitionWithBLOBs update(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public ApiDefinitionWithBLOBs update(@RequestPart("request") SaveApiDefinitionRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
checkPermissionService.checkProjectOwner(request.getProjectId()); checkPermissionService.checkProjectOwner(request.getProjectId());
return apiDefinitionService.update(request, bodyFiles); return apiDefinitionService.update(request, bodyFiles);
} }
@ -166,13 +166,13 @@ public class ApiDefinitionController {
@PostMapping(value = "/run/debug", consumes = {"multipart/form-data"}) @PostMapping(value = "/run/debug", consumes = {"multipart/form-data"})
@MsAuditLog(module = "api_definition", type = OperLogConstants.DEBUG, title = "#request.name", project = "#request.projectId") @MsAuditLog(module = "api_definition", type = OperLogConstants.DEBUG, title = "#request.name", project = "#request.projectId")
public String runDebug(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public String runDebug(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
return apiDefinitionService.run(request, bodyFiles); return apiDefinitionService.run(request, bodyFiles);
} }
@PostMapping(value = "/run", consumes = {"multipart/form-data"}) @PostMapping(value = "/run", consumes = {"multipart/form-data"})
@MsAuditLog(module = "api_definition", type = OperLogConstants.EXECUTE, sourceId = "#request.id", title = "#request.name", project = "#request.projectId") @MsAuditLog(module = "api_definition", type = OperLogConstants.EXECUTE, sourceId = "#request.id", title = "#request.name", project = "#request.projectId")
public String run(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public String run(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
request.setReportId(null); request.setReportId(null);
return apiDefinitionService.run(request, bodyFiles); return apiDefinitionService.run(request, bodyFiles);
} }

View File

@ -90,13 +90,13 @@ public class ApiTestCaseController {
@PostMapping(value = "/create", consumes = {"multipart/form-data"}) @PostMapping(value = "/create", consumes = {"multipart/form-data"})
@MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ApiTestCaseService.class) @MsAuditLog(module = "api_definition", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ApiTestCaseService.class)
public ApiTestCase create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public ApiTestCase create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
return apiTestCaseService.create(request, bodyFiles); return apiTestCaseService.create(request, bodyFiles);
} }
@PostMapping(value = "/update", consumes = {"multipart/form-data"}) @PostMapping(value = "/update", consumes = {"multipart/form-data"})
@MsAuditLog(module = "api_definition", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request)", title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ApiTestCaseService.class) @MsAuditLog(module = "api_definition", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request)", title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ApiTestCaseService.class)
public ApiTestCase update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public ApiTestCase update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles) {
return apiTestCaseService.update(request, bodyFiles); return apiTestCaseService.update(request, bodyFiles);
} }

View File

@ -70,13 +70,13 @@ public class ApiTestEnvironmentController {
@PostMapping("/add") @PostMapping("/add")
@MsAuditLog(module = "project_environment_setting", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#apiTestEnvironmentWithBLOBs.id)", msClass = ApiTestEnvironmentService.class) @MsAuditLog(module = "project_environment_setting", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#apiTestEnvironmentWithBLOBs.id)", msClass = ApiTestEnvironmentService.class)
public String create(@RequestPart("request") ApiTestEnvironmentDTO apiTestEnvironmentWithBLOBs, @RequestPart(value = "files") List<MultipartFile> sslFiles) { public String create(@RequestPart("request") ApiTestEnvironmentDTO apiTestEnvironmentWithBLOBs, @RequestPart(value = "files", required = false) List<MultipartFile> sslFiles) {
return apiTestEnvironmentService.add(apiTestEnvironmentWithBLOBs, sslFiles); return apiTestEnvironmentService.add(apiTestEnvironmentWithBLOBs, sslFiles);
} }
@PostMapping(value = "/update") @PostMapping(value = "/update")
@MsAuditLog(module = "project_environment_setting", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#apiTestEnvironment.id)", content = "#msClass.getLogDetails(#apiTestEnvironment.id)", msClass = ApiTestEnvironmentService.class) @MsAuditLog(module = "project_environment_setting", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#apiTestEnvironment.id)", content = "#msClass.getLogDetails(#apiTestEnvironment.id)", msClass = ApiTestEnvironmentService.class)
public void update(@RequestPart("request") ApiTestEnvironmentDTO apiTestEnvironment, @RequestPart(value = "files") List<MultipartFile> sslFiles) { public void update(@RequestPart("request") ApiTestEnvironmentDTO apiTestEnvironment, @RequestPart(value = "files", required = false) List<MultipartFile> sslFiles) {
apiTestEnvironmentService.update(apiTestEnvironment, sslFiles); apiTestEnvironmentService.update(apiTestEnvironment, sslFiles);
} }

View File

@ -47,7 +47,7 @@ public class JarConfigController {
@PostMapping(value = "/add", consumes = {"multipart/form-data"}) @PostMapping(value = "/add", consumes = {"multipart/form-data"})
@MsAuditLog(module = "project_project_jar", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = JarConfigService.class) @MsAuditLog(module = "project_project_jar", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = JarConfigService.class)
public String add(@RequestPart("request") JarConfig request, @RequestPart(value = "file") MultipartFile file) { public String add(@RequestPart("request") JarConfig request, @RequestPart(value = "file", required = false) MultipartFile file) {
return JarConfigService.add(request, file); return JarConfigService.add(request, file);
} }

View File

@ -114,13 +114,13 @@ public class ProjectController {
@PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"}) @PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"})
@MsAuditLog(module = "project_file_management", type = OperLogConstants.IMPORT, content = "#msClass.getLogDetails(#projectId)", msClass = ProjectService.class) @MsAuditLog(module = "project_file_management", type = OperLogConstants.IMPORT, content = "#msClass.getLogDetails(#projectId)", msClass = ProjectService.class)
public List<FileMetadata> uploadFiles(@PathVariable String projectId, @RequestPart(value = "file") List<MultipartFile> files) { public List<FileMetadata> uploadFiles(@PathVariable String projectId, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
return projectService.uploadFiles(projectId, files); return projectService.uploadFiles(projectId, files);
} }
@PostMapping(value = "/update/file/{fileId}", consumes = {"multipart/form-data"}) @PostMapping(value = "/update/file/{fileId}", consumes = {"multipart/form-data"})
@MsAuditLog(module = "project_file_management", type = OperLogConstants.IMPORT, content = "#msClass.getLogDetails(#fileId)", msClass = ProjectService.class) @MsAuditLog(module = "project_file_management", type = OperLogConstants.IMPORT, content = "#msClass.getLogDetails(#fileId)", msClass = ProjectService.class)
public FileMetadata updateFile(@PathVariable String fileId, @RequestPart(value = "file") MultipartFile file) { public FileMetadata updateFile(@PathVariable String fileId, @RequestPart(value = "file", required = false) MultipartFile file) {
return projectService.updateFile(fileId, file); return projectService.updateFile(fileId, file);
} }

View File

@ -19,7 +19,7 @@ public class ResourceController {
@Resource @Resource
ResourceService resourceService; ResourceService resourceService;
@PostMapping(value = "/md/upload", consumes = {"multipart/form-data"}) @PostMapping(value = "/md/upload", consumes = {"multipart/form-data"})
public void upload(@RequestPart(value = "request") MdUploadRequest request, @RequestPart(value = "file") MultipartFile file) { public void upload(@RequestPart(value = "request") MdUploadRequest request, @RequestPart(value = "file", required = false) MultipartFile file) {
resourceService.mdUpload(request, file); resourceService.mdUpload(request, file);
} }

View File

@ -18,8 +18,8 @@ public class TestController {
@PostMapping(value = "/upload", consumes = {"multipart/form-data"}) @PostMapping(value = "/upload", consumes = {"multipart/form-data"})
public Object testUpload(@RequestPart(value = "id") String id, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles public Object testUpload(@RequestPart(value = "id") String id, @RequestPart(value = "file", required = false) MultipartFile file, @RequestPart(value = "files", required = false) List<MultipartFile> bodyFiles
, @RequestPart(value = "user") User user, @RequestParam(value = "name") String name) { , @RequestPart(value = "user") User user, @RequestParam(value = "name") String name) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("id", id); jsonObject.put("id", id);
jsonObject.put("file", file.getOriginalFilename()); jsonObject.put("file", file.getOriginalFilename());

View File

@ -1,77 +0,0 @@
package io.metersphere.controller.handler;
import io.metersphere.controller.ResultHolder;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import java.util.Objects;
@RestController
public class GlobalExceptionHandler implements ErrorController {
public static final org.slf4j.Logger Logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
private static final String PATH = "/error";
@Resource
private ErrorAttributes errorAttributes;
@Override
public String getErrorPath() {
return PATH;
}
@RequestMapping(value = {PATH}, produces = {"text/html"})
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("error", this.getErrorAttributes(request, false));
}
@RequestMapping(value = PATH)
public ResultHolder error(HttpServletRequest request, HttpServletResponse response) {
WebRequest webRequest = new ServletWebRequest(request);
Throwable t = errorAttributes.getError(webRequest);
Map<String, Object> errorAttributeMap = errorAttributes.getErrorAttributes(webRequest, true);
Integer code = (Integer) errorAttributeMap.get("status");
response.setStatus(code);
String errorMessage = StringUtils.EMPTY;
if (t != null) {
if (Logger.isDebugEnabled()) {
Logger.error("Fail to proceed " + errorAttributeMap.get("path"), t);
}
errorMessage = t.getMessage();
}
if (StringUtils.isBlank(errorMessage)) {
if (code == 403) {
errorMessage = "Permission Denied.";
} else if (code == 404) {
String path = request.getServletPath();
if (Objects.nonNull(request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI)) && StringUtils.isNotBlank(request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI).toString())) {
path = request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI).toString();
}
errorMessage = path + " not found.";
} else {
errorMessage = "The server responds " + code + " but no detailed message.";
}
}
return ResultHolder.error(errorMessage);
}
protected Map<String, Object> getErrorAttributes(HttpServletRequest request, boolean includeStackTrace) {
WebRequest webRequest = new ServletWebRequest(request);
return this.errorAttributes.getErrorAttributes(webRequest, includeStackTrace);
}
}

View File

@ -79,7 +79,7 @@ public class PerformanceTestController {
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_CREATE) @RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_CREATE)
public String save( public String save(
@RequestPart("request") SaveTestPlanRequest request, @RequestPart("request") SaveTestPlanRequest request,
@RequestPart(value = "file") List<MultipartFile> files @RequestPart(value = "file", required = false) List<MultipartFile> files
) { ) {
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
checkPermissionService.checkProjectOwner(request.getProjectId()); checkPermissionService.checkProjectOwner(request.getProjectId());

View File

@ -129,20 +129,20 @@ public class TestCaseController {
@PostMapping(value = "/add", consumes = {"multipart/form-data"}) @PostMapping(value = "/add", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_CREATE) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_CREATE)
@MsAuditLog(module = "track_test_case", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class) @MsAuditLog(module = "track_test_case", type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)
public String addTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file") List<MultipartFile> files) { public String addTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
return testCaseService.save(request, files); return testCaseService.save(request, files);
} }
@PostMapping(value = "/edit", consumes = {"multipart/form-data"}) @PostMapping(value = "/edit", consumes = {"multipart/form-data"})
@MsAuditLog(module = "track_test_case", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class) @MsAuditLog(module = "track_test_case", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)
public String editTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file") List<MultipartFile> files) { public String editTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
return testCaseService.edit(request, files); return testCaseService.edit(request, files);
} }
@PostMapping(value = "/edit/testPlan", consumes = {"multipart/form-data"}) @PostMapping(value = "/edit/testPlan", consumes = {"multipart/form-data"})
@MsAuditLog(module = "track_test_case", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogBeforeDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class) @MsAuditLog(module = "track_test_case", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogBeforeDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)
public String editTestCaseByTestPlan(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file") List<MultipartFile> files) { public String editTestCaseByTestPlan(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
return testCaseService.editTestCase(request, files); return testCaseService.editTestCase(request, files);
} }

@ -1 +1 @@
Subproject commit 87b900d9c55591b1a3a6044172ef02c0bf5b145c Subproject commit 846026f76e50c5a6533a76c0f9822f7b0146b325

View File

@ -24,12 +24,11 @@ mybatis.configuration.use-column-label=true
mybatis.configuration.auto-mapping-behavior=full mybatis.configuration.auto-mapping-behavior=full
mybatis.configuration.default-statement-timeout=25000 mybatis.configuration.default-statement-timeout=25000
mybatis.configuration.map-underscore-to-camel-case=true mybatis.configuration.map-underscore-to-camel-case=true
logging.file.path=/opt/metersphere/logs/${spring.application.name} logging.file.path=/opt/metersphere/logs/${spring.application.name}
# view # view
spring.resources.static-locations=classpath:/templates/,classpath:/static/ spring.mvc.throw-exception-if-no-handler-found=true
spring.web.resources.add-mappings=false
spring.web.resources.static-locations=classpath:/templates/,classpath:/static/
# flyway enable # flyway enable
spring.flyway.enabled=true spring.flyway.enabled=true
spring.flyway.baseline-on-migrate=true spring.flyway.baseline-on-migrate=true

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version> <version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>