fix(接口测试): 修复接口测试文档中某版本没有接口会出现sql错误的情况

--bug=1016792 --user=宋天阳 【接口测试】接口文档-按版本筛选-报sql错误
https://www.tapd.cn/55049933/s/1244287
This commit is contained in:
song-tianyang 2022-09-17 12:49:32 +08:00 committed by 刘瑞斌
parent a16a245bb8
commit bb3bea2b8d
2 changed files with 22 additions and 19 deletions

View File

@ -77,25 +77,28 @@ public class ShareInfoService {
apiDocumentInfoDTOS = this.findApiDocumentSimpleInfoByRequest(apiDocumentRequest, goPage, pageSize); apiDocumentInfoDTOS = this.findApiDocumentSimpleInfoByRequest(apiDocumentRequest, goPage, pageSize);
} }
PageHelper.clearPage(); PageHelper.clearPage();
List<ApiDocumentInfoDTO> returnList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(apiDocumentInfoDTOS)) {
List<String> apiModuleIdList = new ArrayList<>();
LogUtil.info("查找模块相关信息");
List<String> userIdList = new ArrayList<>();
apiDocumentInfoDTOS.forEach(item -> {
if (StringUtils.isNotBlank(item.getModuleId()) && !apiModuleIdList.contains(item.getModuleId())) {
apiModuleIdList.add(item.getModuleId());
if (!userIdList.contains(item.getUserId())) {
userIdList.add(item.getUserId());
}
if (!userIdList.contains(item.getCreateUser())) {
userIdList.add(item.getCreateUser());
}
}
});
Map<String, User> seletedUserMap = userService.getUserIdMapByIds(userIdList);
Map<String, String> moduleNameMap = apiModuleService.getApiModuleNameDicByIds(apiModuleIdList);
LogUtil.info("开始遍历组装数据");
returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, seletedUserMap, moduleNameMap);
}
List<String> apiModuleIdList = new ArrayList<>();
LogUtil.info("查找模块相关信息");
List<String> userIdList = new ArrayList<>();
apiDocumentInfoDTOS.forEach(item -> {
if (StringUtils.isNotBlank(item.getModuleId()) && !apiModuleIdList.contains(item.getModuleId())) {
apiModuleIdList.add(item.getModuleId());
if (!userIdList.contains(item.getUserId())) {
userIdList.add(item.getUserId());
}
if (!userIdList.contains(item.getCreateUser())) {
userIdList.add(item.getCreateUser());
}
}
});
Map<String, User> seletedUserMap = userService.getUserIdMapByIds(userIdList);
Map<String, String> moduleNameMap = apiModuleService.getApiModuleNameDicByIds(apiModuleIdList);
LogUtil.info("开始遍历组装数据");
List<ApiDocumentInfoDTO> returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, seletedUserMap, moduleNameMap);
return PageUtils.setPageInfo(page, returnList); return PageUtils.setPageInfo(page, returnList);
} }

View File

@ -34,7 +34,7 @@
</select> </select>
<select id="selectNameByIds" resultType="io.metersphere.api.dto.definition.ApiModuleDTO"> <select id="selectNameByIds" resultType="io.metersphere.api.dto.definition.ApiModuleDTO">
SELECT name SELECT id,name
FROM api_module FROM api_module
WHERE id IN WHERE id IN
<foreach collection="ids" item="id" separator="," open="(" close=")"> <foreach collection="ids" item="id" separator="," open="(" close=")">