forked from github/dataease
feat(仪表板): 文本下拉组件支持显示字段和排序字段设置
This commit is contained in:
parent
a073b58a5e
commit
c28443ec6b
@ -200,7 +200,7 @@ public class DatasetDataManage {
|
||||
// build query sql
|
||||
SQLMeta sqlMeta = new SQLMeta();
|
||||
Table2SQLObj.table2sqlobj(sqlMeta, null, "(" + sql + ")", crossDs);
|
||||
Field2SQLObj.field2sqlObj(sqlMeta, fields, crossDs, dsMap);
|
||||
Field2SQLObj.field2sqlObj(sqlMeta, fields, fields, crossDs, dsMap);
|
||||
WhereTree2Str.transFilterTrees(sqlMeta, rowPermissionsTree, fields, crossDs, dsMap);
|
||||
Order2SQLObj.getOrders(sqlMeta, fields, datasetGroupInfoDTO.getSortFields(), crossDs, dsMap);
|
||||
String querySQL;
|
||||
@ -459,7 +459,7 @@ public class DatasetDataManage {
|
||||
rowPermissionsTree = permissionManage.getRowPermissionsTree(datasetGroupInfoDTO.getId(), user.getUserId());
|
||||
}
|
||||
|
||||
Field2SQLObj.field2sqlObj(sqlMeta, fields, crossDs, dsMap);
|
||||
Field2SQLObj.field2sqlObj(sqlMeta, fields, datasetGroupInfoDTO.getAllFields(), crossDs, dsMap);
|
||||
WhereTree2Str.transFilterTrees(sqlMeta, rowPermissionsTree, fields, crossDs, dsMap);
|
||||
Order2SQLObj.getOrders(sqlMeta, fields, datasetGroupInfoDTO.getSortFields(), crossDs, dsMap);
|
||||
String querySQL = SQLProvider.createQuerySQLWithLimit(sqlMeta, false, needOrder, true, 0, 1000);
|
||||
@ -585,7 +585,7 @@ public class DatasetDataManage {
|
||||
datasetGroupInfoDTO.setSortFields(Collections.singletonList(deSortField));
|
||||
}
|
||||
|
||||
Field2SQLObj.field2sqlObj(sqlMeta, fields, crossDs, dsMap);
|
||||
Field2SQLObj.field2sqlObj(sqlMeta, fields, datasetGroupInfoDTO.getAllFields(), crossDs, dsMap);
|
||||
WhereTree2Str.transFilterTrees(sqlMeta, rowPermissionsTree, fields, crossDs, dsMap);
|
||||
Order2SQLObj.getOrders(sqlMeta, fields, datasetGroupInfoDTO.getSortFields(), crossDs, dsMap);
|
||||
String querySQL = SQLProvider.createQuerySQLWithLimit(sqlMeta, false, needOrder, false, 0, 1000);
|
||||
|
@ -47,7 +47,7 @@ public class SQLConstants {
|
||||
|
||||
public static final String FIELD_NAME = "%s.`%s`";
|
||||
|
||||
public static final String FIELD_DOT = "`%s`";
|
||||
public static final String FIELD_DOT = "%s";
|
||||
|
||||
public static final String UNIX_TIMESTAMP = "DE_UNIX_TIMESTAMP(%s)";
|
||||
|
||||
|
@ -20,7 +20,7 @@ import java.util.*;
|
||||
*/
|
||||
public class Field2SQLObj {
|
||||
|
||||
public static void field2sqlObj(SQLMeta meta, List<DatasetTableFieldDTO> fields, boolean isCross, Map<Long, DatasourceSchemaDTO> dsMap) {
|
||||
public static void field2sqlObj(SQLMeta meta, List<DatasetTableFieldDTO> fields,List<DatasetTableFieldDTO> originFields, boolean isCross, Map<Long, DatasourceSchemaDTO> dsMap) {
|
||||
SQLObj tableObj = meta.getTable();
|
||||
if (ObjectUtils.isEmpty(tableObj)) {
|
||||
return;
|
||||
@ -33,7 +33,7 @@ public class Field2SQLObj {
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && Objects.equals(x.getExtField(), ExtFieldConstant.EXT_CALC)) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
String calcFieldExp = Utils.calcFieldRegex(x.getOriginName(), tableObj, fields, isCross, dsMap);
|
||||
String calcFieldExp = Utils.calcFieldRegex(x.getOriginName(), tableObj, originFields, isCross, dsMap);
|
||||
// 给计算字段处加一个占位符,后续SQL方言转换后再替换
|
||||
originField = String.format(SqlPlaceholderConstants.CALC_FIELD_PLACEHOLDER, x.getId());
|
||||
fieldsDialect.put(originField, calcFieldExp);
|
||||
|
@ -11,8 +11,8 @@ import io.dataease.engine.constant.SQLConstants;
|
||||
import io.dataease.engine.utils.Utils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -24,8 +24,8 @@ public class Order2SQLObj {
|
||||
|
||||
public static void getOrders(SQLMeta meta, List<DatasetTableFieldDTO> fields, List<DeSortField> sortFields, boolean isCross, Map<Long, DatasourceSchemaDTO> dsMap) {
|
||||
SQLObj tableObj = meta.getTable();
|
||||
List<SQLObj> xOrders = meta.getXOrders();
|
||||
if (ObjectUtils.isEmpty(tableObj) || CollectionUtils.isEmpty(xOrders)) {
|
||||
List<SQLObj> xOrders = meta.getXOrders() == null ? new ArrayList<>() : meta.getXOrders();
|
||||
if (ObjectUtils.isEmpty(tableObj)) {
|
||||
return;
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(sortFields)) {
|
||||
@ -35,6 +35,7 @@ public class Order2SQLObj {
|
||||
SQLObj order = buildSortField(deSortField, tableObj, i, fields, isCross, dsMap);
|
||||
xOrders.add(order);
|
||||
}
|
||||
meta.setXOrders(xOrders);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user