Merge pull request #13255 from dataease/pr@dev-v2@fixds
Pr@dev v2@fixds
This commit is contained in:
commit
217da936cc
@ -128,17 +128,20 @@ public class ChartDataServer implements ChartDataApi {
|
||||
request.setHeader(dsHeader);
|
||||
request.setExcelTypes(dsTypes);
|
||||
}
|
||||
for (Object[] objects : tableRow) {
|
||||
for (int i = 0; i < viewDTO.getXAxis().size(); i++) {
|
||||
if (viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_INT) || viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_FLOAT)) {
|
||||
try {
|
||||
objects[i] = valueFormatter(BigDecimal.valueOf(Double.valueOf(objects[i].toString())), viewDTO.getXAxis().get(i).getFormatterCfg());
|
||||
} catch (Exception ignore) {
|
||||
if (CollectionUtils.isNotEmpty(tableRow)) {
|
||||
for (Object[] objects : tableRow) {
|
||||
for (int i = 0; i < viewDTO.getXAxis().size(); i++) {
|
||||
if (viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_INT) || viewDTO.getXAxis().get(i).getDeType().equals(DeTypeConstants.DE_FLOAT)) {
|
||||
try {
|
||||
objects[i] = valueFormatter(BigDecimal.valueOf(Double.valueOf(objects[i].toString())), viewDTO.getXAxis().get(i).getFormatterCfg());
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
request.setDetails(tableRow);
|
||||
request.setData(chartViewInfo.getData());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@ -483,6 +483,23 @@ public class DatasourceServer implements DatasourceApi {
|
||||
return getDatasourceDTOById(datasourceId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasourceDTO getSimpleDs(Long datasourceId) throws DEException {
|
||||
CoreDatasource datasource = datasourceMapper.selectById(datasourceId);
|
||||
if (datasource == null) {
|
||||
DEException.throwException("不存在的数据源!");
|
||||
}
|
||||
if (datasource.getType().equalsIgnoreCase("api")) {
|
||||
datasource.setConfiguration("[]");
|
||||
} else {
|
||||
datasource.setConfiguration("");
|
||||
}
|
||||
datasource.setConfiguration("");
|
||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||
BeanUtils.copyBean(datasourceDTO, datasource);
|
||||
return datasourceDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasourceDTO get(Long datasourceId) throws DEException {
|
||||
return getDatasourceDTOById(datasourceId, false);
|
||||
@ -1132,8 +1149,12 @@ public class DatasourceServer implements DatasourceApi {
|
||||
params.add(apiDefinition);
|
||||
}
|
||||
}
|
||||
datasourceDTO.setApiConfigurationStr(new String(Base64.getEncoder().encode(Objects.requireNonNull(JsonUtil.toJSONString(apiDefinitionListWithStatus)).toString().getBytes())));
|
||||
datasourceDTO.setParamsStr(new String(Base64.getEncoder().encode(Objects.requireNonNull(JsonUtil.toJSONString(params)).toString().getBytes())));
|
||||
if(CollectionUtils.isNotEmpty(params)){
|
||||
datasourceDTO.setParamsStr(RsaUtils.symmetricEncrypt(JsonUtil.toJSONString(params).toString()));
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(apiDefinitionListWithStatus)){
|
||||
datasourceDTO.setApiConfigurationStr(RsaUtils.symmetricEncrypt(JsonUtil.toJSONString(apiDefinitionListWithStatus).toString()));
|
||||
}
|
||||
if (success == apiDefinitionList.size()) {
|
||||
datasourceDTO.setStatus("Success");
|
||||
} else {
|
||||
@ -1147,7 +1168,6 @@ public class DatasourceServer implements DatasourceApi {
|
||||
TaskDTO taskDTO = new TaskDTO();
|
||||
BeanUtils.copyBean(taskDTO, coreDatasourceTask);
|
||||
datasourceDTO.setSyncSetting(taskDTO);
|
||||
|
||||
CoreDatasourceTask task = datasourceTaskServer.selectByDSId(datasourceDTO.getId());
|
||||
if (task != null) {
|
||||
datasourceDTO.setLastSyncTime(task.getStartTime());
|
||||
@ -1157,13 +1177,12 @@ public class DatasourceServer implements DatasourceApi {
|
||||
Provider provider = ProviderFactory.getProvider(datasourceDTO.getType());
|
||||
provider.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.setConfiguration(RsaUtils.symmetricEncrypt(datasourceDTO.getConfiguration()));
|
||||
datasourceDTO.setCreator(coreUserManage.getUserName(Long.valueOf(datasourceDTO.getCreateBy())));
|
||||
return datasourceDTO;
|
||||
}
|
||||
|
||||
@ -5,9 +5,12 @@ import io.dataease.datasource.dao.auto.entity.CoreDeEngine;
|
||||
import io.dataease.datasource.dao.auto.mapper.CoreDeEngineMapper;
|
||||
import io.dataease.datasource.manage.EngineManage;
|
||||
import io.dataease.datasource.provider.CalciteProvider;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.extensions.datasource.dto.DatasourceDTO;
|
||||
import io.dataease.utils.AuthUtils;
|
||||
import io.dataease.utils.BeanUtils;
|
||||
import io.dataease.utils.IDUtils;
|
||||
import io.dataease.utils.RsaUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -30,33 +33,44 @@ public class EngineServer implements EngineApi {
|
||||
|
||||
@Override
|
||||
public DatasourceDTO getEngine() {
|
||||
if (!AuthUtils.getUser().getUserId().equals(1L)) {
|
||||
DEException.throwException("非管理员,无权访问!");
|
||||
}
|
||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||
List<CoreDeEngine> deEngines = deEngineMapper.selectList(null);
|
||||
if (CollectionUtils.isEmpty(deEngines)) {
|
||||
return datasourceDTO;
|
||||
}
|
||||
return BeanUtils.copyBean(datasourceDTO, deEngines.get(0));
|
||||
BeanUtils.copyBean(datasourceDTO, deEngines.get(0));
|
||||
datasourceDTO.setConfiguration(RsaUtils.symmetricEncrypt(datasourceDTO.getConfiguration()));
|
||||
return datasourceDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(DatasourceDTO datasourceDTO) {
|
||||
if (!AuthUtils.getUser().getUserId().equals(1L)) {
|
||||
DEException.throwException("非管理员,无权访问!");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(datasourceDTO.getConfiguration())) {
|
||||
datasourceDTO.setConfiguration(new String(Base64.getDecoder().decode(datasourceDTO.getConfiguration())));
|
||||
}
|
||||
CoreDeEngine coreDeEngine = new CoreDeEngine();
|
||||
BeanUtils.copyBean(coreDeEngine, datasourceDTO);
|
||||
if(coreDeEngine.getId() == null){
|
||||
if (coreDeEngine.getId() == null) {
|
||||
coreDeEngine.setId(IDUtils.snowID());
|
||||
datasourceDTO.setId(coreDeEngine.getId());
|
||||
deEngineMapper.insert(coreDeEngine);
|
||||
}else {
|
||||
} else {
|
||||
deEngineMapper.updateById(coreDeEngine);
|
||||
}
|
||||
calciteProvider.update(datasourceDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(DatasourceDTO datasourceDTO) throws Exception{
|
||||
public void validate(DatasourceDTO datasourceDTO) throws Exception {
|
||||
if (!AuthUtils.getUser().getUserId().equals(1L)) {
|
||||
DEException.throwException("非管理员,无权访问!");
|
||||
}
|
||||
CoreDeEngine coreDeEngine = new CoreDeEngine();
|
||||
BeanUtils.copyBean(coreDeEngine, datasourceDTO);
|
||||
coreDeEngine.setConfiguration(new String(Base64.getDecoder().decode(coreDeEngine.getConfiguration())));
|
||||
@ -65,6 +79,9 @@ public class EngineServer implements EngineApi {
|
||||
|
||||
@Override
|
||||
public void validateById(Long id) throws Exception {
|
||||
if (!AuthUtils.getUser().getUserId().equals(1L)) {
|
||||
DEException.throwException("非管理员,无权访问!");
|
||||
}
|
||||
engineManage.validate(deEngineMapper.selectById(id));
|
||||
}
|
||||
|
||||
|
||||
@ -655,16 +655,18 @@ public class ExportCenterManage implements BaseExportApi {
|
||||
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
|
||||
if (CollectionUtils.isEmpty(request.getMultiInfo())) {
|
||||
List<Object[]> details = request.getDetails();
|
||||
Integer[] excelTypes = request.getExcelTypes();
|
||||
details.add(0, request.getHeader());
|
||||
ViewDetailField[] detailFields = request.getDetailFields();
|
||||
Object[] header = request.getHeader();
|
||||
if(request.getViewInfo().getType().equalsIgnoreCase("chart-mix-dual-line")){
|
||||
|
||||
//明细sheet
|
||||
Sheet detailsSheet = wb.createSheet("数据");
|
||||
}else {
|
||||
List<Object[]> details = request.getDetails();
|
||||
Integer[] excelTypes = request.getExcelTypes();
|
||||
details.add(0, request.getHeader());
|
||||
ViewDetailField[] detailFields = request.getDetailFields();
|
||||
Object[] header = request.getHeader();
|
||||
Sheet detailsSheet = wb.createSheet("数据");
|
||||
ChartDataServer.setExcelData(detailsSheet, cellStyle, header, details, detailFields, excelTypes);
|
||||
}
|
||||
|
||||
ChartDataServer.setExcelData(detailsSheet, cellStyle, header, details, detailFields, excelTypes);
|
||||
} else {
|
||||
//多个sheet
|
||||
for (int i = 0; i < request.getMultiInfo().size(); i++) {
|
||||
|
||||
@ -23,6 +23,13 @@ public class RestIndexController {
|
||||
return RsaUtils.publicKey();
|
||||
}
|
||||
|
||||
@GetMapping("/symmetricKey")
|
||||
@ResponseBody
|
||||
public String symmetricKey() {
|
||||
return RsaUtils.generateSymmetricKey();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/model")
|
||||
@ResponseBody
|
||||
public boolean model() {
|
||||
|
||||
@ -19,7 +19,7 @@ import java.util.List;
|
||||
@Component
|
||||
public class LinkInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final static String whiteListText = "/user/ipInfo, /apisix/check, /datasetData/enumValue, /datasetData/enumValueObj, /datasetData/getFieldTree, /dekey, /share/validate, /sysParameter/queryOnlineMap, /chartData/innerExportDetails";
|
||||
private final static String whiteListText = "/user/ipInfo, /apisix/check, /datasetData/enumValue, /datasetData/enumValueObj, /datasetData/getFieldTree, /dekey, /symmetricKey, /share/validate, /sysParameter/queryOnlineMap, /chartData/innerExportDetails";
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -155,6 +155,8 @@ export const getById = (id: number) => request.get({ url: '/datasource/get/' + i
|
||||
|
||||
export const getHidePwById = (id: number) => request.get({ url: '/datasource/hidePw/' + id })
|
||||
|
||||
export const getSimpleDs = (id: number) => request.get({ url: '/datasource/getSimpleDs/' + id })
|
||||
|
||||
export const uploadFile = async (data): Promise<IResponse> => {
|
||||
return request
|
||||
.post({
|
||||
|
||||
@ -4,6 +4,8 @@ export const loginApi = data => request.post({ url: '/login/localLogin', data })
|
||||
|
||||
export const queryDekey = () => request.get({ url: 'dekey' })
|
||||
|
||||
export const querySymmetricKey = () => request.get({ url: 'symmetricKey' })
|
||||
|
||||
export const modelApi = () => request.get({ url: 'model' })
|
||||
|
||||
export const platformLoginApi = origin => request.post({ url: '/login/platformLogin/' + origin })
|
||||
|
||||
@ -40,3 +40,15 @@ export const rsaEncryp = word => {
|
||||
crypt.setKey(pk)
|
||||
return crypt.encrypt(word)
|
||||
}
|
||||
|
||||
export const symmetricDecrypt = (data, keyStr) => {
|
||||
const iv = CryptoJS.enc.Utf8.parse('0000000000000000')
|
||||
const key = CryptoJS.enc.Base64.parse(keyStr)
|
||||
const decodedCiphertext = CryptoJS.enc.Base64.parse(data)
|
||||
const decrypted = CryptoJS.AES.decrypt({ ciphertext: decodedCiphertext }, key, {
|
||||
iv: iv,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
})
|
||||
return decrypted.toString(CryptoJS.enc.Utf8)
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import { cloneDeep } from 'lodash-es'
|
||||
import { getDeEngine } from '@/api/datasource'
|
||||
import { CustomPassword } from '@/components/custom-password'
|
||||
import { Base64 } from 'js-base64'
|
||||
import { querySymmetricKey } from '@/api/login'
|
||||
import { symmetricDecrypt } from '@/utils/encryption'
|
||||
const { t } = useI18n()
|
||||
const dialogVisible = ref(false)
|
||||
const loadingInstance = ref(null)
|
||||
@ -149,45 +151,47 @@ const defaultInfo = {
|
||||
}
|
||||
const nodeInfo = reactive(cloneDeep(defaultInfo))
|
||||
const edit = () => {
|
||||
getDeEngine()
|
||||
.then(res => {
|
||||
let {
|
||||
name,
|
||||
createBy,
|
||||
id,
|
||||
createTime,
|
||||
creator,
|
||||
type,
|
||||
pid,
|
||||
configuration,
|
||||
syncSetting,
|
||||
fileName,
|
||||
size,
|
||||
description,
|
||||
lastSyncTime
|
||||
} = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(configuration)
|
||||
}
|
||||
Object.assign(nodeInfo, {
|
||||
name,
|
||||
pid,
|
||||
description,
|
||||
fileName,
|
||||
size,
|
||||
createTime,
|
||||
creator,
|
||||
createBy,
|
||||
id,
|
||||
type,
|
||||
configuration,
|
||||
syncSetting,
|
||||
lastSyncTime
|
||||
querySymmetricKey().then(response => {
|
||||
getDeEngine()
|
||||
.then(res => {
|
||||
let {
|
||||
name,
|
||||
createBy,
|
||||
id,
|
||||
createTime,
|
||||
creator,
|
||||
type,
|
||||
pid,
|
||||
configuration,
|
||||
syncSetting,
|
||||
fileName,
|
||||
size,
|
||||
description,
|
||||
lastSyncTime
|
||||
} = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(symmetricDecrypt(configuration, response.data))
|
||||
}
|
||||
Object.assign(nodeInfo, {
|
||||
name,
|
||||
pid,
|
||||
description,
|
||||
fileName,
|
||||
size,
|
||||
createTime,
|
||||
creator,
|
||||
createBy,
|
||||
id,
|
||||
type,
|
||||
configuration,
|
||||
syncSetting,
|
||||
lastSyncTime
|
||||
})
|
||||
})
|
||||
})
|
||||
.finally(() => {
|
||||
dialogVisible.value = true
|
||||
})
|
||||
.finally(() => {
|
||||
dialogVisible.value = true
|
||||
})
|
||||
})
|
||||
}
|
||||
const basicForm = ref()
|
||||
|
||||
|
||||
@ -42,6 +42,8 @@ import InfoTemplate from '@/views/system/common/InfoTemplate.vue'
|
||||
import { dsTypes } from '@/views/visualized/data/datasource/form/option'
|
||||
import { getDeEngine } from '@/api/datasource'
|
||||
import request from '@/config/axios'
|
||||
import { querySymmetricKey } from '@/api/login'
|
||||
import { symmetricDecrypt } from '@/utils/encryption'
|
||||
const { t } = useI18n()
|
||||
const typeMap = dsTypes.reduce((pre, next) => {
|
||||
pre[next.type] = next.name
|
||||
@ -54,82 +56,82 @@ const infoTemplateTime = ref()
|
||||
const templateList = ref<SettingRecord[]>([])
|
||||
const templateListTime = ref<SettingRecord[]>([])
|
||||
const getEngine = () => {
|
||||
getDeEngine().then(res => {
|
||||
let { id, type, configuration } = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(configuration)
|
||||
}
|
||||
|
||||
nodeInfoId = id
|
||||
|
||||
templateListTime.value = [
|
||||
{
|
||||
pkey: 'datasource.initial_pool_size',
|
||||
pval: configuration?.initialPoolSize || 5,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.min_pool_size',
|
||||
pval: configuration?.minPoolSize || 5,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.max_pool_size',
|
||||
pval: configuration?.maxPoolSize || 5,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.query_timeout',
|
||||
pval: `${configuration?.queryTimeout || 30}${t('common.second')}`,
|
||||
type: '',
|
||||
sort: 0
|
||||
querySymmetricKey().then(response => {
|
||||
getDeEngine().then(res => {
|
||||
let { id, type, configuration } = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(symmetricDecrypt(configuration, response.data))
|
||||
}
|
||||
]
|
||||
nodeInfoId = id
|
||||
templateListTime.value = [
|
||||
{
|
||||
pkey: 'datasource.initial_pool_size',
|
||||
pval: configuration?.initialPoolSize || 5,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.min_pool_size',
|
||||
pval: configuration?.minPoolSize || 5,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.max_pool_size',
|
||||
pval: configuration?.maxPoolSize || 5,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.query_timeout',
|
||||
pval: `${configuration?.queryTimeout || 30}${t('common.second')}`,
|
||||
type: '',
|
||||
sort: 0
|
||||
}
|
||||
]
|
||||
|
||||
templateList.value = [
|
||||
{
|
||||
pkey: t('system.engine_type'),
|
||||
pval: typeMap[type],
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.host',
|
||||
pval: configuration?.host,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.port',
|
||||
pval: configuration?.port,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.data_base',
|
||||
pval: configuration?.dataBase,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.user_name',
|
||||
pval: configuration?.username,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.extra_params',
|
||||
pval: configuration?.extraParams,
|
||||
type: '',
|
||||
sort: 0
|
||||
}
|
||||
]
|
||||
nextTick(() => {
|
||||
infoTemplate.value.init()
|
||||
infoTemplateTime.value.init()
|
||||
templateList.value = [
|
||||
{
|
||||
pkey: t('system.engine_type'),
|
||||
pval: typeMap[type],
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.host',
|
||||
pval: configuration?.host,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.port',
|
||||
pval: configuration?.port,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.data_base',
|
||||
pval: configuration?.dataBase,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.user_name',
|
||||
pval: configuration?.username,
|
||||
type: '',
|
||||
sort: 0
|
||||
},
|
||||
{
|
||||
pkey: 'datasource.extra_params',
|
||||
pval: configuration?.extraParams,
|
||||
type: '',
|
||||
sort: 0
|
||||
}
|
||||
]
|
||||
nextTick(() => {
|
||||
infoTemplate.value.init()
|
||||
infoTemplateTime.value.init()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -42,7 +42,13 @@ import { HandleMore } from '@/components/handle-more'
|
||||
import { Icon } from '@/components/icon-custom'
|
||||
import { fieldType } from '@/utils/attr'
|
||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||
import { getHidePwById, listSyncRecord, uploadFile, perDeleteDatasource } from '@/api/datasource'
|
||||
import {
|
||||
getHidePwById,
|
||||
listSyncRecord,
|
||||
uploadFile,
|
||||
perDeleteDatasource,
|
||||
getSimpleDs
|
||||
} from '@/api/datasource'
|
||||
import CreatDsGroup from './form/CreatDsGroup.vue'
|
||||
import type { Tree } from '../dataset/form/CreatDsGroup.vue'
|
||||
import { previewData, getById } from '@/api/datasource'
|
||||
@ -81,6 +87,8 @@ import { useEmbedded } from '@/store/modules/embedded'
|
||||
import { XpackComponent } from '@/components/plugin'
|
||||
import { iconFieldMap } from '@/components/icon-group/field-list'
|
||||
import { iconDatasourceMap } from '@/components/icon-group/datasource-list'
|
||||
import { querySymmetricKey } from '@/api/login'
|
||||
import { symmetricDecrypt } from '@/utils/encryption'
|
||||
const route = useRoute()
|
||||
const interactiveStore = interactiveStoreWithOut()
|
||||
interface Field {
|
||||
@ -458,6 +466,7 @@ const saveDsFolder = (params, successCb, finallyCb, cmd) => {
|
||||
|
||||
const dsLoading = ref(false)
|
||||
const mounted = ref(false)
|
||||
const symmetricKey = ref('')
|
||||
|
||||
const listDs = () => {
|
||||
rawDatasourceList.value = []
|
||||
@ -550,7 +559,11 @@ const handleNodeClick = data => {
|
||||
dsListTree.value.setCurrentKey(null)
|
||||
return
|
||||
}
|
||||
return getHidePwById(data.id).then(res => {
|
||||
let method = getHidePwById
|
||||
if (data.weight < 7) {
|
||||
method = getSimpleDs
|
||||
}
|
||||
return method(data.id).then(res => {
|
||||
let {
|
||||
name,
|
||||
createBy,
|
||||
@ -570,13 +583,13 @@ const handleNodeClick = data => {
|
||||
enableDataFill
|
||||
} = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(Base64.decode(configuration))
|
||||
}
|
||||
if (apiConfigurationStr) {
|
||||
apiConfigurationStr = JSON.parse(Base64.decode(apiConfigurationStr))
|
||||
configuration = JSON.parse(symmetricDecrypt(configuration, symmetricKey.value))
|
||||
}
|
||||
if (paramsStr) {
|
||||
paramsStr = JSON.parse(Base64.decode(paramsStr))
|
||||
paramsStr = JSON.parse(symmetricDecrypt(paramsStr, symmetricKey.value))
|
||||
}
|
||||
if (apiConfigurationStr) {
|
||||
apiConfigurationStr = JSON.parse(symmetricDecrypt(apiConfigurationStr, symmetricKey.value))
|
||||
}
|
||||
Object.assign(nodeInfo, {
|
||||
name,
|
||||
@ -697,13 +710,13 @@ const editDatasource = (editType?: number) => {
|
||||
enableDataFill
|
||||
} = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(Base64.decode(configuration))
|
||||
configuration = JSON.parse(symmetricDecrypt(configuration, symmetricKey.value))
|
||||
}
|
||||
if (paramsStr) {
|
||||
paramsStr = JSON.parse(Base64.decode(paramsStr))
|
||||
paramsStr = JSON.parse(symmetricDecrypt(paramsStr, symmetricKey.value))
|
||||
}
|
||||
if (apiConfigurationStr) {
|
||||
apiConfigurationStr = JSON.parse(Base64.decode(apiConfigurationStr))
|
||||
apiConfigurationStr = JSON.parse(symmetricDecrypt(apiConfigurationStr, symmetricKey.value))
|
||||
}
|
||||
let datasource = reactive<Node>(cloneDeep(defaultInfo))
|
||||
Object.assign(datasource, {
|
||||
@ -762,13 +775,13 @@ const handleCopy = async data => {
|
||||
lastSyncTime
|
||||
} = res.data
|
||||
if (configuration) {
|
||||
configuration = JSON.parse(Base64.decode(configuration))
|
||||
configuration = JSON.parse(symmetricDecrypt(configuration, symmetricKey.value))
|
||||
}
|
||||
if (paramsStr) {
|
||||
paramsStr = JSON.parse(Base64.decode(paramsStr))
|
||||
paramsStr = JSON.parse(symmetricDecrypt(paramsStr, symmetricKey.value))
|
||||
}
|
||||
if (apiConfigurationStr) {
|
||||
apiConfigurationStr = JSON.parse(Base64.decode(apiConfigurationStr))
|
||||
apiConfigurationStr = JSON.parse(symmetricDecrypt(apiConfigurationStr, symmetricKey.value))
|
||||
}
|
||||
let datasource = reactive<Node>(cloneDeep(defaultInfo))
|
||||
Object.assign(datasource, {
|
||||
@ -901,6 +914,7 @@ const operation = (cmd: string, data: Tree, nodeType: string) => {
|
||||
const handleClick = (tabName: TabPaneName) => {
|
||||
switch (tabName) {
|
||||
case 'config':
|
||||
tableData.value = []
|
||||
listDatasourceTables({ datasourceId: nodeInfo.id }).then(res => {
|
||||
tabList.value = res.data.map(ele => {
|
||||
const { name, tableName } = ele
|
||||
@ -979,6 +993,9 @@ onMounted(() => {
|
||||
if (opt && opt === 'create') {
|
||||
datasourceEditor.value.init(null, null)
|
||||
}
|
||||
querySymmetricKey().then(res => {
|
||||
symmetricKey.value = res.data
|
||||
})
|
||||
})
|
||||
|
||||
const sideTreeStatus = ref(true)
|
||||
@ -1433,7 +1450,9 @@ const getMenuList = (val: boolean) => {
|
||||
}}</BaseInfoItem>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<template v-if="!['Excel', 'API', 'es'].includes(nodeInfo.type)">
|
||||
<template
|
||||
v-if="!['Excel', 'API', 'es'].includes(nodeInfo.type) && nodeInfo.weight >= 7"
|
||||
>
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType !== 'jdbcUrl'">
|
||||
<el-col :span="12">
|
||||
<BaseInfoItem :label="t('datasource.host')">{{
|
||||
@ -1564,7 +1583,7 @@ const getMenuList = (val: boolean) => {
|
||||
</el-row>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="['es'].includes(nodeInfo.type)">
|
||||
<template v-if="['es'].includes(nodeInfo.type) && nodeInfo.weight >= 7">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<BaseInfoItem :label="t('datasource.datasource_url')">{{
|
||||
@ -1576,7 +1595,7 @@ const getMenuList = (val: boolean) => {
|
||||
</template>
|
||||
</BaseInfoContent>
|
||||
<BaseInfoContent
|
||||
v-if="nodeInfo.type === 'API'"
|
||||
v-if="nodeInfo.type === 'API' && nodeInfo.weight >= 7"
|
||||
v-slot="slotProps"
|
||||
:name="t('datasource.data_table')"
|
||||
>
|
||||
@ -1633,7 +1652,7 @@ const getMenuList = (val: boolean) => {
|
||||
</el-button>
|
||||
</BaseInfoContent>
|
||||
<BaseInfoContent
|
||||
v-if="nodeInfo.type === 'API'"
|
||||
v-if="nodeInfo.type === 'API' && nodeInfo.weight >= 7"
|
||||
v-slot="slotProps"
|
||||
:name="t('dataset.update_setting')"
|
||||
:time="(nodeInfo.lastSyncTime as string)"
|
||||
|
||||
@ -5,6 +5,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author wangjiahao
|
||||
@ -26,4 +27,6 @@ public class ChartExcelRequest extends ChartExcelRequestInner {
|
||||
|
||||
private String downloadType;
|
||||
|
||||
private Map<String, Object> data;
|
||||
|
||||
}
|
||||
|
||||
@ -87,16 +87,21 @@ public interface DatasourceApi {
|
||||
@Operation(summary = "删除")
|
||||
void delete(@PathVariable("datasourceId") Long datasourceId) throws DEException;
|
||||
|
||||
@DePermit({"#p0+':read'"})
|
||||
@DePermit({"#p0+':manage'"})
|
||||
@GetMapping("/get/{datasourceId}")
|
||||
@Operation(summary = "数据源详情")
|
||||
DatasourceDTO get(@PathVariable("datasourceId") Long datasourceId) throws DEException;
|
||||
|
||||
@DePermit({"#p0+':read'"})
|
||||
@DePermit({"#p0+':manage'"})
|
||||
@GetMapping("/hidePw/{datasourceId}")
|
||||
@Operation(summary = "数据源详情")
|
||||
DatasourceDTO hidePw(@PathVariable("datasourceId") Long datasourceId) throws DEException;
|
||||
|
||||
@DePermit({"#p0+':read'"})
|
||||
@GetMapping("/getSimpleDs/{datasourceId}")
|
||||
@Operation(summary = "数据源详情")
|
||||
DatasourceDTO getSimpleDs(@PathVariable("datasourceId") Long datasourceId) throws DEException;
|
||||
|
||||
|
||||
@PostMapping("/getTableField")
|
||||
@Operation(summary = "获取表字段")
|
||||
|
||||
@ -8,9 +8,11 @@ import io.dataease.rsa.manage.RsaManage;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
@ -176,7 +178,7 @@ public class RsaUtils {
|
||||
return pk + separator + aesKey;
|
||||
}
|
||||
|
||||
private static final String IV_KEY = "0000000000000000";
|
||||
public static final String IV_KEY = "0000000000000000";
|
||||
|
||||
private static String generateAesKey() {
|
||||
return RandomStringUtils.randomAlphanumeric(16);
|
||||
@ -200,4 +202,53 @@ public class RsaUtils {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static final String ALGORITHM = "AES";
|
||||
public static String symmetricKey = null;
|
||||
private static final int KEY_SIZE = 128;
|
||||
|
||||
|
||||
public static String generateSymmetricKey() {
|
||||
try {
|
||||
if (StringUtils.isEmpty(symmetricKey)) {
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance(ALGORITHM);
|
||||
keyGenerator.init(KEY_SIZE, new SecureRandom());
|
||||
SecretKey secretKey = keyGenerator.generateKey();
|
||||
symmetricKey = Base64.getEncoder().encodeToString(secretKey.getEncoded());
|
||||
}
|
||||
return symmetricKey;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String symmetricEncrypt(String data) {
|
||||
try {
|
||||
byte[] iv = IV_KEY.getBytes(StandardCharsets.UTF_8);
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(Base64.getDecoder().decode(generateSymmetricKey()), ALGORITHM);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
byte[] ciphertext = cipher.doFinal(data.getBytes("UTF-8"));
|
||||
return Base64.getEncoder().encodeToString(ciphertext);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String symmetricDecrypt(String data) {
|
||||
try {
|
||||
byte[] iv = IV_KEY.getBytes(StandardCharsets.UTF_8);
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(Base64.getDecoder().decode(generateSymmetricKey()), ALGORITHM);
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
byte[] decodedCiphertext = Base64.getDecoder().decode(data);
|
||||
byte[] decryptedText = cipher.doFinal(decodedCiphertext);
|
||||
return new String(decryptedText, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ public class WhitelistUtils {
|
||||
"/login/localLogin",
|
||||
"/apisix/check",
|
||||
"/dekey",
|
||||
"/symmetricKey",
|
||||
"/index.html",
|
||||
"/model",
|
||||
"/xpackModel",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user