forked from github/dataease
Merge branch 'dev' into pr@dev_memory_component
This commit is contained in:
commit
c02d6bdb4b
@ -7,6 +7,7 @@ import io.dataease.auth.annotation.DeLog;
|
||||
import io.dataease.auth.annotation.DePermission;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.constants.SysAuthConstants;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
@ -18,10 +19,15 @@ import io.dataease.dto.DatasourceDTO;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.dto.datasource.DBTableDTO;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.base.domain.DatasourceExample;
|
||||
import io.dataease.plugins.common.dto.datasource.DataSourceType;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
@ -30,6 +36,7 @@ import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "数据源:数据源管理")
|
||||
@ -65,8 +72,21 @@ public class DatasourceController {
|
||||
positionIndex = 0, positionKey = "type",
|
||||
value = "id"
|
||||
)
|
||||
public void updateDatasource(@RequestBody UpdataDsRequest dsRequest) throws Exception {
|
||||
datasourceService.updateDatasource(dsRequest);
|
||||
public void updateDatasource(@RequestBody UpdataDsRequest updataDsRequest) throws Exception {
|
||||
DatasourceDTO datasource = new DatasourceDTO();
|
||||
datasource.setConfigurationEncryption(updataDsRequest.isConfigurationEncryption());
|
||||
datasource.setName(updataDsRequest.getName());
|
||||
datasource.setDesc(updataDsRequest.getDesc());
|
||||
datasource.setConfiguration(updataDsRequest.getConfiguration());
|
||||
datasource.setCreateTime(null);
|
||||
datasource.setType(updataDsRequest.getType());
|
||||
datasource.setUpdateTime(System.currentTimeMillis());
|
||||
datasourceService.preCheckDs(datasource);
|
||||
if (StringUtils.isNotEmpty(updataDsRequest.getId())) {
|
||||
datasourceService.updateDatasource(updataDsRequest.getId(), datasource);
|
||||
} else {
|
||||
datasourceService.insert(datasource);
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermissions("datasource:read")
|
||||
|
@ -824,7 +824,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
if(isTable){
|
||||
return "SELECT COUNT(*) from " + String.format(CKConstants.KEYWORD_TABLE, sql);
|
||||
}else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -810,12 +810,12 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
|
||||
|
||||
public String getTotalCount(boolean isTable, String sql, Datasource ds) {
|
||||
if(isTable){
|
||||
if (isTable) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
schema = String.format(Db2Constants.KEYWORD_TABLE, schema);
|
||||
return "SELECT COUNT(*) from " + schema + "." + String.format(Db2Constants.KEYWORD_TABLE, sql);
|
||||
}else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
} else {
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
@ -828,7 +828,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}).toArray(String[]::new);
|
||||
if (ds != null) {
|
||||
Db2Configuration db2Configuration = new Gson().fromJson(ds.getConfiguration(), Db2Configuration.class);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_OFFSET, DE_PAGE_SIZE ", StringUtils.join(array, ","), db2Configuration.getSchema() + String.format(Db2Constants.KEYWORD_TABLE, table));
|
||||
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_OFFSET, DE_PAGE_SIZE ", StringUtils.join(array, ","), String.format(Db2Constants.KEYWORD_TABLE, db2Configuration.getSchema()) + "." + String.format(Db2Constants.KEYWORD_TABLE, table));
|
||||
} else {
|
||||
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_OFFSET, DE_PAGE_SIZE ", StringUtils.join(array, ","), table);
|
||||
}
|
||||
|
@ -1,15 +1,19 @@
|
||||
package io.dataease.provider.query.doris;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.constants.datasource.MySQLConstants;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.datasource.entity.PageInfo;
|
||||
import io.dataease.provider.query.mysql.MysqlQueryProvider;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -17,9 +21,9 @@ import java.util.List;
|
||||
public class DorisQueryProvider extends MysqlQueryProvider {
|
||||
|
||||
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
if(isTable){
|
||||
if (isTable) {
|
||||
return getSQLTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view);
|
||||
}else {
|
||||
} else {
|
||||
return getSQLAsTmpTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view);
|
||||
}
|
||||
}
|
||||
@ -28,4 +32,23 @@ public class DorisQueryProvider extends MysqlQueryProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createRawQuerySQL(String table, List<DatasetTableField> fields, Datasource ds) {
|
||||
String[] array = fields.stream().map(f -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (f.getDeExtractType() == 4) { // 处理 tinyint
|
||||
stringBuilder.append("concat(`").append(f.getOriginName()).append("`,'') AS ").append(f.getDataeaseName());
|
||||
} else if (f.getDeExtractType() == 1 && f.getType().equalsIgnoreCase("YEAR")) { // 处理 YEAR
|
||||
stringBuilder.append("").append(String.format(MySQLConstants.DATE_FORMAT, "CONCAT(" + f.getOriginName() + ",'-01-01')", MySQLConstants.DEFAULT_DATE_FORMAT)).append(" AS ").append(f.getDataeaseName());
|
||||
} else {
|
||||
stringBuilder.append("`").append(f.getOriginName()).append("` AS ").append(f.getDataeaseName());
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}).toArray(String[]::new);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), table);
|
||||
}
|
||||
|
||||
public String getTotalCount(boolean isTable, String sql, Datasource ds) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -774,7 +774,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
if(isTable){
|
||||
return "SELECT COUNT(*) from " + String.format(HiveConstants.KEYWORD_TABLE, sql);
|
||||
}else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,7 +772,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
if(isTable){
|
||||
return "SELECT COUNT(*) from " + String.format(ImpalaConstants.KEYWORD_TABLE, sql);
|
||||
}else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -815,7 +815,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
if(isTable){
|
||||
return "SELECT COUNT(*) from " + String.format(MySQLConstants.KEYWORD_TABLE, sql);
|
||||
}else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1123,6 +1123,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String sqlFix(String sql) {
|
||||
sql = sql.trim();
|
||||
if (sql.lastIndexOf(";") == (sql.length() - 1)) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
schema = String.format(OracleConstants.KEYWORD_TABLE, schema);
|
||||
return "SELECT COUNT(*) from " + schema + "." + String.format(OracleConstants.KEYWORD_TABLE, sql);
|
||||
} else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -803,10 +803,10 @@ public class PgQueryProvider extends QueryProvider {
|
||||
public String getTotalCount(boolean isTable, String sql, Datasource ds) {
|
||||
if(isTable){
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, sql);
|
||||
return "SELECT COUNT(*) from " + String.format(PgConstants.KEYWORD_TABLE, tableWithSchema);
|
||||
String tableWithSchema = String.format(PgConstants.KEYWORD_TABLE, schema) + "." + String.format(PgConstants.KEYWORD_TABLE, sql);
|
||||
return "SELECT COUNT(*) from " + tableWithSchema;
|
||||
}else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -813,7 +813,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, sql);
|
||||
return "SELECT COUNT(*) from " + String.format(ImpalaConstants.KEYWORD_TABLE, tableWithSchema);
|
||||
}else {
|
||||
return "SELECT COUNT(*) from ( " + sql + " ) DE_COUNT_TEMP";
|
||||
return "SELECT COUNT(*) from ( " + sqlFix(sql) + " ) DE_COUNT_TEMP";
|
||||
}
|
||||
}
|
||||
|
||||
@ -826,7 +826,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}).toArray(String[]::new);
|
||||
if (ds != null) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table);
|
||||
String tableWithSchema = String.format(RedshiftConstants.KEYWORD_TABLE, schema) + "." + String.format(RedshiftConstants.KEYWORD_TABLE, table);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_PAGE_SIZE OFFSET DE_OFFSET ", StringUtils.join(array, ","), tableWithSchema);
|
||||
} else {
|
||||
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_PAGE_SIZE OFFSET DE_OFFSET ", StringUtils.join(array, ","), table);
|
||||
|
@ -1123,6 +1123,31 @@ public class DataSetTableService {
|
||||
}
|
||||
plainSelect.setFromItem(subSelect);
|
||||
}
|
||||
List<Join> joins = plainSelect.getJoins();
|
||||
if (joins != null) {
|
||||
for (Join join : joins) {
|
||||
FromItem rightItem = join.getRightItem();
|
||||
if (rightItem instanceof SubSelect) {
|
||||
SelectBody selectBody = ((SubSelect) rightItem).getSelectBody();
|
||||
SubSelect subSelect = new SubSelect();
|
||||
Select subSelectTmp = (Select) CCJSqlParserUtil.parse(removeVariables(selectBody.toString(), dsType));
|
||||
PlainSelect subPlainSelect = ((PlainSelect) subSelectTmp.getSelectBody());
|
||||
subSelect.setSelectBody(subPlainSelect);
|
||||
if (dsType.equals(DatasourceTypes.oracle.getType())) {
|
||||
subSelect.setAlias(new Alias(rightItem.getAlias().toString(), false));
|
||||
} else {
|
||||
if (rightItem.getAlias() == null) {
|
||||
throw new Exception("Failed to parse sql, Every derived table must have its own alias!");
|
||||
}
|
||||
subSelect.setAlias(new Alias(rightItem.getAlias().toString()));
|
||||
}
|
||||
List<Join> joinsList = new ArrayList<>();
|
||||
join.setRightItem(subSelect);
|
||||
joinsList.add(join);
|
||||
plainSelect.setJoins(joinsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
Expression expr = plainSelect.getWhere();
|
||||
if (expr == null) {
|
||||
return handleWith(plainSelect, statementSelect, dsType);
|
||||
@ -2375,13 +2400,13 @@ public class DataSetTableService {
|
||||
String suffix = filename.substring(filename.lastIndexOf(".") + 1);
|
||||
if (StringUtils.equalsIgnoreCase(suffix, "xls")) {
|
||||
ExcelXlsReader excelXlsReader = new ExcelXlsReader();
|
||||
excelXlsReader.setObtainedNum(100);
|
||||
excelXlsReader.setObtainedNum(1000);
|
||||
excelXlsReader.process(inputStream);
|
||||
excelSheetDataList = excelXlsReader.totalSheets;
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) {
|
||||
ExcelXlsxReader excelXlsxReader = new ExcelXlsxReader();
|
||||
excelXlsxReader.setObtainedNum(100);
|
||||
excelXlsxReader.setObtainedNum(1000);
|
||||
excelXlsxReader.process(inputStream);
|
||||
excelSheetDataList = excelXlsxReader.totalSheets;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public class ExtractDataService {
|
||||
for (DatasetTableField oldField : oldFields) {
|
||||
boolean delete = true;
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
if (oldField.getDataeaseName().equalsIgnoreCase(datasetTableField.getDataeaseName()) && oldField.getDeExtractType().equals(datasetTableField.getDeExtractType())) {
|
||||
if (oldField.getDataeaseName().equalsIgnoreCase(datasetTableField.getDataeaseName())) {
|
||||
delete = false;
|
||||
}
|
||||
}
|
||||
@ -220,7 +220,7 @@ public class ExtractDataService {
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
boolean add = true;
|
||||
for (DatasetTableField oldField : oldFields) {
|
||||
if (oldField.getDataeaseName().equalsIgnoreCase(datasetTableField.getDataeaseName()) && oldField.getDeExtractType().equals(datasetTableField.getDeExtractType())) {
|
||||
if (oldField.getDataeaseName().equalsIgnoreCase(datasetTableField.getDataeaseName())) {
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
|
@ -105,16 +105,12 @@ public class DatasourceService {
|
||||
@DeCleaner(DePermissionType.DATASOURCE)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Datasource addDatasource(DatasourceDTO datasource) throws Exception {
|
||||
if (!types().stream().map(DataSourceType::getType).collect(Collectors.toList()).contains(datasource.getType())) {
|
||||
throw new Exception("Datasource type not supported.");
|
||||
}
|
||||
if(datasource.isConfigurationEncryption()){
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
}
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
datasourceProvider.checkConfiguration(datasource);
|
||||
preCheckDs(datasource);
|
||||
return insert(datasource);
|
||||
}
|
||||
|
||||
checkName(datasource.getName(), datasource.getType(), datasource.getId());
|
||||
@DeCleaner(DePermissionType.DATASOURCE)
|
||||
public DatasourceDTO insert(DatasourceDTO datasource) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
datasource.setId(UUID.randomUUID().toString());
|
||||
datasource.setUpdateTime(currentTimeMillis);
|
||||
@ -127,6 +123,17 @@ public class DatasourceService {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public void preCheckDs(DatasourceDTO datasource) throws Exception {
|
||||
if (!types().stream().map(DataSourceType::getType).collect(Collectors.toList()).contains(datasource.getType())) {
|
||||
throw new Exception("Datasource type not supported.");
|
||||
}
|
||||
if (datasource.isConfigurationEncryption()) {
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
}
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
datasourceProvider.checkConfiguration(datasource);
|
||||
checkName(datasource.getName(), datasource.getType(), datasource.getId());
|
||||
}
|
||||
|
||||
public void handleConnectionPool(String datasourceId, String type) {
|
||||
Datasource datasource = datasourceMapper.selectByPrimaryKey(datasourceId);
|
||||
@ -159,7 +166,7 @@ public class DatasourceService {
|
||||
return datasourceDTOS;
|
||||
}
|
||||
|
||||
private void datasourceTrans(DatasourceDTO datasourceDTO){
|
||||
private void datasourceTrans(DatasourceDTO datasourceDTO) {
|
||||
types().forEach(dataSourceType -> {
|
||||
if (dataSourceType.getType().equalsIgnoreCase(datasourceDTO.getType())) {
|
||||
datasourceDTO.setTypeDesc(dataSourceType.getName());
|
||||
@ -214,23 +221,24 @@ public class DatasourceService {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotEmpty(datasourceDTO.getConfiguration())){
|
||||
if (StringUtils.isNotEmpty(datasourceDTO.getConfiguration())) {
|
||||
datasourceDTO.setConfiguration(new String(java.util.Base64.getEncoder().encode(datasourceDTO.getConfiguration().getBytes())));
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(datasourceDTO.getApiConfiguration())){
|
||||
if (CollectionUtils.isNotEmpty(datasourceDTO.getApiConfiguration())) {
|
||||
String config = new Gson().toJson(datasourceDTO.getApiConfiguration());
|
||||
datasourceDTO.setApiConfigurationStr(new String(java.util.Base64.getEncoder().encode(config.getBytes())));
|
||||
datasourceDTO.setApiConfiguration(null);
|
||||
}
|
||||
}
|
||||
|
||||
public DatasourceDTO getDataSourceDetails(String datasourceId){
|
||||
DatasourceDTO result = extDataSourceMapper.queryDetails(datasourceId,String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
if(result != null){
|
||||
public DatasourceDTO getDataSourceDetails(String datasourceId) {
|
||||
DatasourceDTO result = extDataSourceMapper.queryDetails(datasourceId, String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
if (result != null) {
|
||||
this.datasourceTrans(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DatasourceDTO> gridQuery(BaseGridRequest request) {
|
||||
//如果没有查询条件增加一个默认的条件
|
||||
if (CollectionUtils.isEmpty(request.getConditions())) {
|
||||
@ -260,12 +268,6 @@ public class DatasourceService {
|
||||
}
|
||||
|
||||
public void updateDatasource(UpdataDsRequest updataDsRequest) throws Exception {
|
||||
if (!types().stream().map(DataSourceType::getType).collect(Collectors.toList()).contains(updataDsRequest.getType())) {
|
||||
throw new Exception("Datasource type not supported.");
|
||||
}
|
||||
if(updataDsRequest.isConfigurationEncryption()){
|
||||
updataDsRequest.setConfiguration(new String(java.util.Base64.getDecoder().decode(updataDsRequest.getConfiguration())));
|
||||
}
|
||||
checkName(updataDsRequest.getName(), updataDsRequest.getType(), updataDsRequest.getId());
|
||||
Datasource datasource = new Datasource();
|
||||
datasource.setName(updataDsRequest.getName());
|
||||
@ -277,19 +279,15 @@ public class DatasourceService {
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(updataDsRequest.getType());
|
||||
datasourceProvider.checkConfiguration(datasource);
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
if(StringUtils.isNotEmpty(updataDsRequest.getId())){
|
||||
DatasourceExample example = new DatasourceExample();
|
||||
example.createCriteria().andIdEqualTo(updataDsRequest.getId());
|
||||
datasourceMapper.updateByExampleSelective(datasource, example);
|
||||
handleConnectionPool(updataDsRequest.getId());
|
||||
}else {
|
||||
datasource.setId(UUID.randomUUID().toString());
|
||||
datasource.setCreateTime(System.currentTimeMillis());
|
||||
datasourceMapper.insert(datasource);
|
||||
handleConnectionPool(datasource, "add");
|
||||
sysAuthService.copyAuth(datasource.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASOURCE);
|
||||
}
|
||||
updateDatasource(updataDsRequest.getId(), datasource);
|
||||
}
|
||||
|
||||
|
||||
public void updateDatasource(String id, Datasource datasource) {
|
||||
DatasourceExample example = new DatasourceExample();
|
||||
example.createCriteria().andIdEqualTo(id);
|
||||
datasourceMapper.updateByExampleSelective(datasource, example);
|
||||
handleConnectionPool(id);
|
||||
}
|
||||
|
||||
private void handleConnectionPool(String datasourceId) {
|
||||
@ -304,7 +302,7 @@ public class DatasourceService {
|
||||
}
|
||||
|
||||
public ResultHolder validate(DatasourceDTO datasource) throws Exception {
|
||||
if(datasource.isConfigurationEncryption()){
|
||||
if (datasource.isConfigurationEncryption()) {
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
}
|
||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||
@ -395,7 +393,7 @@ public class DatasourceService {
|
||||
}
|
||||
|
||||
public List<String> getSchema(DatasourceDTO datasource) throws Exception {
|
||||
if(datasource.isConfigurationEncryption()){
|
||||
if (datasource.isConfigurationEncryption()) {
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
}
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
@ -519,7 +517,7 @@ public class DatasourceService {
|
||||
return datasourceMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
|
||||
private void checkAndUpdateDatasourceStatus(Datasource datasource) {
|
||||
public void checkAndUpdateDatasourceStatus(Datasource datasource) {
|
||||
try {
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
|
@ -71,7 +71,10 @@
|
||||
@click="redo"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="$t('panel.fullscreen_preview')">
|
||||
<el-tooltip
|
||||
v-if="!isOtherPlatform"
|
||||
:content="$t('panel.fullscreen_preview')"
|
||||
>
|
||||
<svg-icon
|
||||
icon-class="icon_magnify_outlined"
|
||||
class="toolbar-icon-active icon16"
|
||||
@ -235,7 +238,7 @@ import { panelUpdate, removePanelCache, saveCache } from '@/api/panel/panel'
|
||||
import { getPanelAllLinkageInfo, saveLinkage } from '@/api/panel/linkage'
|
||||
import bus from '@/utils/bus'
|
||||
import { queryPanelJumpInfo } from '@/api/panel/linkJump'
|
||||
|
||||
import { inOtherPlatform } from '@/utils/index'
|
||||
export default {
|
||||
name: 'Toolbar',
|
||||
props: {
|
||||
@ -274,6 +277,9 @@ export default {
|
||||
editControlButton() {
|
||||
return this.linkageSettingStatus || this.mobileLayoutStatus
|
||||
},
|
||||
isOtherPlatform() {
|
||||
return inOtherPlatform()
|
||||
},
|
||||
...mapState([
|
||||
'componentData',
|
||||
'canvasStyleData',
|
||||
|
@ -121,7 +121,7 @@
|
||||
:canvas-id="canvasId"
|
||||
/>
|
||||
<!-- 右击菜单 -->
|
||||
<ContextMenu />
|
||||
<ContextMenu/>
|
||||
|
||||
<!-- 对齐标线 -->
|
||||
<span
|
||||
@ -667,8 +667,8 @@ function setPlayerPosition(item, position) {
|
||||
item.y = targetY
|
||||
|
||||
// 还原到像素
|
||||
item.style.left = ((item.x - 1) * this.matrixStyle.width) / this.scalePointWidth
|
||||
item.style.top = ((item.y - 1) * this.matrixStyle.height) / this.scalePointHeight
|
||||
item.style.left = (item.x - 1) / this.matrixScaleWidth
|
||||
item.style.top = (item.y - 1) / this.matrixScaleHeight
|
||||
if (item.y + item.sizey > itemMaxY) {
|
||||
itemMaxY = item.y + item.sizey
|
||||
}
|
||||
@ -906,6 +906,12 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
matrixScaleWidth() {
|
||||
return this.scalePointWidth / this.matrixStyle.width
|
||||
},
|
||||
matrixScaleHeight() {
|
||||
return this.scalePointHeight / this.matrixStyle.height
|
||||
},
|
||||
moveTabCollisionActive() {
|
||||
return this.tabCollisionActiveId
|
||||
},
|
||||
@ -1609,37 +1615,35 @@ export default {
|
||||
const startY = infoBox.startY
|
||||
const moveXSize = e.pageX - startX // X方向移动的距离
|
||||
const moveYSize = e.pageY - startY // Y方向移动的距离
|
||||
|
||||
const addSizex = (moveXSize) % vm.cellWidth > (vm.cellWidth / 4 * 1) ? parseInt(((moveXSize) / vm.cellWidth + 1)) : parseInt(((moveXSize) / vm.cellWidth))
|
||||
const addSizey = (moveYSize) % vm.cellHeight > (vm.cellHeight / 4 * 1) ? parseInt(((moveYSize) / vm.cellHeight + 1)) : parseInt(((moveYSize) / vm.cellHeight))
|
||||
let nowX = Math.round((item.style.width * this.scalePointWidth) / this.matrixStyle.width)
|
||||
let nowY = Math.round((item.style.height * this.scalePointHeight) / this.matrixStyle.height)
|
||||
let nowX = Math.round(item.style.width * this.matrixScaleWidth)
|
||||
let nowY = Math.round(item.style.height * this.matrixScaleHeight)
|
||||
nowX = nowX > 0 ? nowX : 1
|
||||
nowY = nowY > 0 ? nowY : 1
|
||||
|
||||
const oldX = infoBox.oldX
|
||||
const oldY = infoBox.oldY
|
||||
let newX = Math.round((item.style.left * this.scalePointWidth) / this.matrixStyle.width) + 1
|
||||
let newY = Math.round((item.style.top * this.scalePointHeight) / this.matrixStyle.height) + 1
|
||||
let newX = Math.round(item.style.left * this.matrixScaleWidth) + 1
|
||||
let newY = Math.round(item.style.top * this.matrixScaleHeight) + 1
|
||||
newX = newX > 0 ? newX : 1
|
||||
newY = newY > 0 ? newY : 1
|
||||
debounce((function(newX, oldX, newY, oldY, addSizex, addSizey) {
|
||||
return function() {
|
||||
if (newX !== oldX || oldY !== newY) {
|
||||
movePlayer.call(vm, resizeItem, {
|
||||
x: newX,
|
||||
y: newY
|
||||
if (item.sizex !== nowX || item.sizey !== nowY) {
|
||||
debounce((function(newX, oldX, newY, oldY) {
|
||||
return function() {
|
||||
if (newX !== oldX || oldY !== newY) {
|
||||
movePlayer.call(vm, resizeItem, {
|
||||
x: newX,
|
||||
y: newY
|
||||
})
|
||||
infoBox.oldX = newX
|
||||
infoBox.oldY = newY
|
||||
}
|
||||
resizePlayer.call(vm, resizeItem, {
|
||||
sizex: nowX,
|
||||
sizey: nowY
|
||||
})
|
||||
|
||||
infoBox.oldX = newX
|
||||
infoBox.oldY = newY
|
||||
}
|
||||
resizePlayer.call(vm, resizeItem, {
|
||||
sizex: nowX,
|
||||
sizey: nowY
|
||||
})
|
||||
}
|
||||
})(newX, oldX, newY, oldY, addSizex, addSizey), 10)
|
||||
})(newX, oldX, newY, oldY), 10)
|
||||
}
|
||||
},
|
||||
onDragging(e, item) {
|
||||
const infoBox = this.infoBox
|
||||
@ -1659,19 +1663,21 @@ export default {
|
||||
if (this.moveTabCollisionActive) {
|
||||
return
|
||||
}
|
||||
debounce((function(newX, oldX, newY, oldY) {
|
||||
return function() {
|
||||
if (newX !== oldX || oldY !== newY) {
|
||||
movePlayer.call(vm, moveItem, {
|
||||
x: newX,
|
||||
y: newY
|
||||
})
|
||||
if (newX !== oldX || oldY !== newY) {
|
||||
debounce((function(newX, oldX, newY, oldY) {
|
||||
return function() {
|
||||
if (newX !== oldX || oldY !== newY) {
|
||||
movePlayer.call(vm, moveItem, {
|
||||
x: newX,
|
||||
y: newY
|
||||
})
|
||||
|
||||
infoBox.oldX = newX
|
||||
infoBox.oldY = newY
|
||||
infoBox.oldX = newX
|
||||
infoBox.oldY = newY
|
||||
}
|
||||
}
|
||||
}
|
||||
})(newX, oldX, newY, oldY), 10)
|
||||
})(newX, oldX, newY, oldY), 10)
|
||||
}
|
||||
},
|
||||
endMove(e) {
|
||||
|
||||
|
@ -1480,7 +1480,7 @@ export default {
|
||||
this.hasMove && this.$store.commit('recordSnapshot', 'handleUp')
|
||||
// 记录snapshot后 移动已记录设置为false
|
||||
this.hasMove = false
|
||||
}, 100)
|
||||
}, 200)
|
||||
} else {
|
||||
this.hasMove && this.$store.commit('recordSnapshot', 'handleUp')
|
||||
// 记录snapshot后 移动已记录设置为false
|
||||
|
@ -940,7 +940,7 @@ export default {
|
||||
this.sql = ''
|
||||
return
|
||||
}
|
||||
if (this.incrementalConfig.incrementalAdd.length > 0) {
|
||||
if (this.incrementalConfig?.incrementalAdd?.length > 0) {
|
||||
this.incrementalUpdateType = 'incrementalAdd'
|
||||
this.sql = this.incrementalConfig.incrementalAdd
|
||||
} else {
|
||||
|
@ -17,7 +17,7 @@
|
||||
style="border-bottom: 1px solid;border-bottom-color:#E6E6E6;"
|
||||
>
|
||||
<div style="height: 100%;">
|
||||
<share-head/>
|
||||
<share-head />
|
||||
</div>
|
||||
</el-row>
|
||||
<el-row
|
||||
@ -76,7 +76,7 @@
|
||||
width="400"
|
||||
trigger="click"
|
||||
>
|
||||
<panel-detail-info/>
|
||||
<panel-detail-info />
|
||||
<i
|
||||
slot="reference"
|
||||
class="el-icon-warning-outline icon-class"
|
||||
@ -98,7 +98,10 @@
|
||||
</de-btn>
|
||||
</span>
|
||||
|
||||
<span v-if="showType !== 1" style="float: right;margin-right: 10px">
|
||||
<span
|
||||
v-if="showType !== 1"
|
||||
style="float: right;margin-right: 10px"
|
||||
>
|
||||
<de-btn
|
||||
secondary
|
||||
@click="share"
|
||||
@ -108,7 +111,7 @@
|
||||
</span>
|
||||
|
||||
<span
|
||||
v-if="panelInfo.status==='publish'"
|
||||
v-if="panelInfo.status==='publish' && !isOtherPlatform"
|
||||
style="float: right;margin-right: 10px"
|
||||
>
|
||||
<de-btn
|
||||
@ -141,7 +144,7 @@
|
||||
class="de-card-dropdown"
|
||||
>
|
||||
<el-dropdown-item
|
||||
v-if="panelInfo.status==='publish'"
|
||||
v-if="panelInfo.status==='publish' && !isOtherPlatform"
|
||||
@click.native="newTab"
|
||||
>
|
||||
<svg-icon
|
||||
@ -181,8 +184,8 @@
|
||||
</el-dropdown-item>
|
||||
|
||||
<el-dropdown
|
||||
style="width: 100%"
|
||||
v-if="hasDataPermission('export',panelInfo.privileges)&&panelInfo.status==='publish'"
|
||||
style="width: 100%"
|
||||
trigger="hover"
|
||||
placement="right-start"
|
||||
>
|
||||
@ -388,7 +391,7 @@ import PanelDetailInfo from '@/views/panel/list/common/PanelDetailInfo'
|
||||
import AppExportForm from '@/views/panel/list/AppExportForm'
|
||||
import GrantAuth from '../grantAuth'
|
||||
import msgCfm from '@/components/msgCfm/index'
|
||||
|
||||
import { inOtherPlatform } from '@/utils/index'
|
||||
export default {
|
||||
name: 'PanelViewShow',
|
||||
components: { AppExportForm, PanelDetailInfo, Preview, SaveToTemplate, PDFPreExport, ShareHead, GrantAuth },
|
||||
@ -446,6 +449,9 @@ export default {
|
||||
panelInfo() {
|
||||
return this.$store.state.panel.panelInfo
|
||||
},
|
||||
isOtherPlatform() {
|
||||
return inOtherPlatform()
|
||||
},
|
||||
...mapState([
|
||||
'componentData',
|
||||
'canvasStyleData',
|
||||
|
Loading…
Reference in New Issue
Block a user