forked from github/dataease
perf: 自动创建用户设置(xpack)
This commit is contained in:
parent
9a21b85f60
commit
4b9038f4f1
@ -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<SettingItemVO> groupList(String groupKey) {
|
||||
public List<CoreSysSetting> groupList(String groupKey) {
|
||||
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.likeRight("pkey", groupKey);
|
||||
queryWrapper.orderByAsc("sort");
|
||||
List<CoreSysSetting> 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<SettingItemVO> convert(List<CoreSysSetting> sysSettings) {
|
||||
return sysSettings.stream().sorted(Comparator.comparing(CoreSysSetting::getSort)).map(item -> BeanUtils.copyBean(new SettingItemVO(), item)).toList();
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void saveGroup(List<SettingItemVO> vos, String groupKey) {
|
||||
QueryWrapper<CoreSysSetting> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.likeRight("pkey", groupKey);
|
||||
coreSysSettingMapper.delete(queryWrapper);
|
||||
List<CoreSysSetting> sysSettings = vos.stream().map(item -> {
|
||||
List<CoreSysSetting> 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<SettingItemVO> vos) {
|
||||
String key = "basic.";
|
||||
proxy().saveGroup(vos, key);
|
||||
}
|
||||
|
||||
private SysParameterManage proxy() {
|
||||
return CommonBeanFactory.getBean(SysParameterManage.class);
|
||||
}
|
||||
}
|
||||
|
@ -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<SettingItemVO> queryBasicSetting() {
|
||||
String key = "basic.";
|
||||
return sysParameterManage.groupList(key);
|
||||
List<CoreSysSetting> coreSysSettings = sysParameterManage.groupList(key);
|
||||
return sysParameterManage.convert(coreSysSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveBasicSetting(List<SettingItemVO> settingItemVOS) {
|
||||
sysParameterManage.saveGroup(settingItemVOS, "basic.");
|
||||
sysParameterManage.saveBasic(settingItemVOS);
|
||||
}
|
||||
}
|
||||
|
@ -2122,5 +2122,10 @@ export default {
|
||||
geometry: '地理信息',
|
||||
onlinemap: '在线地图',
|
||||
empty_desc: '请在左侧输入信息然后保存'
|
||||
},
|
||||
setting_basic: {
|
||||
autoCreateUser: '禁止第三方自动创建用户',
|
||||
dsIntervalTime: '数据源检测时间间隔',
|
||||
dsExecuteTime: '数据源检测频率'
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<div class="info-template-content">
|
||||
<div class="info-content-item" v-for="item in settingList" :key="item.pkey">
|
||||
<div class="info-item-label">
|
||||
<span>{{ item.pkey }}</span>
|
||||
<span>{{ t(item.pkey) }}</span>
|
||||
<el-tooltip
|
||||
v-if="tooltipItem[item.pkey]"
|
||||
effect="dark"
|
||||
@ -33,7 +33,7 @@
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<span v-else-if="item.pkey === '数据源检测时间间隔'">
|
||||
<span v-else-if="item.pkey.includes('basic.dsIntervalTime')">
|
||||
<span>{{ item.pval + ' ' + executeTime + '执行一次' }}</span>
|
||||
</span>
|
||||
<span v-else>{{ item.pval }}</span>
|
||||
@ -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()
|
||||
|
@ -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<BasicFrom>({
|
||||
autoCreateUser: false,
|
||||
form: reactive({
|
||||
dsIntervalTime: '30',
|
||||
dsExecuteTime: 'minute'
|
||||
})
|
||||
}),
|
||||
settingList: []
|
||||
})
|
||||
|
||||
const rule = reactive<FormRules>({
|
||||
@ -35,44 +30,24 @@ const rule = reactive<FormRules>({
|
||||
]
|
||||
})
|
||||
|
||||
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"
|
||||
>
|
||||
<el-form-item label="禁止扫码创建用户" prop="autoCreateUser">
|
||||
<el-switch v-model="state.form.autoCreateUser" />
|
||||
<el-form-item
|
||||
v-for="item in state.settingList"
|
||||
:key="item.pkey"
|
||||
:prop="item.pkey"
|
||||
:class="{ 'setting-hidden-item': item.pkey === 'dsExecuteTime' }"
|
||||
:label="t(item.label)"
|
||||
>
|
||||
<el-switch
|
||||
v-if="item.pkey === 'autoCreateUser'"
|
||||
active-value="true"
|
||||
inactive-value="false"
|
||||
v-model="state.form[item.pkey]"
|
||||
/>
|
||||
<div v-else-if="item.pkey === 'dsIntervalTime'" class="ds-task-form-inline">
|
||||
<span>每</span>
|
||||
<el-input-number
|
||||
v-model="state.form.dsIntervalTime"
|
||||
autocomplete="off"
|
||||
step-strictly
|
||||
class="text-left"
|
||||
:min="1"
|
||||
:placeholder="t('common.inputText')"
|
||||
controls-position="right"
|
||||
type="number"
|
||||
/>
|
||||
<el-select v-model="state.form.dsExecuteTime">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<span class="ds-span">执行一次</span>
|
||||
</div>
|
||||
<div v-else />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="禁止扫码创建用户" prop="autoCreateUser">
|
||||
<el-switch v-model="state.form.autoCreateUser" />
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="数据源检测时间间隔" prop="dsIntervalTime">
|
||||
<!-- <el-form-item label="数据源检测时间间隔" prop="dsIntervalTime">
|
||||
<div class="ds-task-form-inline">
|
||||
<span>每</span>
|
||||
<el-input-number
|
||||
@ -157,7 +183,7 @@ defineExpose({
|
||||
</el-select>
|
||||
<span class="ds-span">执行一次</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
@ -171,6 +197,9 @@ defineExpose({
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.setting-hidden-item {
|
||||
display: none !important;
|
||||
}
|
||||
.ds-task-form-inline {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
|
@ -17,6 +17,7 @@ import BasicEdit from './BasicEdit.vue'
|
||||
import request from '@/config/axios'
|
||||
import { SettingRecord } from '@/views/system/common/SettingTemplate'
|
||||
import { reactive } from 'vue'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
const editor = ref()
|
||||
const infoTemplate = ref()
|
||||
const tooltips = [
|
||||
@ -26,39 +27,25 @@ const tooltips = [
|
||||
}
|
||||
]
|
||||
const state = reactive({
|
||||
templateList: [
|
||||
{
|
||||
pkey: '禁止扫码创建用户',
|
||||
pval: '未开启',
|
||||
type: 'text',
|
||||
sort: 1
|
||||
},
|
||||
{
|
||||
pkey: '数据源检测时间间隔',
|
||||
pval: '100',
|
||||
type: 'text',
|
||||
sort: 2
|
||||
},
|
||||
{
|
||||
pkey: '数据源检测频率',
|
||||
pval: 'minute',
|
||||
type: 'text',
|
||||
sort: 3
|
||||
}
|
||||
] as SettingRecord[]
|
||||
templateList: [] as SettingRecord[]
|
||||
})
|
||||
|
||||
let originData = []
|
||||
const search = cb => {
|
||||
const url = '/sysParameter/basic/query'
|
||||
originData = []
|
||||
state.templateList = []
|
||||
request.get({ url }).then(res => {
|
||||
originData = cloneDeep(res.data)
|
||||
const data = res.data
|
||||
for (let index = 0; index < data.length; index++) {
|
||||
const item = data[index]
|
||||
if (index === 0) {
|
||||
state.templateList[index].pval = item.pval === 'true' ? '开启' : '未开启'
|
||||
if (item.pkey === 'basic.autoCreateUser') {
|
||||
item.pval = item.pval === 'true' ? '开启' : '未开启'
|
||||
} else {
|
||||
state.templateList[index].pval = item.pval
|
||||
item.pval = item.pval
|
||||
}
|
||||
item.pkey = 'setting_' + item.pkey
|
||||
state.templateList.push(item)
|
||||
}
|
||||
cb && cb()
|
||||
})
|
||||
@ -68,14 +55,9 @@ const refresh = () => {
|
||||
infoTemplate?.value.init()
|
||||
})
|
||||
}
|
||||
search(null)
|
||||
refresh()
|
||||
|
||||
const edit = () => {
|
||||
const param = {
|
||||
autoCreateUser: state.templateList[0].pval === '开启' ? 'true' : 'false',
|
||||
dsIntervalTime: state.templateList[1].pval,
|
||||
dsExecuteTime: state.templateList[2].pval
|
||||
}
|
||||
editor?.value.edit(param)
|
||||
editor?.value.edit(cloneDeep(originData))
|
||||
}
|
||||
</script>
|
||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
||||
Subproject commit eb2b4924a5ada4969bcd633ef7e439dc5c5d810e
|
||||
Subproject commit 8240c12452a97e2ed509a5cd067799de55fa7c30
|
@ -0,0 +1,17 @@
|
||||
package io.dataease.api.permissions.setting.api;
|
||||
|
||||
import io.dataease.api.permissions.setting.vo.PerSettingItemVO;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PerSettingApi {
|
||||
|
||||
@GetMapping("/basic/query")
|
||||
List<PerSettingItemVO> basicSetting();
|
||||
|
||||
@PostMapping("/baisc/save")
|
||||
void saveBasic(@RequestBody List<Object> settings);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package io.dataease.api.permissions.setting.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PerSettingItemVO implements Serializable {
|
||||
|
||||
private String pkey;
|
||||
|
||||
private String pval;
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer sort;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package io.dataease.constant;
|
||||
|
||||
public class XpackSettingConstants {
|
||||
|
||||
public static final String AUTO_CREATE_USER = "basic.autoCreateUser";
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import io.dataease.constant.XpackSettingConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SystemSettingUtils {
|
||||
|
||||
public static boolean xpackSetting(String pkey) {
|
||||
List<String> xpackSettingList = ListUtil.toList(XpackSettingConstants.AUTO_CREATE_USER);
|
||||
return xpackSettingList.contains(pkey);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user