refactor(接口自动化): 统一文件路径
This commit is contained in:
parent
44422224ca
commit
e532cdb634
|
@ -15,6 +15,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
|
|||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.FileUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -58,7 +59,7 @@ public class MsScenario extends MsTestElement {
|
|||
@JSONField(ordinal = 27)
|
||||
private Map<String, String> environmentMap;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||
|
||||
public MsScenario() {
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
|||
import io.metersphere.commons.constants.LoopConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.FileUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -108,7 +109,7 @@ public abstract class MsTestElement {
|
|||
|
||||
private MsTestElement parent;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||
|
||||
/**
|
||||
* todo 公共环境逐层传递,如果自身有环境 以自身引用环境为准否则以公共环境作为请求环境
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario;
|
|||
|
||||
import io.metersphere.api.dto.scenario.request.BodyFile;
|
||||
import io.metersphere.commons.json.JSONSchemaGenerator;
|
||||
import io.metersphere.commons.utils.FileUtils;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -96,11 +97,10 @@ public class Body {
|
|||
}
|
||||
|
||||
private void setFileArg(List<HTTPFileArg> list, List<BodyFile> files, KeyValue keyValue, String requestId) {
|
||||
final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
if (files != null) {
|
||||
files.forEach(file -> {
|
||||
String paramName = keyValue.getName() == null ? requestId : keyValue.getName();
|
||||
String path = BODY_FILE_DIR + '/' + file.getId() + '_' + file.getName();
|
||||
String path = FileUtils.BODY_FILE_DIR + '/' + file.getId() + '_' + file.getName();
|
||||
String mimetype = keyValue.getContentType();
|
||||
list.add(new HTTPFileArg(path, paramName, mimetype));
|
||||
});
|
||||
|
|
|
@ -91,7 +91,7 @@ public class ApiDefinitionService {
|
|||
|
||||
private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24);
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||
|
||||
public List<ApiDefinitionResult> list(ApiDefinitionRequest request) {
|
||||
request = this.initRequest(request, true, true);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ApiTestCaseService {
|
|||
@Resource
|
||||
private TestPlanApiCaseMapper testPlanApiCaseMapper;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||
|
||||
public List<ApiTestCaseResult> list(ApiTestCaseRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.io.*;
|
|||
import java.util.List;
|
||||
|
||||
public class FileUtils {
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
public static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
public static void createBodyFiles(List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
|
||||
if (CollectionUtils.isNotEmpty(bodyUploadIds) && CollectionUtils.isNotEmpty(bodyFiles)) {
|
||||
|
|
Loading…
Reference in New Issue