feat(SQL): 用户自己写SQL,将用户输入的SQL作为内部临时表处理

This commit is contained in:
junjie 2021-03-15 17:08:54 +08:00
parent d565385aca
commit 3a5921377f
2 changed files with 8 additions and 3 deletions

View File

@ -102,8 +102,13 @@ public class ChartViewService {
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(ds);
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(table.getInfo(), DataTableInfoDTO.class);
datasourceRequest.setTable(dataTableInfoDTO.getTable());
datasourceRequest.setQuery(getSQL(ds.getType(), dataTableInfoDTO.getTable(), xAxis, yAxis));
if (StringUtils.equalsIgnoreCase(table.getType(), "db")) {
datasourceRequest.setTable(dataTableInfoDTO.getTable());
datasourceRequest.setQuery(getSQL(ds.getType(), dataTableInfoDTO.getTable(), xAxis, yAxis));
} else if (StringUtils.equalsIgnoreCase(table.getType(), "sql")) {
datasourceRequest.setQuery(getSQL(ds.getType(), " (" + dataTableInfoDTO.getSql() + ") AS tmp ", xAxis, yAxis));
}
List<String[]> data = datasourceProvider.getData(datasourceRequest);
// todo 处理结果,目前做一个单系列图表后期图表组件再扩展

View File

@ -157,7 +157,7 @@ public class DataSetTableService {
datasourceRequest.setQuery(createQuerySQL(ds.getType(), table, fieldArray) + " LIMIT 0,10");// todo limit
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
String sql = dataTableInfoDTO.getSql();
datasourceRequest.setQuery(sql);// todo 因为编辑可能取消某些字段展示这里sql看看怎么处理
datasourceRequest.setQuery(createQuerySQL(ds.getType(), " (" + sql + ") AS tmp ", fieldArray));// todo 因为编辑可能取消某些字段展示这里sql看看怎么处理
}
List<String[]> data = new ArrayList<>();