fix(接口测试): 修复因dao层变动导致的程序报错

修复因dao层变动导致的程序报错
This commit is contained in:
song-tianyang 2022-08-25 16:30:11 +08:00 committed by 建国
parent 29e0f13a2d
commit f3e1a74e2f
1 changed files with 23 additions and 6 deletions

View File

@ -19,9 +19,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author song.tianyang
@ -57,8 +57,18 @@ public class ShareInfoController {
if (request.getApiIdList() != null) {
//要根据ids的顺序进行返回排序
List<ApiDefinitionWithBLOBs> apiModels = apiDefinitionService.getBLOBs(request.getApiIdList());
Map<String, ApiDefinitionWithBLOBs> apiModelMaps = apiModels.stream().collect(Collectors.toMap(ApiDefinitionWithBLOBs::getId, a -> a, (k1, k2) -> k1));
Map<String, User> userIdMap = userService.queryName();
Map<String, ApiDefinitionWithBLOBs> apiModelMaps = new HashMap<>();
List<String> userIdList = new ArrayList<>();
apiModels.forEach(item -> {
apiModelMaps.put(item.getId(), item);
if (!userIdList.contains(item.getUserId())) {
userIdList.add(item.getUserId());
}
if (!userIdList.contains(item.getCreateUser())) {
userIdList.add(item.getCreateUser());
}
});
Map<String, User> userIdMap = userService.getUserIdMapByIds(userIdList);
for (String id : request.getApiIdList()) {
ApiDefinitionWithBLOBs model = apiModelMaps.get(id);
if (model == null) {
@ -78,7 +88,14 @@ public class ShareInfoController {
ApiDefinitionWithBLOBs apiModel = apiDefinitionService.getBLOBs(id);
ApiDocumentInfoDTO returnDTO = new ApiDocumentInfoDTO();
try {
Map<String, User> userIdMap = userService.queryName();
List<String> userIdList = new ArrayList<>();
if (!userIdList.contains(apiModel.getUserId())) {
userIdList.add(apiModel.getUserId());
}
if (!userIdList.contains(apiModel.getCreateUser())) {
userIdList.add(apiModel.getCreateUser());
}
Map<String, User> userIdMap = userService.getUserIdMapByIds(userIdList);
returnDTO = shareInfoService.conversionModelToDTO(apiModel, userIdMap);
} catch (Exception e) {
LogUtil.error(e);