refactor(接口测试): cURL导入优化

This commit is contained in:
WangXu10 2024-09-24 16:18:04 +08:00 committed by Craftsman
parent f24222598e
commit 5400338962
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import io.metersphere.project.service.FileModuleService;
import io.metersphere.sdk.constants.DefaultRepositoryDir;
import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.sdk.dto.api.task.TaskRequestDTO;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.dto.sdk.BaseTreeNode;
import io.metersphere.system.file.annotation.FileLimit;
import io.metersphere.system.log.annotation.Log;
@ -30,6 +31,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @author : jianxing
@ -132,6 +135,12 @@ public class ApiDebugController {
@RequiresPermissions(value = {PermissionConstants.PROJECT_API_DEBUG_READ, PermissionConstants.PROJECT_API_SCENARIO_ADD}, logical = Logical.OR)
public CurlEntity importCurl(@RequestBody ApiImportCurlRequest request) {
CurlEntity parse = CurlParserUtil.parse(request.getCurl());
Optional.ofNullable(parse.getBody()).ifPresent(body -> {
if (parse.getMethod() == CurlEntity.Method.GET) {
Map map = JSON.parseMap(JSON.toFormatJSONString(body));
parse.getQueryParams().putAll(map);
}
});
return parse;
}