Merge branch 'master' of github.com:metersphere/metersphere
This commit is contained in:
commit
d03976d8e1
|
@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author song.tianyang
|
||||
|
@ -39,13 +41,19 @@ public class ApiDocumentController {
|
|||
@PostMapping("/selectApiInfoByParam")
|
||||
public List<ApiDocumentInfoDTO> selectApiInfoByParam(@RequestBody ApiDocumentRequest request) {
|
||||
List<ApiDocumentInfoDTO> returnList = new ArrayList<>();
|
||||
List<ApiDefinitionWithBLOBs> apiModels = apiDefinitionService.getBLOBs(request.getApiIdList());
|
||||
for (ApiDefinitionWithBLOBs apiModel : apiModels) {
|
||||
try{
|
||||
ApiDocumentInfoDTO returnDTO = apiDocumentService.conversionModelToDTO(apiModel);
|
||||
if(request.getApiIdList() != null){
|
||||
//要根据ids的顺序进行返回排序
|
||||
List<ApiDefinitionWithBLOBs> apiModels = apiDefinitionService.getBLOBs(request.getApiIdList());
|
||||
Map<String,ApiDefinitionWithBLOBs> apiModelMaps = apiModels.stream().collect(Collectors.toMap(ApiDefinitionWithBLOBs :: getId,a->a,(k1,k2)->k1));
|
||||
for(String id : request.getApiIdList()){
|
||||
ApiDefinitionWithBLOBs model = apiModelMaps.get(id);
|
||||
if(model == null){
|
||||
model = new ApiDefinitionWithBLOBs();
|
||||
model.setId(id);
|
||||
model.setName(id);
|
||||
}
|
||||
ApiDocumentInfoDTO returnDTO = apiDocumentService.conversionModelToDTO(model);
|
||||
returnList.add(returnDTO);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
|
|
|
@ -201,7 +201,7 @@ public class MsLoopController extends MsTestElement {
|
|||
jsr223PreProcessor.setName("循环超时处理");
|
||||
jsr223PreProcessor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName());
|
||||
jsr223PreProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
jsr223PreProcessor.setProperty("cacheKey", "true");
|
||||
/*jsr223PreProcessor.setProperty("cacheKey", "true");*/
|
||||
jsr223PreProcessor.setProperty("scriptLanguage", "beanshell");
|
||||
jsr223PreProcessor.setProperty("script", script());
|
||||
hashTree.add(jsr223PreProcessor);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
|
||||
processor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName());
|
||||
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
processor.setProperty("cacheKey", "true");
|
||||
/*processor.setProperty("cacheKey", "true");*/
|
||||
processor.setProperty("scriptLanguage", this.getScriptLanguage());
|
||||
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
|
||||
processor.setProperty("scriptLanguage", "nashorn");
|
||||
|
|
|
@ -42,7 +42,7 @@ public class MsJSR223PostProcessor extends MsTestElement {
|
|||
}
|
||||
processor.setProperty(TestElement.TEST_CLASS, JSR223PostProcessor.class.getName());
|
||||
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
processor.setProperty("cacheKey", "true");
|
||||
/*processor.setProperty("cacheKey", "true");*/
|
||||
processor.setProperty("scriptLanguage", this.getScriptLanguage());
|
||||
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
|
||||
processor.setProperty("scriptLanguage", "nashorn");
|
||||
|
|
|
@ -54,7 +54,7 @@ public class MsJSR223PreProcessor extends MsTestElement {
|
|||
}
|
||||
processor.setProperty(TestElement.TEST_CLASS, JSR223PreProcessor.class.getName());
|
||||
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
processor.setProperty("cacheKey", "true");
|
||||
/*processor.setProperty("cacheKey", "true");*/
|
||||
processor.setProperty("scriptLanguage", this.getScriptLanguage());
|
||||
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
|
||||
processor.setProperty("scriptLanguage", "nashorn");
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ApiDocumentService {
|
|||
|
||||
if (apiModel.getRequest() != null) {
|
||||
JSONObject requestJsonObj = JSONObject.parseObject(apiModel.getRequest());
|
||||
//head赋值
|
||||
//head赋值conversionModelToDTO
|
||||
if (requestJsonObj.containsKey("headers")) {
|
||||
JSONArray requestHeadDataArr = new JSONArray();
|
||||
//head赋值
|
||||
|
@ -300,6 +300,7 @@ public class ApiDocumentService {
|
|||
}
|
||||
}
|
||||
apiInfoDTO.setRequestPreviewData(previewJsonArray);
|
||||
apiInfoDTO.setSelectedFlag(true);
|
||||
return apiInfoDTO;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,19 @@
|
|||
</div>
|
||||
<!--最大化不显示具体内容-->
|
||||
<div class="header" v-if="!isMax">
|
||||
<fieldset :disabled="data.disabled" class="ms-fieldset">
|
||||
<el-collapse-transition>
|
||||
<div v-if="data.active && showCollapse" :draggable="draggable">
|
||||
<el-divider></el-divider>
|
||||
<el-collapse-transition>
|
||||
<div v-if="data.active && showCollapse" :draggable="draggable">
|
||||
<el-divider></el-divider>
|
||||
<fieldset :disabled="data.disabled" class="ms-fieldset">
|
||||
<!--四种协议请求内容-->
|
||||
<slot name="request"></slot>
|
||||
<!--其他模版内容,比如断言,提取等-->
|
||||
<slot></slot>
|
||||
</div>
|
||||
</el-collapse-transition>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<!--四种协议执行结果内容-->
|
||||
<slot name="result"></slot>
|
||||
</div>
|
||||
</el-collapse-transition>
|
||||
</div>
|
||||
|
||||
</el-card>
|
||||
|
|
|
@ -27,48 +27,58 @@
|
|||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<customize-req-info :is-customize-req="isCustomizeReq" :request="request"/>
|
||||
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
<ms-api-request-form :isShowEnable="true" :referenced="true" :headers="request.headers " :request="request"
|
||||
v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/>
|
||||
<esb-definition v-xpack :request="request" :showScript="false" v-if="this.showXpackCompnent&&request.esbDataStruct!=null" ref="esbDefinition"/>
|
||||
<ms-tcp-basis-parameters :request="request" v-if="(request.protocol==='TCP'|| request.type==='TCPSampler')&&request.esbDataStruct==null " :showScript="false"/>
|
||||
|
||||
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'"
|
||||
:showScript="false"/>
|
||||
<ms-dubbo-basis-parameters :request="request"
|
||||
v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"
|
||||
<!--请求内容-->
|
||||
<template v-slot:request>
|
||||
<customize-req-info :is-customize-req="isCustomizeReq" :request="request"/>
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
<ms-api-request-form v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"
|
||||
:isShowEnable="true"
|
||||
:referenced="true"
|
||||
:headers="request.headers "
|
||||
:request="request"/>
|
||||
<esb-definition v-if="showXpackCompnent&&request.esbDataStruct!=null"
|
||||
v-xpack
|
||||
:request="request"
|
||||
:showScript="false"
|
||||
ref="esbDefinition"/>
|
||||
<ms-tcp-basis-parameters v-if="(request.protocol==='TCP'|| request.type==='TCPSampler')&&request.esbDataStruct==null "
|
||||
:request="request"
|
||||
:showScript="false"/>
|
||||
|
||||
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
|
||||
<div v-if="request.result">
|
||||
<el-tabs v-model="request.activeName" closable class="ms-tabs">
|
||||
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in request.result.scenarios" :key="index">
|
||||
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
|
||||
<api-response-component v-if="result.name===request.name" :result="result"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
<div v-else-if="showXpackCompnent&&request.backEsbDataStruct != null">
|
||||
<esb-definition-response :currentProtocol="request.protocol" :request="request" :is-api-component="false"
|
||||
:show-options-button="false" :show-header="true" :result="request.requestResult"/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult"/>
|
||||
</div>
|
||||
|
||||
<!-- 保存操作 -->
|
||||
<el-button type="primary" size="small" class="ms-btn-flot" @click="saveTestCase(item)"
|
||||
v-if="!request.referenced">
|
||||
{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
<ms-sql-basis-parameters v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'"
|
||||
:request="request"
|
||||
:showScript="false"/>
|
||||
<ms-dubbo-basis-parameters v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"
|
||||
:request="request"
|
||||
:showScript="false"/>
|
||||
</template>
|
||||
<!-- 执行结果内容 -->
|
||||
<template v-slot:result>
|
||||
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
|
||||
<div v-if="request.result">
|
||||
<el-tabs v-model="request.activeName" closable class="ms-tabs">
|
||||
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in request.result.scenarios" :key="index">
|
||||
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
|
||||
<api-response-component v-if="result.name===request.name" :result="result"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
<div v-else-if="showXpackCompnent&&request.backEsbDataStruct != null">
|
||||
<esb-definition-response :currentProtocol="request.protocol" :request="request" :is-api-component="false"
|
||||
:show-options-button="false" :show-header="true" :result="request.requestResult"/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult"/>
|
||||
</div>
|
||||
<!-- 保存操作 -->
|
||||
<el-button type="primary" size="small" class="ms-btn-flot" @click="saveTestCase(item)" v-if="!request.referenced">
|
||||
{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</api-base-component>
|
||||
<ms-run :debug="true" :reportId="reportId" :run-data="runData" :env-map="envMap"
|
||||
@runRefresh="runRefresh" ref="runTest"/>
|
||||
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -361,6 +361,7 @@ export default {
|
|||
apiShowArray:[],//浏览器要渲染的api信息集合
|
||||
needAsyncSelect: false, //是否需要异步查询api详细数据做展现。只有本次要展示的数据总量大于maxCompnentSize时为true
|
||||
currentApiIndexInApiShowArray: 0,//当前主要展示的api信息在apiShowArray的索引
|
||||
clickStepFlag:false,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
@ -461,12 +462,6 @@ export default {
|
|||
if (this.apiInfoArray.length > 0) {
|
||||
this.checkApiInfoNode(this.apiStepIndex,true);
|
||||
}
|
||||
//拼接body展现数据
|
||||
// for(let dataIndex = 0; dataIndex < this.maxCompnentSize; dataIndex ++){
|
||||
// if(dataIndex < response.data.length){
|
||||
// this.apiShowArray.push(response.data[dataIndex]);
|
||||
// }
|
||||
// }
|
||||
if(response.data.length > this.maxCompnentSize){
|
||||
this.needAsyncSelect = true;
|
||||
}else{
|
||||
|
@ -629,66 +624,65 @@ export default {
|
|||
this.$message.error(this.$t('api_report.error'));
|
||||
},
|
||||
handleScroll(){
|
||||
//apiDocInfoDiv的总高度,是(每个item的高度+20)数量
|
||||
let apiDocDivScrollTop = this.$refs.apiDocInfoDiv.scrollTop;
|
||||
let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight;
|
||||
let scrolledHeigh = apiDocDivScrollTop+apiDocDivClientTop;
|
||||
let lastIndex = 0;
|
||||
for (let index = 0; index < this.apiShowArray.length; index++) {
|
||||
//判断移动到了第几个元素. 公式: 移动过的高度+页面显示高度-第index子元素的高度(含20px)>0 的 index最大值
|
||||
if(scrolledHeigh>0){
|
||||
lastIndex = index;
|
||||
let itemHeight = this.$refs.apiDocInfoDivItem[index].offsetHeight+10;
|
||||
scrolledHeigh = scrolledHeigh - itemHeight;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let names = "";
|
||||
for(let i = 0;i<this.apiShowArray.length;i++){
|
||||
names += this.apiShowArray[i].name+";";
|
||||
}
|
||||
if(lastIndex < this.currentApiIndexInApiShowArray){
|
||||
//上移
|
||||
if(this.needAsyncSelect){
|
||||
//进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据,
|
||||
//可得: apiStepIndex-1- 2 < apiInfoArray,需要添加数据
|
||||
let dataIndex = this.apiStepIndex -3;
|
||||
if(dataIndex >= 0){
|
||||
let apiInfo = this.apiInfoArray[dataIndex];
|
||||
this.apiShowArray.unshift(apiInfo);
|
||||
if(!this.clickStepFlag){
|
||||
//apiDocInfoDiv的总高度,是(每个item的高度+20)数量
|
||||
let apiDocDivScrollTop = this.$refs.apiDocInfoDiv.scrollTop;
|
||||
let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight;
|
||||
let scrolledHeigh = apiDocDivScrollTop+apiDocDivClientTop;
|
||||
let lastIndex = 0;
|
||||
for (let index = 0; index < this.apiShowArray.length; index++) {
|
||||
//判断移动到了第几个元素. 公式: 移动过的高度+页面显示高度-第index子元素的高度(含20px)>0 的 index最大值
|
||||
if(scrolledHeigh>0){
|
||||
lastIndex = index;
|
||||
let itemHeight = this.$refs.apiDocInfoDivItem[index].offsetHeight+10;
|
||||
scrolledHeigh = scrolledHeigh - itemHeight;
|
||||
}else{
|
||||
this.currentApiIndexInApiShowArray--;
|
||||
}
|
||||
|
||||
if(this.apiShowArray.length > (this.currentApiIndexInApiShowArray+3)){
|
||||
this.apiShowArray.pop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.apiStepIndex --;
|
||||
}else if(lastIndex > this.currentApiIndexInApiShowArray){
|
||||
//下滚
|
||||
if(this.needAsyncSelect){
|
||||
//进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据,
|
||||
//可得: apiStepIndex+1+ 2 < apiInfoArray,需要添加数据
|
||||
let dataIndex = this.apiStepIndex +3;
|
||||
if(dataIndex < this.apiInfoArray.length){
|
||||
let apiInfo = this.apiInfoArray[dataIndex];
|
||||
this.apiShowArray.push(apiInfo);
|
||||
}
|
||||
|
||||
if(this.apiShowArray.length <= this.maxCompnentSize){
|
||||
//判断currentApiIndexInApiShowArray 是否需要添加,以及是否需要删除第一个元素
|
||||
this.currentApiIndexInApiShowArray++;
|
||||
}else{
|
||||
this.apiShowArray.shift();
|
||||
let itemHeight = this.$refs.apiDocInfoDivItem[0].offsetHeight+10;
|
||||
this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivScrollTop-itemHeight);
|
||||
if(lastIndex < this.currentApiIndexInApiShowArray){
|
||||
//上移
|
||||
if(this.needAsyncSelect){
|
||||
//进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据,
|
||||
//可得: apiStepIndex-1- 2 < apiInfoArray,需要添加数据
|
||||
let dataIndex = this.apiStepIndex -3;
|
||||
if(dataIndex >= 0){
|
||||
let apiInfo = this.apiInfoArray[dataIndex];
|
||||
this.apiShowArray.unshift(apiInfo);
|
||||
}else{
|
||||
this.currentApiIndexInApiShowArray--;
|
||||
}
|
||||
|
||||
if(this.apiShowArray.length > (this.currentApiIndexInApiShowArray+3)){
|
||||
this.apiShowArray.pop();
|
||||
}
|
||||
}
|
||||
this.apiStepIndex --;
|
||||
}else if(lastIndex > this.currentApiIndexInApiShowArray){
|
||||
//下滚
|
||||
if(this.needAsyncSelect){
|
||||
//进行判断:是否还需要为apiShowArray 增加数据。 由于在当前数据前后最多展现2条数据,
|
||||
//可得: apiStepIndex+1+ 2 < apiInfoArray,需要添加数据
|
||||
let dataIndex = this.apiStepIndex +3;
|
||||
if(dataIndex < this.apiInfoArray.length){
|
||||
let apiInfo = this.apiInfoArray[dataIndex];
|
||||
this.apiShowArray.push(apiInfo);
|
||||
}
|
||||
|
||||
if(this.apiShowArray.length <= this.maxCompnentSize){
|
||||
//判断currentApiIndexInApiShowArray 是否需要添加,以及是否需要删除第一个元素
|
||||
this.currentApiIndexInApiShowArray++;
|
||||
}else{
|
||||
this.apiShowArray.shift();
|
||||
let itemHeight = this.$refs.apiDocInfoDivItem[0].offsetHeight+10;
|
||||
this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivScrollTop-itemHeight);
|
||||
}
|
||||
}
|
||||
this.apiStepIndex ++;
|
||||
}
|
||||
this.apiStepIndex ++;
|
||||
}
|
||||
this.clickStepFlag = false;
|
||||
},
|
||||
redirectScroll(){
|
||||
//滚动条跳转:将滚动条下拉到显示对应对api接口的位置
|
||||
|
@ -700,6 +694,7 @@ export default {
|
|||
itemHeightCount+=itemHeight;
|
||||
}
|
||||
}
|
||||
this.clickStepFlag = true;
|
||||
this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivClientTop+itemHeightCount);
|
||||
},
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2115bd28a90854d2b6276a90878934715498c584
|
||||
Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd
|
Loading…
Reference in New Issue