diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java index 8d71eaf194..8b3f97c1e2 100644 --- a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableFieldController.java @@ -16,10 +16,16 @@ import io.dataease.controller.response.DatasetTableField4Type; import io.dataease.i18n.Translator; import io.dataease.plugins.common.base.domain.DatasetTable; import io.dataease.plugins.common.base.domain.DatasetTableField; +import io.dataease.plugins.common.base.domain.Datasource; +import io.dataease.plugins.datasource.entity.Dateformat; +import io.dataease.plugins.datasource.query.QueryProvider; +import io.dataease.provider.ProviderFactory; import io.dataease.service.dataset.DataSetFieldService; import io.dataease.service.dataset.DataSetTableFieldsService; import io.dataease.service.dataset.DataSetTableService; import io.dataease.service.dataset.PermissionService; +import io.dataease.service.datasource.DatasourceService; +import io.dataease.service.engine.EngineService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.ObjectUtils; @@ -46,14 +52,16 @@ import java.util.stream.Collectors; public class DataSetTableFieldController { @Resource private DataSetTableFieldsService dataSetTableFieldsService; - @Autowired private DataSetFieldService dataSetFieldService; - @Resource private DataSetTableService dataSetTableService; @Resource private PermissionService permissionService; + @Resource + private EngineService engineService; + @Resource + private DatasourceService datasourceService; @DePermission(type = DePermissionType.DATASET) @ApiOperation("查询表下属字段") @@ -208,4 +216,14 @@ public class DataSetTableFieldController { ArrayList::new)); return list; } + + @DePermission(type = DePermissionType.DATASET) + @ApiOperation("时间格式") + @PostMapping("dateformats/{tableId}") + public List dateformats(@PathVariable String tableId) throws Exception{ + DatasetTable datasetTable = dataSetTableService.get(tableId); + Datasource ds = datasetTable.getMode() == 0 ? datasourceService.get(datasetTable.getDataSourceId()) : engineService.getDeEngine(); + QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); + return qp.dateformat(); + } } diff --git a/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java b/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java index 8b9a23b56d..03ba7d0460 100644 --- a/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/engine/doris/DorisQueryProvider.java @@ -1,5 +1,6 @@ package io.dataease.provider.engine.doris; +import com.alibaba.fastjson.JSONArray; import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; import io.dataease.plugins.common.base.domain.DatasetTableField; import io.dataease.plugins.common.base.domain.DatasetTableFieldExample; @@ -16,6 +17,7 @@ import io.dataease.plugins.common.dto.sqlObj.SQLObj; import io.dataease.plugins.common.request.chart.ChartExtFilterRequest; import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO; import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem; +import io.dataease.plugins.datasource.entity.Dateformat; import io.dataease.plugins.datasource.query.QueryProvider; import io.dataease.plugins.datasource.query.Utils; import org.apache.commons.collections4.CollectionUtils; @@ -1311,4 +1313,15 @@ public class DorisQueryProvider extends QueryProvider { return sql; } } + + public List dateformat() { + return JSONArray.parseArray("[\n" + + "{\"dateformat\": \"%Y-%m-%d\"},\n" + + "{\"dateformat\": \"%Y/%m/%d\"},\n" + + "{\"dateformat\": \"%Y%m%d\"},\n" + + "{\"dateformat\": \"%Y-%m-%d %H:%i:%S\"},\n" + + "{\"dateformat\": \"%Y/%m/%d %H:%i:%S\"},\n" + + "{\"dateformat\": \"%Y%m%d %H:%i:%S\"}\n" + + "]", Dateformat.class); + } } diff --git a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java index cb426517e4..8ab3793784 100644 --- a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java @@ -1,5 +1,6 @@ package io.dataease.provider.engine.mysql; +import com.alibaba.fastjson.JSONArray; import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; import io.dataease.plugins.common.base.domain.DatasetTableField; import io.dataease.plugins.common.base.domain.DatasetTableFieldExample; @@ -16,6 +17,7 @@ import io.dataease.plugins.common.dto.sqlObj.SQLObj; import io.dataease.plugins.common.request.chart.ChartExtFilterRequest; import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO; import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem; +import io.dataease.plugins.datasource.entity.Dateformat; import io.dataease.plugins.datasource.query.QueryProvider; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; @@ -1312,4 +1314,15 @@ public class MysqlQueryProvider extends QueryProvider { return sql; } } + + public List dateformat() { + return JSONArray.parseArray("[\n" + + "{\"dateformat\": \"%Y-%m-%d\"},\n" + + "{\"dateformat\": \"%Y/%m/%d\"},\n" + + "{\"dateformat\": \"%Y%m%d\"},\n" + + "{\"dateformat\": \"%Y-%m-%d %H:%i:%S\"},\n" + + "{\"dateformat\": \"%Y/%m/%d %H:%i:%S\"},\n" + + "{\"dateformat\": \"%Y%m%d %H:%i:%S\"}\n" + + "]", Dateformat.class); + } } diff --git a/backend/src/main/java/io/dataease/provider/query/mysql/MysqlQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/mysql/MysqlQueryProvider.java index b02ee4ef54..93e2d2ad59 100644 --- a/backend/src/main/java/io/dataease/provider/query/mysql/MysqlQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/mysql/MysqlQueryProvider.java @@ -1,5 +1,6 @@ package io.dataease.provider.query.mysql; +import com.alibaba.fastjson.JSONArray; import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; import io.dataease.plugins.common.base.domain.DatasetTableField; import io.dataease.plugins.common.base.domain.DatasetTableFieldExample; @@ -17,7 +18,7 @@ import io.dataease.plugins.common.dto.sqlObj.SQLObj; import io.dataease.plugins.common.request.chart.ChartExtFilterRequest; import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO; import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem; -import io.dataease.plugins.datasource.entity.PageInfo; +import io.dataease.plugins.datasource.entity.Dateformat; import io.dataease.plugins.datasource.query.QueryProvider; import io.dataease.plugins.datasource.query.Utils; import org.apache.commons.collections4.CollectionUtils; @@ -374,20 +375,6 @@ public class MysqlQueryProvider extends QueryProvider { @Override public String getSQLTableInfo(String table, List xAxis, List fieldCustomFilter, List rowPermissionsTree, List extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) { - return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view); - } - - @Override - public String getSQLWithPage(boolean isTable, String table, List xAxis, List fieldCustomFilter, List rowPermissionsTree, List extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) { - String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize() : ""); - if (isTable) { - return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit; - } else { - return originalTableInfo("(" + sqlFix(table) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit; - } - } - - private String originalTableInfo(String table, List xAxis, List fieldCustomFilter, List rowPermissionsTree, List extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) { SQLObj tableObj = SQLObj.builder() .tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table)) .tableAlias(String.format(TABLE_ALIAS_PREFIX, 0)) @@ -458,7 +445,7 @@ public class MysqlQueryProvider extends QueryProvider { .build(); if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders); if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL); - return st.render(); + return sqlLimit(st.render(), view); } @Override @@ -1333,4 +1320,15 @@ public class MysqlQueryProvider extends QueryProvider { public String sqlForPreview(String table, Datasource ds) { return "SELECT * FROM " + String.format(MySQLConstants.KEYWORD_TABLE, table); } + + public List dateformat() { + return JSONArray.parseArray("[\n" + + "{\"dateformat\": \"%Y-%m-%d\"},\n" + + "{\"dateformat\": \"%Y/%m/%d\"},\n" + + "{\"dateformat\": \"%Y%m%d\"},\n" + + "{\"dateformat\": \"%Y-%m-%d %H:%i:%S\"},\n" + + "{\"dateformat\": \"%Y/%m/%d %H:%i:%S\"},\n" + + "{\"dateformat\": \"%Y%m%d %H:%i:%S\"}\n" + + "]", Dateformat.class); + } } diff --git a/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java index 46cc773569..5acfdef48b 100644 --- a/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/sqlserver/SqlserverQueryProvider.java @@ -1,5 +1,7 @@ package io.dataease.provider.query.sqlserver; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; import io.dataease.plugins.common.base.domain.DatasetTableField; @@ -17,6 +19,7 @@ import io.dataease.plugins.common.dto.sqlObj.SQLObj; import io.dataease.plugins.common.request.chart.ChartExtFilterRequest; import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO; import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem; +import io.dataease.plugins.datasource.entity.Dateformat; import io.dataease.plugins.datasource.entity.JdbcConfiguration; import io.dataease.plugins.datasource.query.QueryProvider; import io.dataease.plugins.datasource.query.Utils; @@ -1331,4 +1334,13 @@ public class SqlserverQueryProvider extends QueryProvider { schema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema); return "SELECT * FROM " + schema + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table); } + + public List dateformat() { + return JSONArray.parseArray("[\n" + + "{\"dateformat\": \"102\", \"desc\": \"yyyy.mm.dd\"},\n" + + "{\"dateformat\": \"23\", \"desc\": \"yyyy-mm-dd\"},\n" + + "{\"dateformat\": \"111\", \"desc\": \"yyyy/mm/dd\"},\n" + + "{\"dateformat\": \"120\", \"desc\": \"yyyy-mm-dd hh:mi:ss\"}\n" + + "]", Dateformat.class); + } } diff --git a/frontend/src/api/dataset/dataset.js b/frontend/src/api/dataset/dataset.js index c96d1a7bec..fc4c5b7c69 100644 --- a/frontend/src/api/dataset/dataset.js +++ b/frontend/src/api/dataset/dataset.js @@ -136,6 +136,14 @@ export function fieldListDQ(id, showLoading = true) { }) } +export function dateformats(id, showLoading = true) { + return request({ + url: '/dataset/field/dateformats/' + id, + loading: showLoading, + method: 'post' + }) +} + export function batchEdit(data) { return request({ url: '/dataset/field/batchEdit', diff --git a/frontend/src/views/dataset/data/FieldEdit.vue b/frontend/src/views/dataset/data/FieldEdit.vue index 44eb1336f7..6e879d8947 100644 --- a/frontend/src/views/dataset/data/FieldEdit.vue +++ b/frontend/src/views/dataset/data/FieldEdit.vue @@ -736,7 +736,7 @@