融合服务接口优化

This commit is contained in:
lizhicheng 2022-08-10 19:43:17 +08:00
parent 65dc6fae91
commit a01ecfc0fb
1 changed files with 10 additions and 6 deletions

View File

@ -112,9 +112,8 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
}
params.put("userId", SecurityUser.getUserId());
List<TbFuseDTO> dtoList = baseDao.getFuseDTOList(params);
Map<String, Map<String, Object>> dataResourceList=getDataResource();
dtoList.forEach(dto -> {
dto.setFuseResourceList(getFuseResourceByFuseId(dto.getId(), dataResourceList));
dto.setFuseResourceList(getFuseResourceByFuseId(dto.getId()));
dto.setFuseAttrList(getAttrByFuseId(dto.getId()));
});
List<TbFuseDTO> result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList());
@ -130,7 +129,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
TbFuseDTO fuseDTO = new TbFuseDTO();
BeanUtils.copyProperties(fuseEntity, fuseDTO);
fuseDTO.setFuseAttrList(getAttrByFuseId(id));
fuseDTO.setFuseResourceList(getFuseResourceByFuseId(id, getDataResource()));
fuseDTO.setFuseResourceList(getFuseResourceByFuseId(id));
setCollection(fuseDTO);
return fuseDTO;
}
@ -175,17 +174,22 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
return result;
}
private List<TbFuseResourceDTO> getFuseResourceByFuseId(Long fuseId, Map<String, Map<String, Object>> dataResourceMap) {
private List<TbFuseResourceDTO> getFuseResourceByFuseId(Long fuseId) {
Map<String, Map<String, Object>> dataResourceMap = new HashMap<>();
List<TbFuseResourceDTO> result = new ArrayList();
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("fuse_id", fuseId);
List<TbFuseResourceEntity> list = fuseResourceDao.selectList(wrapper);
list.stream().filter(index -> index.getType() != null).collect(Collectors.groupingBy(TbFuseResourceEntity::getType)).forEach((type, value) -> {
Map<String, List<TbFuseResourceEntity>> resourceMap = list.stream().filter(index -> index.getType() != null).collect(Collectors.groupingBy(TbFuseResourceEntity::getType));
if (resourceMap.containsKey("数据资源")) {
dataResourceMap.putAll(getDataResource());
}
resourceMap.forEach((type, value) -> {
if ("组件服务".equals(type)) {
result.addAll(value.stream().map(attr -> {
TbFuseResourceDTO dto = new TbFuseResourceDTO();
BeanUtils.copyProperties(attr, dto);
ResourceDTO resourceDTO=resourceService.get(dto.getResourceId());
ResourceDTO resourceDTO = resourceService.get(dto.getResourceId());
resourceDTO.setDeptName(sysDeptService.get(resourceDTO.getDeptId()).getName());
dto.setResource(resourceDTO);
return dto;