mirror of
https://github.com/dataease/dataease.git
synced 2026-05-16 14:31:00 +08:00
refactor: 优化问数数据源查询 (#17242)
This commit is contained in:
@@ -57,6 +57,7 @@ public interface DataSetAssistantMapper {
|
||||
left join `core_dataset_table` cdt on cdg.id = cdt.dataset_group_id
|
||||
left join `core_dataset_table_field` cdtf on cdtf.dataset_group_id = cdg.id and (cdtf.dataset_table_id is NULL or cdtf.dataset_table_id = cdt.id)
|
||||
inner join `core_datasource` cd on cdt.datasource_id = cd.id
|
||||
where cdg.is_cross != 1 and (cd.STATUS IS NULL OR cd.STATUS != 'Error')
|
||||
${ew.customSqlSegment}
|
||||
"""
|
||||
)
|
||||
@@ -119,6 +120,8 @@ public interface DataSetAssistantMapper {
|
||||
INNER JOIN `core_dataset_group` cdg ON cdg.id = cdt.dataset_group_id
|
||||
AND cdg.is_cross != 1
|
||||
INNER JOIN `core_dataset_table_field` cdtf ON cdtf.dataset_group_id = cdg.id and (cdtf.dataset_table_id is NULL or cdtf.dataset_table_id = cdt.id)
|
||||
where not exists( select 1 from user_ds_permissions ds_p where cd.id = ds_p.resource_id )
|
||||
and not exists( select 1 from user_dg_permissions dg_p where cdg.id = dg_p.resource_id )
|
||||
${ew.customSqlSegment}
|
||||
""")
|
||||
List<Map<String, Object>> queryCommunity(@Param("ew") QueryWrapper queryWrapper);
|
||||
|
||||
@@ -13,7 +13,6 @@ import io.dataease.api.permissions.dataset.api.ColumnPermissionsApi;
|
||||
import io.dataease.api.permissions.dataset.dto.DataSetColumnPermissionsDTO;
|
||||
import io.dataease.api.permissions.dataset.dto.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.auth.bo.TokenUserBO;
|
||||
import io.dataease.chart.dao.auto.mapper.CoreChartViewMapper;
|
||||
import io.dataease.chart.dao.ext.mapper.ExtChartViewMapper;
|
||||
import io.dataease.commons.utils.EncryptUtils;
|
||||
import io.dataease.constant.ColumnPermissionConstants;
|
||||
@@ -71,9 +70,6 @@ public class DatasetSQLBotManage {
|
||||
@Resource
|
||||
private DataSetAssistantMapper dataSetAssistantMapper;
|
||||
|
||||
@Resource
|
||||
private ExtChartViewMapper extChartViewMapper;
|
||||
|
||||
@Resource
|
||||
private EngineManage engineManage;
|
||||
|
||||
@@ -101,6 +97,9 @@ public class DatasetSQLBotManage {
|
||||
@Value("${dataease.sqlbot.log:false}")
|
||||
private boolean sqlbotApiLog;
|
||||
|
||||
@Resource
|
||||
private ExtChartViewMapper extChartViewMapper;
|
||||
|
||||
private String aesEncrypt(String text) {
|
||||
String iv = aesIv;
|
||||
int len = iv.length();
|
||||
@@ -153,11 +152,11 @@ public class DatasetSQLBotManage {
|
||||
return datasetRowPermissions.stream().collect(Collectors.groupingBy(DataSetRowPermissionsTreeDTO::getDatasetId));
|
||||
}
|
||||
|
||||
|
||||
public List<DataSQLBotDatasetVO> getDatasetList(String dvInfo){
|
||||
return extChartViewMapper.findDataSQLBotDatasetDvId(dvInfo);
|
||||
}
|
||||
|
||||
|
||||
public List<DataSQLBotAssistantVO> getDatasourceList(Long dsId, Long datasetId) {
|
||||
TokenUserBO user = Objects.requireNonNull(AuthUtils.getUser());
|
||||
Long oid = user.getDefaultOid();
|
||||
@@ -179,17 +178,11 @@ public class DatasetSQLBotManage {
|
||||
if (!isAdmin) {
|
||||
return null;
|
||||
}
|
||||
queryWrapper.eq("cdg.is_cross", 0)
|
||||
.and(wrapper -> wrapper.isNull("cd.STATUS").or().ne("cd.STATUS", "Error"));
|
||||
list = dataSetAssistantMapper.queryAll(queryWrapper);
|
||||
} else if (!model) {
|
||||
if (!isAdmin) {
|
||||
return null;
|
||||
}
|
||||
queryWrapper.apply("""
|
||||
not exists( select 1 from user_ds_permissions ds_p where cd.id = ds_p.resource_id )
|
||||
and not exists( select 1 from user_dg_permissions dg_p where cdg.id = dg_p.resource_id )
|
||||
""");
|
||||
list = dataSetAssistantMapper.queryCommunity(queryWrapper);
|
||||
} else {
|
||||
boolean isRootRole = isAdmin;
|
||||
|
||||
Reference in New Issue
Block a user