Merge branch 'dev-v2' into pr@dev-v2_dzz

This commit is contained in:
dataeaseShu 2023-10-27 15:17:41 +08:00
commit f82d9ad3e7
20 changed files with 491 additions and 45 deletions

View File

@ -14,18 +14,18 @@ public class MybatisPlusGenerator {
* 第一 我嫌麻烦
* 第二 后面配置会放到nacos读起来更麻烦了
*/
private static final String url = "jdbc:mysql://39.98.78.97:3306/dataease?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false";
private static final String url = "jdbc:mysql://127.0.0.1:3306/de_standalone?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false";
private static final String username = "root";
private static final String password = "Password123@mysql";
/**
* 业务模块例如datasource,dataset,panel等
*/
private static final String busi = "operation";
private static final String busi = "system";
/**
* 这是要生成代码的表名称
*/
private static final String TABLE_NAME = "core_opt_recent";
private static final String TABLE_NAME = "core_sys_setting";
/**
* 下面两个配置基本上不用动

View File

@ -290,7 +290,7 @@ public class DatasetDataManage {
if (ObjectUtils.isEmpty(list)) {
return null;
}
sql = SQLUtils.buildOriginPreviewSqlWithOrderBy(sql, 100, 0, list.get(0).getOriginName() + " ASC ");
sql = SQLUtils.buildOriginPreviewSqlWithOrderBy(sql, 100, 0, String.format(SQLConstants.FIELD_DOT, list.get(0).getOriginName()) + " ASC ");
} else {
sql = SQLUtils.buildOriginPreviewSql(sql, 100, 0);
}

View File

@ -34,6 +34,7 @@ import io.dataease.datasource.provider.ApiUtils;
import io.dataease.datasource.provider.CalciteProvider;
import io.dataease.datasource.provider.ExcelUtils;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.datasource.type.Pg;
import io.dataease.engine.constant.SQLConstants;
import io.dataease.exception.DEException;
import io.dataease.i18n.Translator;
@ -265,7 +266,9 @@ public class DatasourceServer implements DatasourceApi {
DEException.throwException("Failed to create table " + datasourceRequest.getTable());
}
}
datasourceSyncManage.extractExcelData(coreDatasource, "all_scope");
commonThreadPool.addTask(() -> {
datasourceSyncManage.extractExcelData(coreDatasource, "all_scope");
});
} else if (dataSourceDTO.getType().equals(DatasourceConfiguration.DatasourceType.API.name())) {
CoreDatasourceTask coreDatasourceTask = new CoreDatasourceTask();
BeanUtils.copyBean(coreDatasourceTask, dataSourceDTO.getSyncSetting());
@ -298,11 +301,28 @@ public class DatasourceServer implements DatasourceApi {
}
}
} else {
checkParams(dataSourceDTO.getConfiguration());
calciteProvider.update(dataSourceDTO);
}
return dataSourceDTO;
}
private static void checkParams(String configurationStr) {
DatasourceConfiguration configuration = JsonUtil.parseObject(configurationStr, DatasourceConfiguration.class);
if(configuration.getInitialPoolSize() < configuration.getMinPoolSize()){
DEException.throwException("初始连接数不能小于最小连接数!");
}
if(configuration.getInitialPoolSize() > configuration.getMaxPoolSize()){
DEException.throwException("初始连接数不能大于最大连接数!");
}
if(configuration.getMaxPoolSize() < configuration.getMinPoolSize()){
DEException.throwException("最大连接数不能小于最小连接数!");
}
if(configuration.getQueryTimeout() < 0){
DEException.throwException("查询超时不能小于0");
}
}
private static void checkName(List<String> tables) {
for (int i = 0; i < tables.size() - 1; i++) {
for (int j = i + 1; j < tables.size(); j++) {
@ -419,6 +439,7 @@ public class DatasourceServer implements DatasourceApi {
dataSourceManage.innerEdit(requestDatasource);
}
} else {
checkParams(dataSourceDTO.getConfiguration());
dataSourceManage.innerEdit(requestDatasource);
calciteProvider.update(dataSourceDTO);
}

View File

@ -13,7 +13,7 @@ import java.util.List;
public class Mysql extends DatasourceConfiguration {
private String driver = "com.mysql.cj.jdbc.Driver";
private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
private List<String> illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations");
private List<String> illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations", "allowloadlocalinfile", "allowUrlInLocalInfile", "allowLoadLocalInfileInPath");
private List<String> showTableSqls = Arrays.asList("show tables");
public String getJdbc() {
@ -24,7 +24,7 @@ public class Mysql extends DatasourceConfiguration {
.replace("DATABASE", getDataBase().trim());
} else {
for (String illegalParameter : illegalParameters) {
if (getExtraParams().contains(illegalParameter)) {
if (getExtraParams().toLowerCase().contains(illegalParameter.toLowerCase())) {
throw new RuntimeException("Illegal parameter: " + illegalParameter);
}
}

View File

@ -47,6 +47,8 @@ public class SQLConstants {
public static final String FIELD_NAME = "%s.`%s`";
public static final String FIELD_DOT = "`%s`";
public static final String UNIX_TIMESTAMP = "UNIX_TIMESTAMP(%s)";
public static final String DATE_FORMAT = "DATE_FORMAT(%s,'%s')";

View File

@ -56,7 +56,10 @@ public class SQLProvider {
if (ObjectUtils.isNotEmpty(xFields)) {
xOrders = new ArrayList<>();
SQLObj sqlObj = xFields.get(0);
SQLObj result = SQLObj.builder().orderField(sqlObj.getFieldAlias()).orderAlias(sqlObj.getFieldAlias()).orderDirection("ASC").build();
SQLObj result = SQLObj.builder()
.orderField(String.format(SQLConstants.FIELD_DOT, sqlObj.getFieldAlias()))
.orderAlias(String.format(SQLConstants.FIELD_DOT, sqlObj.getFieldAlias()))
.orderDirection("ASC").build();
xOrders.add(result);
}
}
@ -115,7 +118,10 @@ public class SQLProvider {
if (needOrder && ObjectUtils.isEmpty(orders)) {
if (ObjectUtils.isNotEmpty(xFields) || ObjectUtils.isNotEmpty(yFields)) {
SQLObj sqlObj = ObjectUtils.isNotEmpty(xFields) ? xFields.get(0) : yFields.get(0);
SQLObj result = SQLObj.builder().orderField(sqlObj.getFieldAlias()).orderAlias(sqlObj.getFieldAlias()).orderDirection("ASC").build();
SQLObj result = SQLObj.builder()
.orderField(String.format(SQLConstants.FIELD_DOT, sqlObj.getFieldAlias()))
.orderAlias(String.format(SQLConstants.FIELD_DOT, sqlObj.getFieldAlias()))
.orderDirection("ASC").build();
orders.add(result);
}
}

View File

@ -78,7 +78,10 @@ public class Order2SQLObj {
fieldName = originField;
}
}
SQLObj result = SQLObj.builder().orderField(originField).orderAlias(originField).orderDirection(f.getOrderDirection()).build();
SQLObj result = SQLObj.builder()
.orderField(String.format(SQLConstants.FIELD_DOT, originField))
.orderAlias(String.format(SQLConstants.FIELD_DOT, originField))
.orderDirection(f.getOrderDirection()).build();
return result;
}

View File

@ -0,0 +1,17 @@
package io.dataease.system.bo;
import lombok.Data;
import java.io.Serializable;
@Data
public class SysParameterBO implements Serializable {
private String key;
private String val;
private String type;
private String sort;
}

View File

@ -0,0 +1,94 @@
package io.dataease.system.dao.auto.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author fit2cloud
* @since 2023-10-27
*/
@TableName("core_sys_setting")
public class CoreSysSetting implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private Long id;
/**
*
*/
private String pkey;
/**
*
*/
private String pval;
/**
* 类型
*/
private String type;
/**
* 顺序
*/
private Integer sort;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPkey() {
return pkey;
}
public void setPkey(String pkey) {
this.pkey = pkey;
}
public String getPval() {
return pval;
}
public void setPval(String pval) {
this.pval = pval;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
@Override
public String toString() {
return "CoreSysSetting{" +
"id = " + id +
", pkey = " + pkey +
", pval = " + pval +
", type = " + type +
", sort = " + sort +
"}";
}
}

View File

@ -0,0 +1,18 @@
package io.dataease.system.dao.auto.mapper;
import io.dataease.system.dao.auto.entity.CoreSysSetting;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author fit2cloud
* @since 2023-10-27
*/
@Mapper
public interface CoreSysSettingMapper extends BaseMapper<CoreSysSetting> {
}

View File

@ -0,0 +1,60 @@
package io.dataease.system.manage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.dataease.system.dao.auto.entity.CoreSysSetting;
import io.dataease.system.dao.auto.mapper.CoreSysSettingMapper;
import io.dataease.utils.IDUtils;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class SysParameterManage {
private static final String mapKey = "map.key";
@Resource
private CoreSysSettingMapper coreSysSettingMapper;
public String singleVal(String key) {
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pkey", key);
CoreSysSetting sysSetting = coreSysSettingMapper.selectOne(queryWrapper);
if (ObjectUtils.isNotEmpty(sysSetting)) {
return sysSetting.getPval();
}
return null;
}
public String queryOnlineMap() {
return singleVal(mapKey);
}
public void saveOnlineMap(String val) {
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pkey", mapKey);
CoreSysSetting sysSetting = coreSysSettingMapper.selectOne(queryWrapper);
if (ObjectUtils.isEmpty(sysSetting)) {
sysSetting = new CoreSysSetting();
sysSetting.setId(IDUtils.snowID());
sysSetting.setPkey(mapKey);
sysSetting.setPval(val);
sysSetting.setType("text");
sysSetting.setSort(1);
coreSysSettingMapper.insert(sysSetting);
}
sysSetting.setPval(val);
coreSysSettingMapper.updateById(sysSetting);
}
void save(List<CoreSysSetting> boList) {
List<CoreSysSetting> all = all();
}
private List<CoreSysSetting> all() {
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
return coreSysSettingMapper.selectList(queryWrapper);
}
}

View File

@ -0,0 +1,32 @@
package io.dataease.system.server;
import io.dataease.api.system.SysParameterApi;
import io.dataease.api.system.request.OnlineMapEditor;
import io.dataease.system.manage.SysParameterManage;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/sysParameter")
public class SysParameterServer implements SysParameterApi {
@Resource
private SysParameterManage sysParameterManage;
@Override
public String singleVal(String key) {
return sysParameterManage.singleVal(key);
}
@Override
public void saveOnlineMap(OnlineMapEditor editor) {
sysParameterManage.saveOnlineMap(editor.getKey());
}
@Override
public String queryOnlineMap() {
String key = sysParameterManage.queryOnlineMap();
return StringUtils.isNotBlank(key) ? key : "";
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
import request from '@/config/axios'
export const queryMapKeyApi = () => request.get({ url: '/sysParameter/queryOnlineMap' })
export const saveMapKeyApi = data => request.post({ url: '/sysParameter/saveOnlineMap', data })

View File

@ -2117,6 +2117,7 @@ export default {
},
online_map: {
geometry: '地理信息',
onlinemap: '在线地图'
onlinemap: '在线地图',
empty_desc: '请在左侧输入信息然后保存'
}
}

View File

@ -65,6 +65,7 @@ export const snapshotStore = defineStore('snapshot', {
deepCopy(this.snapshotData[this.snapshotIndex]) || getDefaultCanvasInfo()
// undo 是当前没有记录
this.snapshotPublish(componentSnapshot)
this.styleChangeTimes++
}
},
@ -73,6 +74,7 @@ export const snapshotStore = defineStore('snapshot', {
this.snapshotIndex++
const snapshotInfo = deepCopy(this.snapshotData[this.snapshotIndex])
this.snapshotPublish(snapshotInfo)
this.styleChangeTimes++
}
},
snapshotPublish(snapshotInfo) {

View File

@ -19,21 +19,117 @@
}}</el-button>
</el-aside>
<el-main>
<div class="de-map-container" :id="domId" />
<div v-show="mapLoaded" v-if="!mapReloading" class="de-map-container" :id="domId" />
<EmptyBackground
v-if="!mapLoaded"
img-type="noneWhite"
:description="t('online_map.empty_desc')"
/>
</el-main>
</el-container>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { nextTick, onMounted, ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { queryMapKeyApi, saveMapKeyApi } from '@/api/setting/sysParameter'
import { ElMessage } from 'element-plus-secondary'
import EmptyBackground from '@/components/empty-background/src/EmptyBackground.vue'
const { t } = useI18n()
const key = ref('')
const mapInstance = ref(null)
const mapReloading = ref(false)
const domId = ref('de-map-container')
const saveHandler = () => {
console.log(111)
const mapLoaded = ref(false)
const loadMap = () => {
if (!key.value) {
return
}
const mykey = key.value
const url = `https://webapi.amap.com/maps?v=2.0&key=${mykey}`
loadScript(url)
.then(() => {
if (mapInstance.value) {
mapInstance.value?.destroy()
mapInstance.value = null
mapReloading.value = true
setTimeout(() => {
domId.value = domId.value + '-de-'
mapReloading.value = false
nextTick(() => {
createMapInstance()
})
}, 1500)
return
}
createMapInstance()
})
.catch(e => {
if (mapInstance.value) {
mapInstance.value.destroy()
mapInstance.value = null
}
console.error(e)
})
}
const createMapInstance = () => {
mapInstance.value = new window.AMap.Map(domId.value, {
viewMode: '2D',
zoom: 11,
center: [116.397428, 39.90923]
})
mapLoaded.value = true
}
const saveHandler = () => {
saveMapKeyApi({ key: key.value })
.then(() => {
ElMessage.success(t('commons.save_success'))
initLoad()
})
.catch(e => {
console.error(e)
})
}
const initLoad = () => {
queryMapKeyApi()
.then(res => {
key.value = res.data
loadMap()
})
.catch(e => {
console.error(e)
})
}
const loadScript = (url: string) => {
return new Promise(function (resolve, reject) {
const scriptId = 'de-gaode-script-id'
let dom = document.getElementById(scriptId)
if (dom) {
dom.parentElement?.removeChild(dom)
dom = null
window.AMap = null
}
var script = document.createElement('script')
script.id = scriptId
script.onload = function () {
return resolve(null)
}
script.onerror = function () {
return reject(new Error('Load script from '.concat(url, ' failed')))
}
script.src = url
var head = document.head || document.getElementsByTagName('head')[0]
;(document.body || head).appendChild(script)
})
}
onMounted(() => {
initLoad()
})
</script>
<style lang="less" scoped>

View File

@ -0,0 +1,20 @@
package io.dataease.api.system;
import io.dataease.api.system.request.OnlineMapEditor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
public interface SysParameterApi {
@GetMapping("/singleVal/{key}")
String singleVal(@PathVariable("key") String key);
@PostMapping("/saveOnlineMap")
void saveOnlineMap(@RequestBody OnlineMapEditor editor);
@GetMapping("/queryOnlineMap")
String queryOnlineMap();
}

View File

@ -0,0 +1,11 @@
package io.dataease.api.system.request;
import lombok.Data;
import java.io.Serializable;
@Data
public class OnlineMapEditor implements Serializable {
private String key;
}