forked from github/dataease
fix: 修复系统变量显示问题
This commit is contained in:
parent
16d59975f9
commit
ca3e8aaea7
@ -117,9 +117,9 @@ public class CalciteProvider {
|
||||
tableDesc.setDatasourceId(datasourceRequest.getDatasource().getId());
|
||||
tableDesc.setType("db");
|
||||
tableDesc.setTableName(resultSet.getString(1));
|
||||
if(resultSet.getMetaData().getColumnCount() > 1){
|
||||
if (resultSet.getMetaData().getColumnCount() > 1) {
|
||||
tableDesc.setName(resultSet.getString(2));
|
||||
}else {
|
||||
} else {
|
||||
tableDesc.setName(resultSet.getString(1));
|
||||
}
|
||||
return tableDesc;
|
||||
@ -316,10 +316,40 @@ public class CalciteProvider {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void hidePW(DatasourceDTO datasourceDTO) {
|
||||
DatasourceConfiguration configuration = null;
|
||||
DatasourceType datasourceType = DatasourceType.valueOf(datasourceDTO.getType());
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
case mongo:
|
||||
case mariadb:
|
||||
case TiDB:
|
||||
case StarRocks:
|
||||
case doris:
|
||||
configuration = JsonUtil.parseObject(datasourceDTO.getConfiguration(), Mysql.class);
|
||||
if (StringUtils.isNotEmpty(configuration.getUrlType()) && configuration.getUrlType().equalsIgnoreCase("jdbcUrl")) {
|
||||
if (configuration.getJdbcUrl().contains("password=")) {
|
||||
String[] params = configuration.getJdbcUrl().split("\\?")[1].split("&");
|
||||
String pd = "";
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (params[i].contains("password=")) {
|
||||
pd = params[i];
|
||||
}
|
||||
}
|
||||
configuration.setJdbcUrl(configuration.getJdbcUrl().replace(pd, "password=******"));
|
||||
datasourceDTO.setConfiguration(JsonUtil.toJSONString(configuration).toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private String getTableFiledSql(DatasourceRequest datasourceRequest) {
|
||||
String sql = "";
|
||||
DatasourceConfiguration configuration = null;
|
||||
String database="";
|
||||
String database = "";
|
||||
DatasourceType datasourceType = DatasourceType.valueOf(datasourceRequest.getDatasource().getType());
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
@ -440,7 +470,8 @@ public class CalciteProvider {
|
||||
return sql;
|
||||
}
|
||||
|
||||
private TableField getTableFieldDesc(DatasourceRequest datasourceRequest, ResultSet resultSet) throws SQLException {
|
||||
private TableField getTableFieldDesc(DatasourceRequest datasourceRequest, ResultSet resultSet) throws
|
||||
SQLException {
|
||||
TableField tableField = new TableField();
|
||||
tableField.setOriginName(resultSet.getString(1));
|
||||
tableField.setType(resultSet.getString(2).toUpperCase());
|
||||
@ -809,7 +840,7 @@ public class CalciteProvider {
|
||||
" AND ep.class = 1 \n" +
|
||||
" AND ep.name = 'MS_Description'\n" +
|
||||
"where sc.name ='DS_SCHEMA'"
|
||||
.replace("DS_SCHEMA", configuration.getSchema()));
|
||||
.replace("DS_SCHEMA", configuration.getSchema()));
|
||||
tableSqls.add("SELECT \n" +
|
||||
" t.name AS TableName, \n" +
|
||||
" ep.value AS TableDescription \n" +
|
||||
|
@ -488,12 +488,20 @@ public class DatasourceServer implements DatasourceApi {
|
||||
return calciteProvider.getSchema(datasourceRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasourceDTO hidePw(Long datasourceId) throws DEException {
|
||||
return getDatasourceDTOById(datasourceId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasourceDTO get(Long datasourceId) throws DEException {
|
||||
return getDatasourceDTOById(datasourceId, false);
|
||||
}
|
||||
|
||||
private DatasourceDTO getDatasourceDTOById(Long datasourceId, boolean hidePw) throws DEException {
|
||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||
CoreDatasource datasource = datasourceMapper.selectById(datasourceId);
|
||||
if(datasource == null){
|
||||
if (datasource == null) {
|
||||
DEException.throwException("不存在的数据源!");
|
||||
}
|
||||
BeanUtils.copyBean(datasourceDTO, datasource);
|
||||
@ -547,15 +555,18 @@ public class DatasourceServer implements DatasourceApi {
|
||||
if (task != null) {
|
||||
datasourceDTO.setLastSyncTime(task.getStartTime());
|
||||
}
|
||||
} else {
|
||||
if (hidePw) {
|
||||
calciteProvider.hidePW(datasourceDTO);
|
||||
}
|
||||
|
||||
}
|
||||
if (datasourceDTO.getType().equalsIgnoreCase(DatasourceConfiguration.DatasourceType.Excel.toString())) {
|
||||
datasourceDTO.setFileName(ExcelUtils.getFileName(datasource));
|
||||
datasourceDTO.setSize(ExcelUtils.getSize(datasource));
|
||||
}
|
||||
datasourceDTO.setConfiguration(new String(Base64.getEncoder().encode(datasourceDTO.getConfiguration().getBytes())));
|
||||
|
||||
datasourceDTO.setCreator(coreUserManage.getUserName(Long.valueOf(datasourceDTO.getCreateBy())));
|
||||
|
||||
return datasourceDTO;
|
||||
}
|
||||
|
||||
@ -750,7 +761,7 @@ public class DatasourceServer implements DatasourceApi {
|
||||
datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO));
|
||||
datasourceRequest.setQuery(TableUtils.tableName2Sql(datasourceSchemaDTO, tableName) + " LIMIT 0 OFFSET 0");
|
||||
datasourceRequest.setTable(tableName);
|
||||
List<TableField> tableFields = (List<TableField>) calciteProvider.fetchTableField(datasourceRequest) ;
|
||||
List<TableField> tableFields = (List<TableField>) calciteProvider.fetchTableField(datasourceRequest);
|
||||
return tableFields.stream().filter(tableField -> {
|
||||
return !tableField.getOriginName().equalsIgnoreCase("dataease_uuid");
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -183,12 +183,21 @@ public class ExportCenterManage {
|
||||
if (status.equalsIgnoreCase(exportTaskDTO.getExportStatus())) {
|
||||
setExportFromAbsName(exportTaskDTO);
|
||||
}
|
||||
if (status.equalsIgnoreCase(exportTaskDTO.getExportStatus())) {
|
||||
setOrgName(exportTaskDTO);
|
||||
}
|
||||
result.add(exportTaskDTO);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void setOrgName(ExportTaskDTO exportTaskDTO) {
|
||||
if (exportTaskDTO.getExportFromType().equalsIgnoreCase("chart")) {
|
||||
exportTaskDTO.setOrgName(dataVisualizationServer.getAbsPath(exportTaskDTO.getExportFrom()));
|
||||
}
|
||||
}
|
||||
|
||||
private void setExportFromAbsName(ExportTaskDTO exportTaskDTO) {
|
||||
if (exportTaskDTO.getExportFromType().equalsIgnoreCase("chart")) {
|
||||
exportTaskDTO.setExportFromName(dataVisualizationServer.getAbsPath(exportTaskDTO.getExportFrom()));
|
||||
|
@ -10,9 +10,9 @@ import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public class CheckDsStatusJob implements Job {
|
||||
|
||||
@Resource
|
||||
private DatasourceServer datasourceServer;
|
||||
|
||||
|
@ -13,3 +13,24 @@ CREATE TABLE `core_sys_startup_job`
|
||||
BEGIN;
|
||||
INSERT INTO `core_sys_startup_job` VALUES ('chartFilterMerge', 'chartFilterMerge', 'ready');
|
||||
COMMIT;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS "core_export_task";
|
||||
CREATE TABLE "core_export_task"
|
||||
(
|
||||
"id" VARCHAR(255) NOT NULL,
|
||||
"user_id" BIGINT(20) NOT NULL,
|
||||
"file_name" VARCHAR(2048) DEFAULT NULL,
|
||||
"file_size" DOUBLE DEFAULT NULL,
|
||||
"file_size_unit" VARCHAR(255) DEFAULT NULL,
|
||||
"export_from" VARCHAR(255) DEFAULT NULL,
|
||||
"export_status" VARCHAR(255) DEFAULT NULL,
|
||||
"export_from_type" VARCHAR(255) DEFAULT NULL,
|
||||
"export_time" BIGINT(20) DEFAULT NULL,
|
||||
"export_progress" VARCHAR(255) DEFAULT NULL,
|
||||
"export_machine_name" VARCHAR(512) DEFAULT NULL,
|
||||
"params" CLOB NOT NULL COMMENT '过滤参数',
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT='导出任务表';
|
||||
|
||||
UPDATE `QRTZ_JOB_DETAILS` SET `JOB_CLASS_NAME` = 'io.dataease.job.schedule.CheckDsStatusJob' WHERE (`SCHED_NAME` = 'deSyncJob') and (`JOB_NAME` = 'Datasource') and (`JOB_GROUP` = 'check_status');
|
||||
|
@ -52,3 +52,6 @@ CREATE TABLE `xpack_platform_token`
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
|
||||
|
||||
UPDATE `QRTZ_JOB_DETAILS` SET `JOB_CLASS_NAME` = 'io.dataease.job.schedule.CheckDsStatusJob' WHERE (`SCHED_NAME` = 'deSyncJob') and (`JOB_NAME` = 'Datasource') and (`JOB_GROUP` = 'check_status');
|
||||
|
@ -147,6 +147,8 @@ export const deleteById = (id: number) => request.get({ url: '/datasource/delete
|
||||
|
||||
export const getById = (id: number) => request.get({ url: '/datasource/get/' + id })
|
||||
|
||||
export const getHidePwById = (id: number) => request.get({ url: '/datasource/hidePw/' + id })
|
||||
|
||||
export const uploadFile = async (data): Promise<IResponse> => {
|
||||
return request
|
||||
.post({
|
||||
|
@ -204,8 +204,8 @@ const downloadViewDetails = () => {
|
||||
exportLoading.value = true
|
||||
exportExcelDownload(chart, () => {
|
||||
openMessageLoading(exportData)
|
||||
exportLoading.value = false
|
||||
})
|
||||
exportLoading.value = false
|
||||
}
|
||||
|
||||
const exportData = () => {
|
||||
|
@ -475,7 +475,6 @@ export const exportExcelDownload = (chart, callBack?) => {
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
callBack('success')
|
||||
} else {
|
||||
callBack && callBack(res)
|
||||
}
|
||||
|
@ -65,8 +65,6 @@ const handleClick = tab => {
|
||||
} else {
|
||||
description.value = t('data_export.no_task')
|
||||
}
|
||||
|
||||
tableData.value = []
|
||||
drawerLoading.value = true
|
||||
exportTasks(activeName.value)
|
||||
.then(res => {
|
||||
@ -192,6 +190,7 @@ const callbackExport = () => {
|
||||
const downLoadAll = () => {
|
||||
if (multipleSelection.value.length === 0) {
|
||||
tableData.value.forEach(item => {
|
||||
console.log(item.id)
|
||||
downloadFile(item.id)
|
||||
.then(res => {
|
||||
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
|
||||
|
@ -8,7 +8,7 @@ import ArrowSide from '@/views/common/DeResourceArrow.vue'
|
||||
import { HandleMore } from '@/components/handle-more'
|
||||
import { Icon } from '@/components/icon-custom'
|
||||
import { fieldType } from '@/utils/attr'
|
||||
import { listSyncRecord, uploadFile } from '@/api/datasource'
|
||||
import { getHidePwById, listSyncRecord, uploadFile } from '@/api/datasource'
|
||||
import CreatDsGroup from './form/CreatDsGroup.vue'
|
||||
import type { Tree } from '../dataset/form/CreatDsGroup.vue'
|
||||
import { previewData, getById } from '@/api/datasource'
|
||||
@ -455,7 +455,7 @@ const handleNodeClick = data => {
|
||||
dsListTree.value.setCurrentKey(null)
|
||||
return
|
||||
}
|
||||
return getById(data.id).then(res => {
|
||||
return getHidePwById(data.id).then(res => {
|
||||
let {
|
||||
name,
|
||||
createBy,
|
||||
@ -571,7 +571,48 @@ const editDatasource = (editType?: number) => {
|
||||
if (nodeInfo.type === 'Excel') {
|
||||
nodeInfo.editType = editType
|
||||
}
|
||||
datasourceEditor.value.init(nodeInfo)
|
||||
return getById(nodeInfo.id).then(res => {
|
||||
let {
|
||||
name,
|
||||
createBy,
|
||||
id,
|
||||
createTime,
|
||||
creator,
|
||||
type,
|
||||
pid,
|
||||
configuration,
|
||||
syncSetting,
|
||||
apiConfigurationStr,
|
||||
fileName,
|
||||
size,
|
||||
description,
|
||||
lastSyncTime
|
||||
} = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(Base64.decode(configuration))
|
||||
}
|
||||
if (apiConfigurationStr) {
|
||||
apiConfigurationStr = JSON.parse(Base64.decode(apiConfigurationStr))
|
||||
}
|
||||
let datasource = reactive<Node>(cloneDeep(defaultInfo))
|
||||
Object.assign(datasource, {
|
||||
name,
|
||||
pid,
|
||||
description,
|
||||
fileName,
|
||||
size,
|
||||
createTime,
|
||||
creator,
|
||||
createBy,
|
||||
id,
|
||||
type,
|
||||
configuration,
|
||||
syncSetting,
|
||||
apiConfiguration: apiConfigurationStr,
|
||||
lastSyncTime
|
||||
})
|
||||
datasourceEditor.value.init(datasource)
|
||||
})
|
||||
}
|
||||
|
||||
const handleEdit = async data => {
|
||||
|
@ -71,6 +71,11 @@ public interface DatasourceApi {
|
||||
@GetMapping("/get/{datasourceId}")
|
||||
DatasourceDTO get(@PathVariable("datasourceId") Long datasourceId) throws DEException;
|
||||
|
||||
@DePermit({"#p0+':read'"})
|
||||
@GetMapping("/hidePw/{datasourceId}")
|
||||
DatasourceDTO hidePw(@PathVariable("datasourceId") Long datasourceId) throws DEException;
|
||||
|
||||
|
||||
@PostMapping("/getTableField")
|
||||
List<TableField> getTableField(@RequestBody Map<String, String> req) throws DEException;
|
||||
|
||||
|
@ -30,4 +30,6 @@ public class ExportTaskDTO {
|
||||
private String exportMachineName;
|
||||
|
||||
private String exportFromName;
|
||||
|
||||
private String orgName;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysVariableValueItem {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private String variableValue;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private String variableValue2;
|
||||
|
Loading…
Reference in New Issue
Block a user