From 4b9038f4f1d9ed61ce989e92a45d239a7fcfd2d3 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 27 Nov 2023 09:05:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=BE=E7=BD=AE(xpack)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/manage/SysParameterManage.java | 34 ++++-- .../system/server/SysParameterServer.java | 6 +- core/core-frontend/src/locales/zh-CN.ts | 5 + .../src/views/system/common/InfoTemplate.vue | 78 +----------- .../system/parameter/basic/BasicEdit.vue | 115 +++++++++++------- .../system/parameter/basic/BasicInfo.vue | 44 ++----- de-xpack | 2 +- .../setting/api/PerSettingApi.java | 17 +++ .../setting/vo/PerSettingItemVO.java | 19 +++ .../constant/XpackSettingConstants.java | 6 + .../io/dataease/utils/SystemSettingUtils.java | 14 +++ 11 files changed, 181 insertions(+), 159 deletions(-) create mode 100644 sdk/api/api-permissions/src/main/java/io/dataease/api/permissions/setting/api/PerSettingApi.java create mode 100644 sdk/api/api-permissions/src/main/java/io/dataease/api/permissions/setting/vo/PerSettingItemVO.java create mode 100644 sdk/common/src/main/java/io/dataease/constant/XpackSettingConstants.java create mode 100644 sdk/common/src/main/java/io/dataease/utils/SystemSettingUtils.java diff --git a/core/core-backend/src/main/java/io/dataease/system/manage/SysParameterManage.java b/core/core-backend/src/main/java/io/dataease/system/manage/SysParameterManage.java index 510138086f..4f9d477557 100644 --- a/core/core-backend/src/main/java/io/dataease/system/manage/SysParameterManage.java +++ b/core/core-backend/src/main/java/io/dataease/system/manage/SysParameterManage.java @@ -2,16 +2,21 @@ package io.dataease.system.manage; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.dataease.api.system.vo.SettingItemVO; +import io.dataease.license.config.XpackInteract; import io.dataease.system.dao.auto.entity.CoreSysSetting; import io.dataease.system.dao.auto.mapper.CoreSysSettingMapper; import io.dataease.system.dao.ext.mapper.ExtCoreSysSettingMapper; import io.dataease.utils.BeanUtils; +import io.dataease.utils.CommonBeanFactory; import io.dataease.utils.IDUtils; +import io.dataease.utils.SystemSettingUtils; import jakarta.annotation.Resource; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -71,26 +76,41 @@ public class SysParameterManage { return null; } - public List groupList(String groupKey) { + public List groupList(String groupKey) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.likeRight("pkey", groupKey); queryWrapper.orderByAsc("sort"); - List sysSettings = coreSysSettingMapper.selectList(queryWrapper); - if (!CollectionUtils.isEmpty(sysSettings)) { - return sysSettings.stream().map(item -> BeanUtils.copyBean(new SettingItemVO(), item)).toList(); - } - return null; + return coreSysSettingMapper.selectList(queryWrapper); } + @XpackInteract(value = "perSetting") + public List convert(List sysSettings) { + return sysSettings.stream().sorted(Comparator.comparing(CoreSysSetting::getSort)).map(item -> BeanUtils.copyBean(new SettingItemVO(), item)).toList(); + } + + + @Transactional public void saveGroup(List vos, String groupKey) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.likeRight("pkey", groupKey); coreSysSettingMapper.delete(queryWrapper); - List sysSettings = vos.stream().map(item -> { + List sysSettings = vos.stream().filter(vo -> !SystemSettingUtils.xpackSetting(vo.getPkey())).map(item -> { CoreSysSetting sysSetting = BeanUtils.copyBean(new CoreSysSetting(), item); sysSetting.setId(IDUtils.snowID()); return sysSetting; }).collect(Collectors.toList()); extCoreSysSettingMapper.saveBatch(sysSettings); } + + + @XpackInteract(value = "perSetting", before = false) + @Transactional + public void saveBasic(List vos) { + String key = "basic."; + proxy().saveGroup(vos, key); + } + + private SysParameterManage proxy() { + return CommonBeanFactory.getBean(SysParameterManage.class); + } } diff --git a/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java b/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java index 2a6ba90fd3..eb33745da1 100644 --- a/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java +++ b/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java @@ -3,6 +3,7 @@ package io.dataease.system.server; import io.dataease.api.system.SysParameterApi; import io.dataease.api.system.request.OnlineMapEditor; import io.dataease.api.system.vo.SettingItemVO; +import io.dataease.system.dao.auto.entity.CoreSysSetting; import io.dataease.system.manage.SysParameterManage; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; @@ -36,11 +37,12 @@ public class SysParameterServer implements SysParameterApi { @Override public List queryBasicSetting() { String key = "basic."; - return sysParameterManage.groupList(key); + List coreSysSettings = sysParameterManage.groupList(key); + return sysParameterManage.convert(coreSysSettings); } @Override public void saveBasicSetting(List settingItemVOS) { - sysParameterManage.saveGroup(settingItemVOS, "basic."); + sysParameterManage.saveBasic(settingItemVOS); } } diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 56060dafd4..470de07b41 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -2122,5 +2122,10 @@ export default { geometry: '地理信息', onlinemap: '在线地图', empty_desc: '请在左侧输入信息然后保存' + }, + setting_basic: { + autoCreateUser: '禁止第三方自动创建用户', + dsIntervalTime: '数据源检测时间间隔', + dsExecuteTime: '数据源检测频率' } } diff --git a/core/core-frontend/src/views/system/common/InfoTemplate.vue b/core/core-frontend/src/views/system/common/InfoTemplate.vue index 3f8d37ff0c..4dc05b29de 100644 --- a/core/core-frontend/src/views/system/common/InfoTemplate.vue +++ b/core/core-frontend/src/views/system/common/InfoTemplate.vue @@ -11,7 +11,7 @@
- {{ item.pkey }} + {{ t(item.pkey) }}
- + {{ item.pval + ' ' + executeTime + '执行一次' }} {{ item.pval }} @@ -74,7 +74,7 @@ const loadList = () => { settingList.value = [] if (props.settingData?.length) { props.settingData.forEach(item => { - if (item.pkey === '数据源检测频率') { + if (item.pkey.includes('basic.dsExecuteTime')) { executeTime.value = getExecuteTime(item.pval) } else { settingList.value.push(item) @@ -93,78 +93,6 @@ const getExecuteTime = val => { const settingList = ref([] as SettingRecord[]) -/* const loadBasic = () => { - settingList.value.push({ - pkey: '请求超时时间', - pval: '100', - type: 'text', - sort: 1 - }) - settingList.value.push({ - pkey: '数据源检测时间间隔', - pval: '100', - type: 'text', - sort: 2 - }) - settingList.value.push({ - pkey: '默认登录方式', - pval: '普通登录', - type: 'text', - sort: 3 - }) - settingList.value.push({ - pkey: '默认密码', - pval: 'DataEase@123456', - type: 'pwd', - sort: 4 - }) -} - -const loadEmail = () => { - settingList.value.push({ - pkey: 'SMTP主机', - pval: 'smtp.exmail.qq.com', - type: 'text', - sort: 1 - }) - settingList.value.push({ - pkey: 'SMTP端口', - pval: '465', - type: 'text', - sort: 2 - }) - settingList.value.push({ - pkey: 'SMTP账户', - pval: 'test@fit2cloud.com', - type: 'text', - sort: 3 - }) - settingList.value.push({ - pkey: 'SMTP密码', - pval: 'DataEase@123456', - type: 'pwd', - sort: 4 - }) - settingList.value.push({ - pkey: '测试收件人', - pval: 'yawen.chen@fit2cloud.com', - type: 'pwd', - sort: 5 - }) - settingList.value.push({ - pkey: 'SSL', - pval: '开启', - type: 'text', - sort: 6 - }) - settingList.value.push({ - pkey: 'TSL', - pval: '未开启', - type: 'text', - sort: 7 - }) -} */ - const init = () => { if (props.settingData?.length) { loadList() diff --git a/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue b/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue index a7b28155fa..431ecf502f 100644 --- a/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue +++ b/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue @@ -12,17 +12,12 @@ const options = [ { value: 'minute', label: '分钟(执行时间:0秒)' }, { value: 'hour', label: '小时(执行时间:0分0秒)' } ] -interface BasicFrom { - autoCreateUser?: boolean - dsIntervalTime?: string - dsExecuteTime?: string -} const state = reactive({ - form: reactive({ - autoCreateUser: false, + form: reactive({ dsIntervalTime: '30', dsExecuteTime: 'minute' - }) + }), + settingList: [] }) const rule = reactive({ @@ -35,44 +30,24 @@ const rule = reactive({ ] }) -const edit = row => { - state.form = { - autoCreateUser: row.autoCreateUser === 'true', - dsIntervalTime: row.dsIntervalTime, - dsExecuteTime: row.dsExecuteTime - } - dialogVisible.value = true -} - -const emits = defineEmits(['saved']) - const buildSettingList = () => { - const param = { ...state.form } - const item0 = { - pkey: 'basic.autoCreateUser', - pval: param.autoCreateUser.toString(), - type: 'text', - sort: 1 - } - const item1 = { - pkey: 'basic.dsIntervalTime', - pval: param.dsIntervalTime, - type: 'text', - sort: 2 - } - const item2 = { - pkey: 'basic.dsExecuteTime', - pval: param.dsExecuteTime, - type: 'text', - sort: 3 - } - return [item0, item1, item2] + return state.settingList.map(item => { + const pkey = item.pkey.startsWith('basic.') ? item.pkey : `basic.${item.pkey}` + const sort = item.sort + const type = item.type + const pval = state.form[item.pkey] + return { pkey, pval, type, sort } + }) } +const emits = defineEmits(['saved']) const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate((valid, fields) => { if (valid) { const param = buildSettingList() + if (param.length < 2) { + return + } showLoading() request .post({ url: '/sysParameter/basic/save', data: param }) @@ -94,6 +69,7 @@ const submitForm = async (formEl: FormInstance | undefined) => { } const resetForm = (formEl: FormInstance | undefined) => { + state.settingList = [] if (!formEl) return formEl.resetFields() dialogVisible.value = false @@ -109,6 +85,19 @@ const showLoading = () => { const closeLoading = () => { loadingInstance.value?.close() } + +const edit = list => { + state.settingList = list.map(item => { + const pkey = item.pkey + item['label'] = `setting_${pkey}` + item['pkey'] = pkey.split('.')[1] + let pval = item.pval + state.form[item['pkey']] = pval || state.form[item['pkey']] + return item + }) + console.log(state.settingList) + dialogVisible.value = true +} defineExpose({ edit }) @@ -130,11 +119,48 @@ defineExpose({ label-width="80px" label-position="top" > - - + + +
+ + + + + + 执行一次 +
+
+ - +