fix(接口测试): 修复选择版本后模块树没有刷新的问题

This commit is contained in:
CaptainB 2022-01-24 15:59:00 +08:00 committed by song-tianyang
parent 33879ea23b
commit 469634f290
5 changed files with 50 additions and 39 deletions
backend/src/main/java/io/metersphere/api
frontend/src/business/components/api/definition

View File

@ -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}")

View File

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

View File

@ -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,7 +69,8 @@ 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);
List<ApiModuleDTO> apiModules = extApiModuleMapper.getNodeTreeByProjectId(projectId, protocol);
@ -101,6 +105,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
}
}
request.setModuleIds(allModuleIdList);
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 -> {

View File

@ -17,6 +17,7 @@
:type="'edit'"
page-source="definition"
:total='total'
:current-version="currentVersion"
ref="nodeTree"/>
</ms-aside-container>

View File

@ -81,11 +81,12 @@
isReadOnly: {
type: Boolean,
default() {
return false
return false;
}
},
showOperator: Boolean,
planId: String,
currentVersion: String,
relevanceProjectId: String,
reviewId: String,
pageSource: String,
@ -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;
}