fix(接口测试): 修复选择版本后模块树没有刷新的问题
This commit is contained in:
parent
94c4e591ac
commit
57bccc46a6
|
@ -25,10 +25,17 @@ public class ApiModuleController {
|
|||
|
||||
@GetMapping("/list/{projectId}/{protocol}")
|
||||
public List<ApiModuleDTO> getNodeByProjectId(@PathVariable String projectId, @PathVariable String protocol) {
|
||||
// checkPermissionService.checkProjectOwner(projectId);
|
||||
String userId = SessionUtils.getUserId();
|
||||
ApiDefinitionDefaultApiTypeUtil.addUserSelectApiType(userId, protocol);
|
||||
return apiModuleService.getNodeTreeByProjectId(projectId, protocol);
|
||||
return apiModuleService.getNodeTreeByProjectId(projectId, protocol, null);
|
||||
}
|
||||
|
||||
@GetMapping("/list/{projectId}/{protocol}/{versionId}")
|
||||
public List<ApiModuleDTO> getNodeByProjectId(@PathVariable String projectId, @PathVariable String protocol,
|
||||
@PathVariable String versionId) {
|
||||
String userId = SessionUtils.getUserId();
|
||||
ApiDefinitionDefaultApiTypeUtil.addUserSelectApiType(userId, protocol);
|
||||
return apiModuleService.getNodeTreeByProjectId(projectId, protocol, versionId);
|
||||
}
|
||||
|
||||
@GetMapping("/trashCount/{projectId}/{protocol}")
|
||||
|
|
|
@ -48,13 +48,6 @@ public class ApiDefinitionImportUtil {
|
|||
return "/" + path;
|
||||
}
|
||||
|
||||
public static ApiModule getNodeTree(String projectId) {
|
||||
ApiModuleService apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
|
||||
List<ApiModuleDTO> nodeTrees = apiModuleService.getNodeTreeByProjectId(projectId, RequestType.HTTP);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ApiModule buildModule(ApiModule parentModule, String name, String projectId) {
|
||||
ApiModuleService apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
|
||||
ApiModule module;
|
||||
|
|
|
@ -2,7 +2,10 @@ package io.metersphere.api.service;
|
|||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import io.metersphere.api.dto.definition.ApiModuleDTO;
|
||||
import io.metersphere.api.dto.definition.DragModuleRequest;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ApiModuleMapper;
|
||||
|
@ -66,9 +69,10 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
public ApiModule get(String id) {
|
||||
return apiModuleMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
public List<ApiModuleDTO> getNodeTreeByProjectId(String projectId, String protocol) {
|
||||
|
||||
public List<ApiModuleDTO> getNodeTreeByProjectId(String projectId, String protocol, String versionId) {
|
||||
// 判断当前项目下是否有默认模块,没有添加默认模块
|
||||
this.getDefaultNode(projectId,protocol);
|
||||
this.getDefaultNode(projectId, protocol);
|
||||
List<ApiModuleDTO> apiModules = extApiModuleMapper.getNodeTreeByProjectId(projectId, protocol);
|
||||
ApiDefinitionRequest request = new ApiDefinitionRequest();
|
||||
request.setProjectId(projectId);
|
||||
|
@ -95,21 +99,24 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
moduleIds = this.nodeList(apiModules, node.getId(), moduleIds);
|
||||
moduleIds.add(node.getId());
|
||||
for (String moduleId : moduleIds) {
|
||||
if(!allModuleIdList.contains(moduleId)){
|
||||
if (!allModuleIdList.contains(moduleId)) {
|
||||
allModuleIdList.add(moduleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
request.setModuleIds(allModuleIdList);
|
||||
List<Map<String,Object>> moduleCountList = extApiDefinitionMapper.moduleCountByCollection(request);
|
||||
Map<String,Integer> moduleCountMap = this.parseModuleCountList(moduleCountList);
|
||||
if (StringUtils.isNotBlank(versionId)) {
|
||||
request.setVersionId(versionId);
|
||||
}
|
||||
List<Map<String, Object>> moduleCountList = extApiDefinitionMapper.moduleCountByCollection(request);
|
||||
Map<String, Integer> moduleCountMap = this.parseModuleCountList(moduleCountList);
|
||||
apiModules.forEach(node -> {
|
||||
List<String> moduleIds = new ArrayList<>();
|
||||
moduleIds = this.nodeList(apiModules, node.getId(), moduleIds);
|
||||
moduleIds.add(node.getId());
|
||||
int countNum = 0;
|
||||
for (String moduleId : moduleIds) {
|
||||
if(moduleCountMap.containsKey(moduleId)){
|
||||
if (moduleCountMap.containsKey(moduleId)) {
|
||||
countNum += moduleCountMap.get(moduleId).intValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
:type="'edit'"
|
||||
page-source="definition"
|
||||
:total='total'
|
||||
:current-version="currentVersion"
|
||||
ref="nodeTree"/>
|
||||
</ms-aside-container>
|
||||
|
||||
|
|
|
@ -46,26 +46,26 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsAddBasisApi from "../basis/AddBasisApi";
|
||||
import SelectMenu from "../../../../track/common/SelectMenu";
|
||||
import {OPTIONS} from "../../model/JsonData";
|
||||
import ApiImport from "../import/ApiImport";
|
||||
import MsNodeTree from "../../../../track/common/NodeTree";
|
||||
import ApiModuleHeader from "./ApiModuleHeader";
|
||||
import {buildTree} from "../../model/NodeTree";
|
||||
import {getCurrentProjectID} from "@/common/js/utils";
|
||||
import MsAddBasisApi from "../basis/AddBasisApi";
|
||||
import SelectMenu from "../../../../track/common/SelectMenu";
|
||||
import {OPTIONS} from "../../model/JsonData";
|
||||
import ApiImport from "../import/ApiImport";
|
||||
import MsNodeTree from "../../../../track/common/NodeTree";
|
||||
import ApiModuleHeader from "./ApiModuleHeader";
|
||||
import {buildTree} from "../../model/NodeTree";
|
||||
import {getCurrentProjectID} from "@/common/js/utils";
|
||||
|
||||
export default {
|
||||
name: 'MsApiModule',
|
||||
components: {
|
||||
ApiModuleHeader,
|
||||
MsNodeTree,
|
||||
MsAddBasisApi,
|
||||
SelectMenu,
|
||||
ApiImport
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
export default {
|
||||
name: 'MsApiModule',
|
||||
components: {
|
||||
ApiModuleHeader,
|
||||
MsNodeTree,
|
||||
MsAddBasisApi,
|
||||
SelectMenu,
|
||||
ApiImport
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
openType: 'relevance',
|
||||
result: {},
|
||||
condition: {
|
||||
|
@ -81,14 +81,15 @@
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
},
|
||||
showOperator: Boolean,
|
||||
planId: String,
|
||||
currentVersion: String,
|
||||
relevanceProjectId: String,
|
||||
reviewId: String,
|
||||
pageSource:String,
|
||||
pageSource: String,
|
||||
total: Number,
|
||||
options: {
|
||||
type: Array,
|
||||
|
@ -165,9 +166,11 @@
|
|||
if (this.isPlanModel) {
|
||||
url = '/api/module/list/plan/' + this.planId + '/' + this.condition.protocol;
|
||||
} else if (this.isRelevanceModel) {
|
||||
url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol;
|
||||
url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol +
|
||||
(this.currentVersion ? '/' + this.currentVersion : '');
|
||||
} else {
|
||||
url = "/api/module/list/" + (projectId ? projectId : this.projectId) + "/" + this.condition.protocol;
|
||||
url = "/api/module/list/" + (projectId ? projectId : this.projectId) + "/" + this.condition.protocol +
|
||||
(this.currentVersion ? '/' + this.currentVersion : '');
|
||||
if (!this.projectId) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue