Merge branch 'master' of github.com:metersphere/metersphere

This commit is contained in:
chenjianxing 2021-03-24 21:30:17 +08:00
commit d03976d8e1
10 changed files with 134 additions and 115 deletions

View File

@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author song.tianyang * @author song.tianyang
@ -39,13 +41,19 @@ public class ApiDocumentController {
@PostMapping("/selectApiInfoByParam") @PostMapping("/selectApiInfoByParam")
public List<ApiDocumentInfoDTO> selectApiInfoByParam(@RequestBody ApiDocumentRequest request) { public List<ApiDocumentInfoDTO> selectApiInfoByParam(@RequestBody ApiDocumentRequest request) {
List<ApiDocumentInfoDTO> returnList = new ArrayList<>(); List<ApiDocumentInfoDTO> returnList = new ArrayList<>();
List<ApiDefinitionWithBLOBs> apiModels = apiDefinitionService.getBLOBs(request.getApiIdList()); if(request.getApiIdList() != null){
for (ApiDefinitionWithBLOBs apiModel : apiModels) { //要根据ids的顺序进行返回排序
try{ List<ApiDefinitionWithBLOBs> apiModels = apiDefinitionService.getBLOBs(request.getApiIdList());
ApiDocumentInfoDTO returnDTO = apiDocumentService.conversionModelToDTO(apiModel); 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); returnList.add(returnDTO);
}catch (Exception e){
e.printStackTrace();
} }
} }
return returnList; return returnList;

View File

@ -201,7 +201,7 @@ public class MsLoopController extends MsTestElement {
jsr223PreProcessor.setName("循环超时处理"); jsr223PreProcessor.setName("循环超时处理");
jsr223PreProcessor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName()); jsr223PreProcessor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName());
jsr223PreProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); jsr223PreProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
jsr223PreProcessor.setProperty("cacheKey", "true"); /*jsr223PreProcessor.setProperty("cacheKey", "true");*/
jsr223PreProcessor.setProperty("scriptLanguage", "beanshell"); jsr223PreProcessor.setProperty("scriptLanguage", "beanshell");
jsr223PreProcessor.setProperty("script", script()); jsr223PreProcessor.setProperty("script", script());
hashTree.add(jsr223PreProcessor); hashTree.add(jsr223PreProcessor);

View File

@ -48,7 +48,7 @@ public class MsJSR223Processor extends MsTestElement {
processor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName()); processor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName());
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
processor.setProperty("cacheKey", "true"); /*processor.setProperty("cacheKey", "true");*/
processor.setProperty("scriptLanguage", this.getScriptLanguage()); processor.setProperty("scriptLanguage", this.getScriptLanguage());
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
processor.setProperty("scriptLanguage", "nashorn"); processor.setProperty("scriptLanguage", "nashorn");

View File

@ -42,7 +42,7 @@ public class MsJSR223PostProcessor extends MsTestElement {
} }
processor.setProperty(TestElement.TEST_CLASS, JSR223PostProcessor.class.getName()); processor.setProperty(TestElement.TEST_CLASS, JSR223PostProcessor.class.getName());
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
processor.setProperty("cacheKey", "true"); /*processor.setProperty("cacheKey", "true");*/
processor.setProperty("scriptLanguage", this.getScriptLanguage()); processor.setProperty("scriptLanguage", this.getScriptLanguage());
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
processor.setProperty("scriptLanguage", "nashorn"); processor.setProperty("scriptLanguage", "nashorn");

View File

@ -54,7 +54,7 @@ public class MsJSR223PreProcessor extends MsTestElement {
} }
processor.setProperty(TestElement.TEST_CLASS, JSR223PreProcessor.class.getName()); processor.setProperty(TestElement.TEST_CLASS, JSR223PreProcessor.class.getName());
processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); processor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
processor.setProperty("cacheKey", "true"); /*processor.setProperty("cacheKey", "true");*/
processor.setProperty("scriptLanguage", this.getScriptLanguage()); processor.setProperty("scriptLanguage", this.getScriptLanguage());
if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) { if (StringUtils.isNotEmpty(this.getScriptLanguage()) && this.getScriptLanguage().equals("nashornScript")) {
processor.setProperty("scriptLanguage", "nashorn"); processor.setProperty("scriptLanguage", "nashorn");

View File

@ -87,7 +87,7 @@ public class ApiDocumentService {
if (apiModel.getRequest() != null) { if (apiModel.getRequest() != null) {
JSONObject requestJsonObj = JSONObject.parseObject(apiModel.getRequest()); JSONObject requestJsonObj = JSONObject.parseObject(apiModel.getRequest());
//head赋值 //head赋值conversionModelToDTO
if (requestJsonObj.containsKey("headers")) { if (requestJsonObj.containsKey("headers")) {
JSONArray requestHeadDataArr = new JSONArray(); JSONArray requestHeadDataArr = new JSONArray();
//head赋值 //head赋值
@ -300,6 +300,7 @@ public class ApiDocumentService {
} }
} }
apiInfoDTO.setRequestPreviewData(previewJsonArray); apiInfoDTO.setRequestPreviewData(previewJsonArray);
apiInfoDTO.setSelectedFlag(true);
return apiInfoDTO; return apiInfoDTO;
} }

View File

@ -37,14 +37,19 @@
</div> </div>
<!--最大化不显示具体内容--> <!--最大化不显示具体内容-->
<div class="header" v-if="!isMax"> <div class="header" v-if="!isMax">
<fieldset :disabled="data.disabled" class="ms-fieldset"> <el-collapse-transition>
<el-collapse-transition> <div v-if="data.active && showCollapse" :draggable="draggable">
<div v-if="data.active && showCollapse" :draggable="draggable"> <el-divider></el-divider>
<el-divider></el-divider> <fieldset :disabled="data.disabled" class="ms-fieldset">
<!--四种协议请求内容-->
<slot name="request"></slot>
<!--其他模版内容比如断言提取等-->
<slot></slot> <slot></slot>
</div> </fieldset>
</el-collapse-transition> <!--四种协议执行结果内容-->
</fieldset> <slot name="result"></slot>
</div>
</el-collapse-transition>
</div> </div>
</el-card> </el-card>

View File

@ -27,48 +27,58 @@
</el-tooltip> </el-tooltip>
</template> </template>
<customize-req-info :is-customize-req="isCustomizeReq" :request="request"/> <!--请求内容-->
<template v-slot:request>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <customize-req-info :is-customize-req="isCustomizeReq" :request="request"/>
<ms-api-request-form :isShowEnable="true" :referenced="true" :headers="request.headers " :request="request" <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/> <ms-api-request-form 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"/> :isShowEnable="true"
<ms-tcp-basis-parameters :request="request" v-if="(request.protocol==='TCP'|| request.type==='TCPSampler')&&request.esbDataStruct==null " :showScript="false"/> :referenced="true"
:headers="request.headers "
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'" :request="request"/>
:showScript="false"/> <esb-definition v-if="showXpackCompnent&&request.esbDataStruct!=null"
<ms-dubbo-basis-parameters :request="request" v-xpack
v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :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"/> :showScript="false"/>
<ms-sql-basis-parameters v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'"
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p> :request="request"
<div v-if="request.result"> :showScript="false"/>
<el-tabs v-model="request.activeName" closable class="ms-tabs"> <ms-dubbo-basis-parameters v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in request.result.scenarios" :key="index"> :request="request"
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px"> :showScript="false"/>
<api-response-component v-if="result.name===request.name" :result="result"/> </template>
</div> <!-- 执行结果内容 -->
</el-tab-pane> <template v-slot:result>
</el-tabs> <p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
</div> <div v-if="request.result">
<div v-else-if="showXpackCompnent&&request.backEsbDataStruct != null"> <el-tabs v-model="request.activeName" closable class="ms-tabs">
<esb-definition-response :currentProtocol="request.protocol" :request="request" :is-api-component="false" <el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in request.result.scenarios" :key="index">
:show-options-button="false" :show-header="true" :result="request.requestResult"/> <div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
</div> <api-response-component v-if="result.name===request.name" :result="result"/>
<div v-else> </div>
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult"/> </el-tab-pane>
</div> </el-tabs>
</div>
<!-- 保存操作 --> <div v-else-if="showXpackCompnent&&request.backEsbDataStruct != null">
<el-button type="primary" size="small" class="ms-btn-flot" @click="saveTestCase(item)" <esb-definition-response :currentProtocol="request.protocol" :request="request" :is-api-component="false"
v-if="!request.referenced"> :show-options-button="false" :show-header="true" :result="request.requestResult"/>
{{ $t('commons.save') }} </div>
</el-button> <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> </api-base-component>
<ms-run :debug="true" :reportId="reportId" :run-data="runData" :env-map="envMap" <ms-run :debug="true" :reportId="reportId" :run-data="runData" :env-map="envMap"
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" ref="runTest"/>
</div> </div>
</template> </template>

View File

@ -361,6 +361,7 @@ export default {
apiShowArray:[],//api apiShowArray:[],//api
needAsyncSelect: false, //apimaxCompnentSizetrue needAsyncSelect: false, //apimaxCompnentSizetrue
currentApiIndexInApiShowArray: 0,//apiapiShowArray currentApiIndexInApiShowArray: 0,//apiapiShowArray
clickStepFlag:false,
} }
}, },
props: { props: {
@ -461,12 +462,6 @@ export default {
if (this.apiInfoArray.length > 0) { if (this.apiInfoArray.length > 0) {
this.checkApiInfoNode(this.apiStepIndex,true); 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){ if(response.data.length > this.maxCompnentSize){
this.needAsyncSelect = true; this.needAsyncSelect = true;
}else{ }else{
@ -629,66 +624,65 @@ export default {
this.$message.error(this.$t('api_report.error')); this.$message.error(this.$t('api_report.error'));
}, },
handleScroll(){ handleScroll(){
//apiDocInfoDiv(item+20) if(!this.clickStepFlag){
let apiDocDivScrollTop = this.$refs.apiDocInfoDiv.scrollTop; //apiDocInfoDiv(item+20)
let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight; let apiDocDivScrollTop = this.$refs.apiDocInfoDiv.scrollTop;
let scrolledHeigh = apiDocDivScrollTop+apiDocDivClientTop; let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight;
let lastIndex = 0; let scrolledHeigh = apiDocDivScrollTop+apiDocDivClientTop;
for (let index = 0; index < this.apiShowArray.length; index++) { let lastIndex = 0;
//. : +-index(20px)>0 index for (let index = 0; index < this.apiShowArray.length; index++) {
if(scrolledHeigh>0){ //. : +-index(20px)>0 index
lastIndex = index; if(scrolledHeigh>0){
let itemHeight = this.$refs.apiDocInfoDivItem[index].offsetHeight+10; lastIndex = index;
scrolledHeigh = scrolledHeigh - itemHeight; let itemHeight = this.$refs.apiDocInfoDivItem[index].offsetHeight+10;
}else{ scrolledHeigh = scrolledHeigh - itemHeight;
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);
}else{ }else{
this.currentApiIndexInApiShowArray--; break;
}
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){ if(lastIndex < this.currentApiIndexInApiShowArray){
//currentApiIndexInApiShowArray //
this.currentApiIndexInApiShowArray++; if(this.needAsyncSelect){
}else{ //apiShowArray 2
this.apiShowArray.shift(); // apiStepIndex-1- 2 < apiInfoArray
let itemHeight = this.$refs.apiDocInfoDivItem[0].offsetHeight+10; let dataIndex = this.apiStepIndex -3;
this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivScrollTop-itemHeight); 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(){ redirectScroll(){
//api //api
@ -700,6 +694,7 @@ export default {
itemHeightCount+=itemHeight; itemHeightCount+=itemHeight;
} }
} }
this.clickStepFlag = true;
this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivClientTop+itemHeightCount); this.$refs.apiDocInfoDiv.scrollTop = (apiDocDivClientTop+itemHeightCount);
}, },

@ -1 +1 @@
Subproject commit 2115bd28a90854d2b6276a90878934715498c584 Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd