refactor: 智能问数优化 (#17228)

This commit is contained in:
王嘉豪
2025-10-20 18:24:12 +08:00
committed by GitHub
parent e05ade7bab
commit b792f85cfa
8 changed files with 132 additions and 21 deletions

View File

@@ -57,7 +57,6 @@ 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}
"""
)
@@ -120,8 +119,6 @@ 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);

View File

@@ -179,11 +179,17 @@ 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;