Merge pull request #6402 from dataease/pr@dev-v2@feat_system_setting

feat: 系统参数漏提代码
This commit is contained in:
fit2cloud-chenyw 2023-10-27 14:33:38 +08:00 committed by GitHub
commit a421f6bdaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 221 additions and 0 deletions

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 : "";
}
}