diff --git a/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetGroupManage.java b/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetGroupManage.java index 30b570fd01..3abbef8e48 100644 --- a/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetGroupManage.java +++ b/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetGroupManage.java @@ -2,8 +2,6 @@ package io.dataease.dataset.manage; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.fasterxml.jackson.core.type.TypeReference; -import io.dataease.extensions.datasource.dto.DatasetTableDTO; -import io.dataease.extensions.datasource.dto.DatasourceDTO; import io.dataease.api.dataset.union.DatasetGroupInfoDTO; import io.dataease.api.dataset.union.UnionDTO; import io.dataease.api.dataset.vo.DataSetBarVO; @@ -21,6 +19,8 @@ import io.dataease.datasource.dao.auto.entity.CoreDatasource; import io.dataease.datasource.dao.auto.mapper.CoreDatasourceMapper; import io.dataease.engine.constant.ExtFieldConstant; import io.dataease.exception.DEException; +import io.dataease.extensions.datasource.dto.DatasetTableDTO; +import io.dataease.extensions.datasource.dto.DatasourceDTO; import io.dataease.extensions.view.dto.DatasetTableFieldDTO; import io.dataease.extensions.view.dto.SqlVariableDetails; import io.dataease.i18n.Translator; @@ -378,6 +378,42 @@ public class DatasetGroupManage { return get(id, type); } + public DatasetGroupInfoDTO getDetail(Long id) throws Exception { + CoreDatasetGroup coreDatasetGroup = coreDatasetGroupMapper.selectById(id); + if (coreDatasetGroup == null) { + return null; + } + DatasetGroupInfoDTO dto = new DatasetGroupInfoDTO(); + BeanUtils.copyBean(dto, coreDatasetGroup); + // get creator + String userName = coreUserManage.getUserName(Long.valueOf(dto.getCreateBy())); + if (StringUtils.isNotBlank(userName)) { + dto.setCreator(userName); + } + String updateUserName = coreUserManage.getUserName(Long.valueOf(dto.getUpdateBy())); + if (StringUtils.isNotBlank(updateUserName)) { + dto.setUpdater(updateUserName); + } + dto.setUnionSql(null); + if (StringUtils.equalsIgnoreCase(dto.getNodeType(), "dataset")) { + List unionDTOList = JsonUtil.parseList(coreDatasetGroup.getInfo(), new TypeReference<>() { + }); + dto.setUnion(unionDTOList); + + // 获取field + List dsFields = datasetTableFieldManage.selectByDatasetGroupId(id); + List allFields = dsFields.stream().map(ele -> { + DatasetTableFieldDTO datasetTableFieldDTO = new DatasetTableFieldDTO(); + BeanUtils.copyBean(datasetTableFieldDTO, ele); + datasetTableFieldDTO.setFieldShortName(ele.getDataeaseName()); + return datasetTableFieldDTO; + }).collect(Collectors.toList()); + + dto.setAllFields(allFields); + } + return dto; + } + public DatasetGroupInfoDTO get(Long id, String type) throws Exception { CoreDatasetGroup coreDatasetGroup = coreDatasetGroupMapper.selectById(id); if (coreDatasetGroup == null) { diff --git a/core/core-backend/src/main/java/io/dataease/dataset/server/DatasetTreeServer.java b/core/core-backend/src/main/java/io/dataease/dataset/server/DatasetTreeServer.java index 903d1e7b8d..05815fd531 100644 --- a/core/core-backend/src/main/java/io/dataease/dataset/server/DatasetTreeServer.java +++ b/core/core-backend/src/main/java/io/dataease/dataset/server/DatasetTreeServer.java @@ -2,13 +2,13 @@ package io.dataease.dataset.server; import io.dataease.api.dataset.DatasetTreeApi; import io.dataease.api.dataset.dto.DatasetNodeDTO; -import io.dataease.extensions.datasource.dto.DatasetTableDTO; -import io.dataease.extensions.view.dto.SqlVariableDetails; import io.dataease.api.dataset.union.DatasetGroupInfoDTO; import io.dataease.api.dataset.vo.DataSetBarVO; import io.dataease.constant.LogOT; import io.dataease.constant.LogST; import io.dataease.dataset.manage.DatasetGroupManage; +import io.dataease.extensions.datasource.dto.DatasetTableDTO; +import io.dataease.extensions.view.dto.SqlVariableDetails; import io.dataease.log.DeLog; import io.dataease.model.BusiNodeRequest; import io.dataease.model.BusiNodeVO; @@ -72,7 +72,7 @@ public class DatasetTreeServer implements DatasetTreeApi { @Override public DatasetGroupInfoDTO details(Long id) throws Exception { - return datasetGroupManage.get(id, null); + return datasetGroupManage.getDetail(id); } @Override