forked from github/dataease
Merge pull request #6402 from dataease/pr@dev-v2@feat_system_setting
feat: 系统参数漏提代码
This commit is contained in:
commit
a421f6bdaf
@ -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;
|
||||
}
|
@ -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 +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -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> {
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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 : "";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user