fix: 修复接口定义-接口列表-文档-仅选中get请求接口-按更新时间从前到后显示,选中某个接口后,焦点不是选中的接口的问题

修复接口定义-接口列表-文档-仅选中get请求接口-按更新时间从前到后显示,选中某个接口后,焦点不是选中的接口的问题
This commit is contained in:
song.tianyang 2021-03-24 20:18:36 +08:00
parent 27e405fde5
commit c90ab047bb
3 changed files with 70 additions and 66 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<>();
if(request.getApiIdList() != null){
//要根据ids的顺序进行返回排序
List<ApiDefinitionWithBLOBs> apiModels = apiDefinitionService.getBLOBs(request.getApiIdList()); List<ApiDefinitionWithBLOBs> apiModels = apiDefinitionService.getBLOBs(request.getApiIdList());
for (ApiDefinitionWithBLOBs apiModel : apiModels) { Map<String,ApiDefinitionWithBLOBs> apiModelMaps = apiModels.stream().collect(Collectors.toMap(ApiDefinitionWithBLOBs :: getId,a->a,(k1,k2)->k1));
try{ for(String id : request.getApiIdList()){
ApiDocumentInfoDTO returnDTO = apiDocumentService.conversionModelToDTO(apiModel); 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

@ -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

@ -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,6 +624,7 @@ export default {
this.$message.error(this.$t('api_report.error')); this.$message.error(this.$t('api_report.error'));
}, },
handleScroll(){ handleScroll(){
if(!this.clickStepFlag){
//apiDocInfoDiv(item+20) //apiDocInfoDiv(item+20)
let apiDocDivScrollTop = this.$refs.apiDocInfoDiv.scrollTop; let apiDocDivScrollTop = this.$refs.apiDocInfoDiv.scrollTop;
let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight; let apiDocDivClientTop = this.$refs.apiDocInfoDiv.clientHeight;
@ -645,10 +641,6 @@ export default {
} }
} }
let names = "";
for(let i = 0;i<this.apiShowArray.length;i++){
names += this.apiShowArray[i].name+";";
}
if(lastIndex < this.currentApiIndexInApiShowArray){ if(lastIndex < this.currentApiIndexInApiShowArray){
// //
if(this.needAsyncSelect){ if(this.needAsyncSelect){
@ -689,6 +681,8 @@ export default {
} }
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);
}, },