mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
将 sys_config 从 system 迁移到 infra 模块,并进行改名~
This commit is contained in:
parent
17cb37f577
commit
b005e062bb
9
pom.xml
9
pom.xml
@ -24,7 +24,6 @@
|
|||||||
<!-- 统一依赖管理 -->
|
<!-- 统一依赖管理 -->
|
||||||
<spring.boot.version>2.4.2</spring.boot.version>
|
<spring.boot.version>2.4.2</spring.boot.version>
|
||||||
|
|
||||||
<!-- <ruoyi.version>3.3.0</ruoyi.version>-->
|
|
||||||
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
|
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
|
||||||
<!-- <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>-->
|
<!-- <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>-->
|
||||||
<!-- <druid.version>1.2.2</druid.version>-->
|
<!-- <druid.version>1.2.2</druid.version>-->
|
||||||
@ -48,7 +47,7 @@
|
|||||||
<mysql-connector-java.version>5.1.46</mysql-connector-java.version>
|
<mysql-connector-java.version>5.1.46</mysql-connector-java.version>
|
||||||
<druid.version>1.2.4</druid.version>
|
<druid.version>1.2.4</druid.version>
|
||||||
<mybatis-plus.version>3.4.1</mybatis-plus.version>
|
<mybatis-plus.version>3.4.1</mybatis-plus.version>
|
||||||
<redisson.version>3.13.6</redisson.version>
|
<redisson.version>3.14.1</redisson.version>
|
||||||
<!-- 监控相关 -->
|
<!-- 监控相关 -->
|
||||||
<skywalking.version>8.3.0</skywalking.version>
|
<skywalking.version>8.3.0</skywalking.version>
|
||||||
<!-- 工具类相关 -->
|
<!-- 工具类相关 -->
|
||||||
@ -142,6 +141,12 @@
|
|||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
<version>${knife4j.version}</version>
|
<version>${knife4j.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>mapstruct</artifactId>
|
||||||
|
<groupId>org.mapstruct</groupId> <!-- 避免冲突 -->
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- DB 相关 -->
|
<!-- DB 相关 -->
|
||||||
|
@ -3,7 +3,7 @@ import request from '@/utils/request'
|
|||||||
// 查询参数列表
|
// 查询参数列表
|
||||||
export function listConfig(query) {
|
export function listConfig(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/config/page',
|
url: '/infra/config/page',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
@ -12,7 +12,7 @@ export function listConfig(query) {
|
|||||||
// 查询参数详细
|
// 查询参数详细
|
||||||
export function getConfig(configId) {
|
export function getConfig(configId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/config/get?id=' + configId,
|
url: '/infra/config/get?id=' + configId,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ export function getConfig(configId) {
|
|||||||
// 根据参数键名查询参数值
|
// 根据参数键名查询参数值
|
||||||
export function getConfigKey(configKey) {
|
export function getConfigKey(configKey) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/config/get-value-by-key?key=' + configKey,
|
url: '/infra/config/get-value-by-key?key=' + configKey,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ export function getConfigKey(configKey) {
|
|||||||
// 新增参数配置
|
// 新增参数配置
|
||||||
export function addConfig(data) {
|
export function addConfig(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/config/create',
|
url: '/infra/config/create',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@ -37,7 +37,7 @@ export function addConfig(data) {
|
|||||||
// 修改参数配置
|
// 修改参数配置
|
||||||
export function updateConfig(data) {
|
export function updateConfig(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/config/update',
|
url: '/infra/config/update',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@ -46,7 +46,7 @@ export function updateConfig(data) {
|
|||||||
// 删除参数配置
|
// 删除参数配置
|
||||||
export function delConfig(configId) {
|
export function delConfig(configId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/config/delete?id=' + configId,
|
url: '/infra/config/delete?id=' + configId,
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ export function delConfig(configId) {
|
|||||||
// 导出参数
|
// 导出参数
|
||||||
export function exportConfig(query) {
|
export function exportConfig(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/config/export',
|
url: '/infra/config/export',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query,
|
params: query,
|
||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
|
@ -304,7 +304,10 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const queryParams = this.queryParams;
|
const queryParams = this.addDateRange(this.queryParams, [
|
||||||
|
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
|
||||||
|
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
|
||||||
|
]);
|
||||||
this.$confirm('是否确认导出所有参数数据项?', "警告", {
|
this.$confirm('是否确认导出所有参数数据项?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.apollo.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 针对 {@link com.ctrip.framework.apollo.core.ConfigConsts} 的补充,主要增加:
|
||||||
|
*
|
||||||
|
* 1. apollo.jdbc.* 配置项的枚举
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class ConfigConsts {
|
||||||
|
|
||||||
|
public static final String APOLLO_JDBC_URL = "apollo.jdbc.url";
|
||||||
|
public static final String APOLLO_JDBC_USERNAME = "apollo.jdbc.username";
|
||||||
|
public static final String APOLLO_JDBC_PASSWORD = "apollo.jdbc.password";
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
package cn.iocoder.dashboard.framework.apollo.internals;
|
package cn.iocoder.dashboard.framework.apollo.internals;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.dashboard.framework.apollo.core.ConfigConsts;
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
|
||||||
import com.ctrip.framework.apollo.Apollo;
|
import com.ctrip.framework.apollo.Apollo;
|
||||||
import com.ctrip.framework.apollo.build.ApolloInjector;
|
import com.ctrip.framework.apollo.build.ApolloInjector;
|
||||||
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
|
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
|
||||||
@ -59,12 +60,9 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
|||||||
this.m_namespace = namespace;
|
this.m_namespace = namespace;
|
||||||
this.propertiesFactory = ApolloInjector.getInstance(PropertiesFactory.class);
|
this.propertiesFactory = ApolloInjector.getInstance(PropertiesFactory.class);
|
||||||
this.m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
|
this.m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
|
||||||
// TODO 优化到配置
|
// 初始化 DB
|
||||||
String url = "jdbc:mysql://127.0.1:33061/ruoyi-vue-pro?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT";
|
DataSource dataSource = new DriverManagerDataSource(System.getProperty(ConfigConsts.APOLLO_JDBC_URL),
|
||||||
String username = "root";
|
System.getProperty(ConfigConsts.APOLLO_JDBC_USERNAME), System.getProperty(ConfigConsts.APOLLO_JDBC_PASSWORD));
|
||||||
String password = "123456";
|
|
||||||
// DataSource dataSource = DataSourceBuilder.create().url(url).username(username).password(password).build();
|
|
||||||
DataSource dataSource = new DriverManagerDataSource(url, username, password);
|
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
// 初始化加载
|
// 初始化加载
|
||||||
@ -76,7 +74,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
|||||||
@Override
|
@Override
|
||||||
protected void sync() {
|
protected void sync() {
|
||||||
// 第一步,尝试获取配置
|
// 第一步,尝试获取配置
|
||||||
List<SysConfigDO> configs = this.loadConfigIfUpdate(this.maxUpdateTime);
|
List<InfConfigDO> configs = this.loadConfigIfUpdate(this.maxUpdateTime);
|
||||||
if (CollUtil.isEmpty(configs)) { // 如果没有更新,则返回
|
if (CollUtil.isEmpty(configs)) { // 如果没有更新,则返回
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,7 +109,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
|||||||
return ConfigSourceType.REMOTE;
|
return ConfigSourceType.REMOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Properties buildProperties(List<SysConfigDO> configs) {
|
private Properties buildProperties(List<InfConfigDO> configs) {
|
||||||
Properties properties = propertiesFactory.getPropertiesInstance();
|
Properties properties = propertiesFactory.getPropertiesInstance();
|
||||||
configs.stream().filter(config -> 0 == config.getDeleted()) // 过滤掉被删除的配置
|
configs.stream().filter(config -> 0 == config.getDeleted()) // 过滤掉被删除的配置
|
||||||
.forEach(config -> properties.put(config.getKey(), config.getValue()));
|
.forEach(config -> properties.put(config.getKey(), config.getValue()));
|
||||||
@ -145,7 +143,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
|||||||
* @param maxUpdateTime 当前配置的最大更新时间
|
* @param maxUpdateTime 当前配置的最大更新时间
|
||||||
* @return 配置列表
|
* @return 配置列表
|
||||||
*/
|
*/
|
||||||
private List<SysConfigDO> loadConfigIfUpdate(Date maxUpdateTime) {
|
private List<InfConfigDO> loadConfigIfUpdate(Date maxUpdateTime) {
|
||||||
// 第一步,判断是否要更新。
|
// 第一步,判断是否要更新。
|
||||||
boolean isUpdate = maxUpdateTime == null; // 如果更新时间为空,说明 DB 一定有新数据
|
boolean isUpdate = maxUpdateTime == null; // 如果更新时间为空,说明 DB 一定有新数据
|
||||||
if (!isUpdate) {
|
if (!isUpdate) {
|
||||||
@ -159,12 +157,12 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean existsNewConfig(Date maxUpdateTime) {
|
private boolean existsNewConfig(Date maxUpdateTime) {
|
||||||
return jdbcTemplate.query("SELECT id FROM sys_config WHERE update_time > ? LIMIT 1",
|
return jdbcTemplate.query("SELECT id FROM inf_config WHERE update_time > ? LIMIT 1",
|
||||||
ResultSet::next, maxUpdateTime);
|
ResultSet::next, maxUpdateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SysConfigDO> getSysConfigList() {
|
private List<InfConfigDO> getSysConfigList() {
|
||||||
return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM sys_config", new BeanPropertyRowMapper<>(SysConfigDO.class));
|
return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM inf_config", new BeanPropertyRowMapper<>(InfConfigDO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* 配置中心客户端,基于 Apollo Client 进行简化
|
||||||
|
*
|
||||||
|
* 差别在于,我们使用 {@link cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO} 表作为配置源。
|
||||||
|
* 当然,功能肯定也会相对少些,满足最小化诉求。
|
||||||
|
*
|
||||||
|
* 1. 项目初始化时,可以使用 SysConfigDO 表的配置
|
||||||
|
* 2. 使用 Spring @Value 可以注入属性
|
||||||
|
* 3. SysConfigDO 表的配置修改时,注入到 @Value 的属性可以刷新
|
||||||
|
*
|
||||||
|
* 另外,整个包结构会参考 Apollo 为主,方便维护与理解
|
||||||
|
*/
|
||||||
package cn.iocoder.dashboard.framework.apollo;
|
package cn.iocoder.dashboard.framework.apollo;
|
||||||
|
@ -8,6 +8,11 @@ import com.ctrip.framework.apollo.internals.ConfigRepository;
|
|||||||
import com.ctrip.framework.apollo.internals.DefaultConfig;
|
import com.ctrip.framework.apollo.internals.DefaultConfig;
|
||||||
import com.ctrip.framework.apollo.spi.ConfigFactory;
|
import com.ctrip.framework.apollo.spi.ConfigFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基于 DB 的 ConfigFactory 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
public class DBConfigFactory implements ConfigFactory {
|
public class DBConfigFactory implements ConfigFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -21,7 +26,7 @@ public class DBConfigFactory implements ConfigFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ConfigRepository createDBConfigRepository(String namespace) {
|
private ConfigRepository createDBConfigRepository(String namespace) {
|
||||||
return new DBConfigRepository(namespace); // TODO 芋艿:看看怎么优化
|
return new DBConfigRepository(namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.apollo.spring.boot;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.framework.apollo.core.ConfigConsts;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.core.env.ConfigurableEnvironment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对 {@link com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer} 的补充,目前的目的有:
|
||||||
|
*
|
||||||
|
* 1. 将自定义的 apollo.jdbc 设置到 System 变量中
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class ApolloApplicationContextInitializer implements EnvironmentPostProcessor, Ordered {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优先级更高,要早于 Apollo 的 ApolloApplicationContextInitializer 的初始化
|
||||||
|
*/
|
||||||
|
public static final int DEFAULT_ORDER = -1;
|
||||||
|
|
||||||
|
private int order = DEFAULT_ORDER;
|
||||||
|
|
||||||
|
private static final String[] APOLLO_SYSTEM_PROPERTIES = {ConfigConsts.APOLLO_JDBC_URL,
|
||||||
|
ConfigConsts.APOLLO_JDBC_USERNAME, ConfigConsts.APOLLO_JDBC_PASSWORD};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||||
|
initializeSystemProperty(environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To fill system properties from environment config
|
||||||
|
*/
|
||||||
|
void initializeSystemProperty(ConfigurableEnvironment environment) {
|
||||||
|
for (String propertyName : APOLLO_SYSTEM_PROPERTIES) {
|
||||||
|
fillSystemPropertyFromEnvironment(environment, propertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillSystemPropertyFromEnvironment(ConfigurableEnvironment environment, String propertyName) {
|
||||||
|
if (System.getProperty(propertyName) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String propertyValue = environment.getProperty(propertyName);
|
||||||
|
if (Strings.isNullOrEmpty(propertyValue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
System.setProperty(propertyName, propertyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder() {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(int order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config;
|
package cn.iocoder.dashboard.modules.infra.controller.config;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.*;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.*;
|
||||||
import cn.iocoder.dashboard.modules.system.convert.config.SysConfigConvert;
|
import cn.iocoder.dashboard.modules.infra.convert.config.InfConfigConvert;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
|
||||||
import cn.iocoder.dashboard.modules.system.service.config.SysConfigService;
|
import cn.iocoder.dashboard.modules.infra.service.config.InfConfigService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -21,12 +21,12 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_SENSITIVE;
|
import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_SENSITIVE;
|
||||||
|
|
||||||
@Api(tags = "参数配置")
|
@Api(tags = "参数配置")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/config")
|
@RequestMapping("/infra/config")
|
||||||
public class SysConfigController {
|
public class InfConfigController {
|
||||||
|
|
||||||
@Value("${demo.test}")
|
@Value("${demo.test}")
|
||||||
private String demo;
|
private String demo;
|
||||||
@ -42,42 +42,42 @@ public class SysConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysConfigService configService;
|
private InfConfigService configService;
|
||||||
|
|
||||||
@ApiOperation("获取参数配置分页")
|
@ApiOperation("获取参数配置分页")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:config:list')")
|
// @PreAuthorize("@ss.hasPermi('infra:config:list')")
|
||||||
public CommonResult<PageResult<SysConfigRespVO>> getConfigPage(@Validated SysConfigPageReqVO reqVO) {
|
public CommonResult<PageResult<InfConfigRespVO>> getConfigPage(@Validated InfConfigPageReqVO reqVO) {
|
||||||
PageResult<SysConfigDO> page = configService.getConfigPage(reqVO);
|
PageResult<InfConfigDO> page = configService.getConfigPage(reqVO);
|
||||||
return success(SysConfigConvert.INSTANCE.convertPage(page));
|
return success(InfConfigConvert.INSTANCE.convertPage(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("导出参数配置")
|
@ApiOperation("导出参数配置")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
// @Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
// @Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
// @PreAuthorize("@ss.hasPermi('system:config:export')")
|
// @PreAuthorize("@ss.hasPermi('infra:config:export')")
|
||||||
public void exportSysConfig(HttpServletResponse response, @Validated SysConfigExportReqVO reqVO) throws IOException {
|
public void exportSysConfig(HttpServletResponse response, @Validated InfConfigExportReqVO reqVO) throws IOException {
|
||||||
List<SysConfigDO> list = configService.getConfigList(reqVO);
|
List<InfConfigDO> list = configService.getConfigList(reqVO);
|
||||||
// 拼接数据
|
// 拼接数据
|
||||||
List<SysConfigExcelVO> excelDataList = SysConfigConvert.INSTANCE.convertList(list);
|
List<InfConfigExcelVO> excelDataList = InfConfigConvert.INSTANCE.convertList(list);
|
||||||
// 输出
|
// 输出
|
||||||
ExcelUtils.write(response, "参数配置.xls", "配置列表",
|
ExcelUtils.write(response, "参数配置.xls", "配置列表",
|
||||||
SysConfigExcelVO.class, excelDataList);
|
InfConfigExcelVO.class, excelDataList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获得参数配置")
|
@ApiOperation("获得参数配置")
|
||||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||||
@GetMapping(value = "/get")
|
@GetMapping(value = "/get")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:config:query')")
|
// @PreAuthorize("@ss.hasPermi('infra:config:query')")
|
||||||
public CommonResult<SysConfigRespVO> getConfig(@RequestParam("id") Long id) {
|
public CommonResult<InfConfigRespVO> getConfig(@RequestParam("id") Long id) {
|
||||||
return success(SysConfigConvert.INSTANCE.convert(configService.getConfig(id)));
|
return success(InfConfigConvert.INSTANCE.convert(configService.getConfig(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "根据参数键名查询参数值", notes = "敏感配置,不允许返回给前端")
|
@ApiOperation(value = "根据参数键名查询参数值", notes = "敏感配置,不允许返回给前端")
|
||||||
@ApiImplicitParam(name = "key", value = "参数键", required = true, example = "yunai.biz.username", dataTypeClass = String.class)
|
@ApiImplicitParam(name = "key", value = "参数键", required = true, example = "yunai.biz.username", dataTypeClass = String.class)
|
||||||
@GetMapping(value = "/get-value-by-key")
|
@GetMapping(value = "/get-value-by-key")
|
||||||
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
|
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
|
||||||
SysConfigDO config = configService.getConfigByKey(key);
|
InfConfigDO config = configService.getConfigByKey(key);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -89,18 +89,18 @@ public class SysConfigController {
|
|||||||
|
|
||||||
@ApiOperation("新增参数配置")
|
@ApiOperation("新增参数配置")
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:config:add')")
|
// @PreAuthorize("@ss.hasPermi('infra:config:add')")
|
||||||
// @Log(title = "参数管理", businessType = BusinessType.INSERT)
|
// @Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
// @RepeatSubmit
|
// @RepeatSubmit
|
||||||
public CommonResult<Long> createConfig(@Validated @RequestBody SysConfigCreateReqVO reqVO) {
|
public CommonResult<Long> createConfig(@Validated @RequestBody InfConfigCreateReqVO reqVO) {
|
||||||
return success(configService.createConfig(reqVO));
|
return success(configService.createConfig(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改参数配置")
|
@ApiOperation("修改参数配置")
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:config:edit')")
|
// @PreAuthorize("@ss.hasPermi('infra:config:edit')")
|
||||||
// @Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
// @Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
public CommonResult<Boolean> edit(@Validated @RequestBody SysConfigUpdateReqVO reqVO) {
|
public CommonResult<Boolean> edit(@Validated @RequestBody InfConfigUpdateReqVO reqVO) {
|
||||||
configService.updateConfig(reqVO);
|
configService.updateConfig(reqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ public class SysConfigController {
|
|||||||
@ApiOperation("删除参数配置")
|
@ApiOperation("删除参数配置")
|
||||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:config:remove')")
|
// @PreAuthorize("@ss.hasPermi('infra:config:remove')")
|
||||||
// @Log(title = "参数管理", businessType = BusinessType.DELETE)
|
// @Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
|
||||||
configService.deleteConfig(id);
|
configService.deleteConfig(id);
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config.vo;
|
package cn.iocoder.dashboard.modules.infra.controller.config.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -13,7 +13,7 @@ import javax.validation.constraints.Size;
|
|||||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class SysConfigBaseVO {
|
public class InfConfigBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "参数分组", required = true, example = "biz")
|
@ApiModelProperty(value = "参数分组", required = true, example = "biz")
|
||||||
@NotEmpty(message = "参数分组不能为空")
|
@NotEmpty(message = "参数分组不能为空")
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config.vo;
|
package cn.iocoder.dashboard.modules.infra.controller.config.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -11,7 +11,7 @@ import javax.validation.constraints.Size;
|
|||||||
@ApiModel("参数配置创建 Request VO")
|
@ApiModel("参数配置创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class SysConfigCreateReqVO extends SysConfigBaseVO {
|
public class InfConfigCreateReqVO extends InfConfigBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "参数键名", required = true, example = "yunai.db.username")
|
@ApiModelProperty(value = "参数键名", required = true, example = "yunai.db.username")
|
||||||
@NotBlank(message = "参数键名长度不能为空")
|
@NotBlank(message = "参数键名长度不能为空")
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config.vo;
|
package cn.iocoder.dashboard.modules.infra.controller.config.vo;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
||||||
import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert;
|
import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert;
|
||||||
@ -12,7 +12,7 @@ import java.util.Date;
|
|||||||
* 参数配置 Excel 导出响应 VO
|
* 参数配置 Excel 导出响应 VO
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class SysConfigExcelVO {
|
public class InfConfigExcelVO {
|
||||||
|
|
||||||
@ExcelProperty("参数配置序号")
|
@ExcelProperty("参数配置序号")
|
||||||
private Long id;
|
private Long id;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config.vo;
|
package cn.iocoder.dashboard.modules.infra.controller.config.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -11,7 +11,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
|
|||||||
|
|
||||||
@ApiModel("参数配置导出 Request VO")
|
@ApiModel("参数配置导出 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class SysConfigExportReqVO {
|
public class InfConfigExportReqVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
|
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
|
||||||
private String name;
|
private String name;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config.vo;
|
package cn.iocoder.dashboard.modules.infra.controller.config.vo;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.PageParam;
|
import cn.iocoder.dashboard.common.pojo.PageParam;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@ -14,7 +14,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
|
|||||||
@ApiModel("参数配置分页 Request VO")
|
@ApiModel("参数配置分页 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class SysConfigPageReqVO extends PageParam {
|
public class InfConfigPageReqVO extends PageParam {
|
||||||
|
|
||||||
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
|
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
|
||||||
private String name;
|
private String name;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config.vo;
|
package cn.iocoder.dashboard.modules.infra.controller.config.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -12,7 +12,7 @@ import java.util.Date;
|
|||||||
@ApiModel("参数配置信息 Response VO")
|
@ApiModel("参数配置信息 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class SysConfigRespVO extends SysConfigBaseVO {
|
public class InfConfigRespVO extends InfConfigBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
|
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
|
||||||
private Long id;
|
private Long id;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.controller.config.vo;
|
package cn.iocoder.dashboard.modules.infra.controller.config.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull;
|
|||||||
@ApiModel("参数配置创建 Request VO")
|
@ApiModel("参数配置创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class SysConfigUpdateReqVO extends SysConfigBaseVO {
|
public class InfConfigUpdateReqVO extends InfConfigBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
|
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
|
||||||
@NotNull(message = "参数配置编号不能为空")
|
@NotNull(message = "参数配置编号不能为空")
|
@ -0,0 +1 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.infra.controller;
|
@ -0,0 +1,29 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.infra.convert.config;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigCreateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigExcelVO;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigRespVO;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigUpdateReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface InfConfigConvert {
|
||||||
|
|
||||||
|
InfConfigConvert INSTANCE = Mappers.getMapper(InfConfigConvert.class);
|
||||||
|
|
||||||
|
PageResult<InfConfigRespVO> convertPage(PageResult<InfConfigDO> page);
|
||||||
|
|
||||||
|
InfConfigRespVO convert(InfConfigDO bean);
|
||||||
|
|
||||||
|
InfConfigDO convert(InfConfigCreateReqVO bean);
|
||||||
|
|
||||||
|
InfConfigDO convert(InfConfigUpdateReqVO bean);
|
||||||
|
|
||||||
|
List<InfConfigExcelVO> convertList(List<InfConfigDO> list);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.infra.convert;
|
@ -1,33 +1,33 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.dal.mysql.dao.config;
|
package cn.iocoder.dashboard.modules.infra.dal.mysql.dao.config;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigExportReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigExportReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigPageReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigPageReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SysConfigMapper extends BaseMapperX<SysConfigDO> {
|
public interface InfConfigMapper extends BaseMapperX<InfConfigDO> {
|
||||||
|
|
||||||
default PageResult<SysConfigDO> selectPage(SysConfigPageReqVO reqVO) {
|
default PageResult<InfConfigDO> selectPage(InfConfigPageReqVO reqVO) {
|
||||||
return selectPage(reqVO,
|
return selectPage(reqVO,
|
||||||
new QueryWrapperX<SysConfigDO>().likeIfPresent("name", reqVO.getName())
|
new QueryWrapperX<InfConfigDO>().likeIfPresent("name", reqVO.getName())
|
||||||
.likeIfPresent("`key`", reqVO.getKey())
|
.likeIfPresent("`key`", reqVO.getKey())
|
||||||
.eqIfPresent("`type`", reqVO.getType())
|
.eqIfPresent("`type`", reqVO.getType())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
default SysConfigDO selectByKey(String key) {
|
default InfConfigDO selectByKey(String key) {
|
||||||
return selectOne(new QueryWrapper<SysConfigDO>().eq("`key`", key));
|
return selectOne(new QueryWrapper<InfConfigDO>().eq("`key`", key));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysConfigDO> selectList(SysConfigExportReqVO reqVO) {
|
default List<InfConfigDO> selectList(InfConfigExportReqVO reqVO) {
|
||||||
return selectList(new QueryWrapperX<SysConfigDO>().likeIfPresent("name", reqVO.getName())
|
return selectList(new QueryWrapperX<InfConfigDO>().likeIfPresent("name", reqVO.getName())
|
||||||
.likeIfPresent("`key`", reqVO.getKey())
|
.likeIfPresent("`key`", reqVO.getKey())
|
||||||
.eqIfPresent("`type`", reqVO.getType())
|
.eqIfPresent("`type`", reqVO.getType())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
@ -0,0 +1 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.infra.dal.mysql.dao;
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config;
|
package cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.dashboard.modules.system.enums.config.SysConfigTypeEnum;
|
import cn.iocoder.dashboard.modules.infra.enums.config.InfConfigTypeEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -13,11 +13,11 @@ import lombok.ToString;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@TableName("sys_config")
|
@TableName("inf_config")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class SysConfigDO extends BaseDO {
|
public class InfConfigDO extends BaseDO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数主键
|
* 参数主键
|
||||||
@ -44,7 +44,7 @@ public class SysConfigDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 参数类型
|
* 参数类型
|
||||||
*
|
*
|
||||||
* 枚举 {@link SysConfigTypeEnum}
|
* 枚举 {@link InfConfigTypeEnum}
|
||||||
*/
|
*/
|
||||||
@TableField("`type`")
|
@TableField("`type`")
|
||||||
private Integer type;
|
private Integer type;
|
@ -0,0 +1 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject;
|
@ -0,0 +1,18 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.infra.enums;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Infra 错误码枚举类
|
||||||
|
*
|
||||||
|
* system 系统,使用 1-001-000-000 段
|
||||||
|
*/
|
||||||
|
public interface InfErrorCodeConstants {
|
||||||
|
|
||||||
|
// ========== 参数配置 1001000000 ==========
|
||||||
|
ErrorCode CONFIG_NOT_FOUND = new ErrorCode(1001000001, "参数配置不存在");
|
||||||
|
ErrorCode CONFIG_NAME_DUPLICATE = new ErrorCode(1001000002, "参数配置 key 重复");
|
||||||
|
ErrorCode CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE = new ErrorCode(1001000003, "不能删除类型为系统内置的参数配置");
|
||||||
|
ErrorCode CONFIG_GET_VALUE_ERROR_IF_SENSITIVE = new ErrorCode(1001000004, "不允许获取敏感配置到前端");
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.enums.config;
|
package cn.iocoder.dashboard.modules.infra.enums.config;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum SysConfigTypeEnum {
|
public enum InfConfigTypeEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统配置
|
* 系统配置
|
@ -1,18 +1,18 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.service.config;
|
package cn.iocoder.dashboard.modules.infra.service.config;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigCreateReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigCreateReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigExportReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigExportReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigPageReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigPageReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigUpdateReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigUpdateReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数配置 Service 接口
|
* 参数配置 Service 接口
|
||||||
*/
|
*/
|
||||||
public interface SysConfigService {
|
public interface InfConfigService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得参数配置分页列表
|
* 获得参数配置分页列表
|
||||||
@ -20,7 +20,7 @@ public interface SysConfigService {
|
|||||||
* @param reqVO 分页条件
|
* @param reqVO 分页条件
|
||||||
* @return 分页列表
|
* @return 分页列表
|
||||||
*/
|
*/
|
||||||
PageResult<SysConfigDO> getConfigPage(SysConfigPageReqVO reqVO);
|
PageResult<InfConfigDO> getConfigPage(InfConfigPageReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得参数配置列表
|
* 获得参数配置列表
|
||||||
@ -28,7 +28,7 @@ public interface SysConfigService {
|
|||||||
* @param reqVO 列表
|
* @param reqVO 列表
|
||||||
* @return 列表
|
* @return 列表
|
||||||
*/
|
*/
|
||||||
List<SysConfigDO> getConfigList(SysConfigExportReqVO reqVO);
|
List<InfConfigDO> getConfigList(InfConfigExportReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得参数配置
|
* 获得参数配置
|
||||||
@ -36,7 +36,7 @@ public interface SysConfigService {
|
|||||||
* @param id 配置编号
|
* @param id 配置编号
|
||||||
* @return 参数配置
|
* @return 参数配置
|
||||||
*/
|
*/
|
||||||
SysConfigDO getConfig(Long id);
|
InfConfigDO getConfig(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参数键,获得参数配置
|
* 根据参数键,获得参数配置
|
||||||
@ -44,7 +44,7 @@ public interface SysConfigService {
|
|||||||
* @param key 配置键
|
* @param key 配置键
|
||||||
* @return 参数配置
|
* @return 参数配置
|
||||||
*/
|
*/
|
||||||
SysConfigDO getConfigByKey(String key);
|
InfConfigDO getConfigByKey(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建参数配置
|
* 创建参数配置
|
||||||
@ -52,14 +52,14 @@ public interface SysConfigService {
|
|||||||
* @param reqVO 创建信息
|
* @param reqVO 创建信息
|
||||||
* @return 配置编号
|
* @return 配置编号
|
||||||
*/
|
*/
|
||||||
Long createConfig(SysConfigCreateReqVO reqVO);
|
Long createConfig(InfConfigCreateReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新参数配置
|
* 更新参数配置
|
||||||
*
|
*
|
||||||
* @param reqVO 更新信息
|
* @param reqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateConfig(SysConfigUpdateReqVO reqVO);
|
void updateConfig(InfConfigUpdateReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除参数配置
|
* 删除参数配置
|
@ -1,16 +1,16 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.service.config.impl;
|
package cn.iocoder.dashboard.modules.infra.service.config.impl;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigCreateReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigCreateReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigExportReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigExportReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigPageReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigPageReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigUpdateReqVO;
|
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigUpdateReqVO;
|
||||||
import cn.iocoder.dashboard.modules.system.convert.config.SysConfigConvert;
|
import cn.iocoder.dashboard.modules.infra.convert.config.InfConfigConvert;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.config.SysConfigMapper;
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.dao.config.InfConfigMapper;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
|
import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
|
||||||
import cn.iocoder.dashboard.modules.system.enums.config.SysConfigTypeEnum;
|
import cn.iocoder.dashboard.modules.infra.enums.config.InfConfigTypeEnum;
|
||||||
import cn.iocoder.dashboard.modules.system.service.config.SysConfigService;
|
import cn.iocoder.dashboard.modules.infra.service.config.InfConfigService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -18,64 +18,64 @@ import javax.annotation.Resource;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
|
import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数配置 Service 实现类
|
* 参数配置 Service 实现类
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SysConfigServiceImpl implements SysConfigService {
|
public class InfConfigServiceImpl implements InfConfigService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysConfigMapper configMapper;
|
private InfConfigMapper configMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<SysConfigDO> getConfigPage(SysConfigPageReqVO reqVO) {
|
public PageResult<InfConfigDO> getConfigPage(InfConfigPageReqVO reqVO) {
|
||||||
return configMapper.selectPage(reqVO);
|
return configMapper.selectPage(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysConfigDO> getConfigList(SysConfigExportReqVO reqVO) {
|
public List<InfConfigDO> getConfigList(InfConfigExportReqVO reqVO) {
|
||||||
return configMapper.selectList(reqVO);
|
return configMapper.selectList(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysConfigDO getConfig(Long id) {
|
public InfConfigDO getConfig(Long id) {
|
||||||
return configMapper.selectById(id);
|
return configMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysConfigDO getConfigByKey(String key) {
|
public InfConfigDO getConfigByKey(String key) {
|
||||||
return configMapper.selectByKey(key);
|
return configMapper.selectByKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createConfig(SysConfigCreateReqVO reqVO) {
|
public Long createConfig(InfConfigCreateReqVO reqVO) {
|
||||||
// 校验正确性
|
// 校验正确性
|
||||||
checkCreateOrUpdate(null, reqVO.getKey());
|
checkCreateOrUpdate(null, reqVO.getKey());
|
||||||
// 插入参数配置
|
// 插入参数配置
|
||||||
SysConfigDO config = SysConfigConvert.INSTANCE.convert(reqVO);
|
InfConfigDO config = InfConfigConvert.INSTANCE.convert(reqVO);
|
||||||
config.setType(SysConfigTypeEnum.CUSTOM.getType());
|
config.setType(InfConfigTypeEnum.CUSTOM.getType());
|
||||||
configMapper.insert(config);
|
configMapper.insert(config);
|
||||||
return config.getId();
|
return config.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateConfig(SysConfigUpdateReqVO reqVO) {
|
public void updateConfig(InfConfigUpdateReqVO reqVO) {
|
||||||
// 校验正确性
|
// 校验正确性
|
||||||
checkCreateOrUpdate(reqVO.getId(), null); // 不允许更新 key
|
checkCreateOrUpdate(reqVO.getId(), null); // 不允许更新 key
|
||||||
// 更新参数配置
|
// 更新参数配置
|
||||||
SysConfigDO updateObj = SysConfigConvert.INSTANCE.convert(reqVO);
|
InfConfigDO updateObj = InfConfigConvert.INSTANCE.convert(reqVO);
|
||||||
configMapper.updateById(updateObj);
|
configMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteConfig(Long id) {
|
public void deleteConfig(Long id) {
|
||||||
// 校验配置存在
|
// 校验配置存在
|
||||||
SysConfigDO config = checkConfigExists(id);
|
InfConfigDO config = checkConfigExists(id);
|
||||||
// 内置配置,不允许删除
|
// 内置配置,不允许删除
|
||||||
if (SysConfigTypeEnum.SYSTEM.getType().equals(config.getType())) {
|
if (InfConfigTypeEnum.SYSTEM.getType().equals(config.getType())) {
|
||||||
throw ServiceExceptionUtil.exception(CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE);
|
throw ServiceExceptionUtil.exception(CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE);
|
||||||
}
|
}
|
||||||
// 删除
|
// 删除
|
||||||
@ -89,11 +89,11 @@ public class SysConfigServiceImpl implements SysConfigService {
|
|||||||
checkConfigKeyUnique(id, key);
|
checkConfigKeyUnique(id, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SysConfigDO checkConfigExists(Long id) {
|
private InfConfigDO checkConfigExists(Long id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
SysConfigDO config = configMapper.selectById(id);
|
InfConfigDO config = configMapper.selectById(id);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
throw ServiceExceptionUtil.exception(CONFIG_NOT_FOUND);
|
throw ServiceExceptionUtil.exception(CONFIG_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ public class SysConfigServiceImpl implements SysConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkConfigKeyUnique(Long id, String key) {
|
private void checkConfigKeyUnique(Long id, String key) {
|
||||||
SysConfigDO config = configMapper.selectByKey(key);
|
InfConfigDO config = configMapper.selectByKey(key);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
@ -0,0 +1 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.infra.service;
|
@ -1,29 +0,0 @@
|
|||||||
package cn.iocoder.dashboard.modules.system.convert.config;
|
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigCreateReqVO;
|
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigExcelVO;
|
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigRespVO;
|
|
||||||
import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigUpdateReqVO;
|
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface SysConfigConvert {
|
|
||||||
|
|
||||||
SysConfigConvert INSTANCE = Mappers.getMapper(SysConfigConvert.class);
|
|
||||||
|
|
||||||
PageResult<SysConfigRespVO> convertPage(PageResult<SysConfigDO> page);
|
|
||||||
|
|
||||||
SysConfigRespVO convert(SysConfigDO bean);
|
|
||||||
|
|
||||||
SysConfigDO convert(SysConfigCreateReqVO bean);
|
|
||||||
|
|
||||||
SysConfigDO convert(SysConfigUpdateReqVO bean);
|
|
||||||
|
|
||||||
List<SysConfigExcelVO> convertList(List<SysConfigDO> list);
|
|
||||||
|
|
||||||
}
|
|
@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.system.enums;
|
|||||||
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误码枚举类
|
* System 错误码枚举类
|
||||||
*
|
*
|
||||||
* system 系统,使用 1-002-000-000 段
|
* system 系统,使用 1-002-000-000 段
|
||||||
*/
|
*/
|
||||||
@ -75,9 +75,4 @@ public interface SysErrorCodeConstants {
|
|||||||
// ========== 文件 1002009000 ==========
|
// ========== 文件 1002009000 ==========
|
||||||
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1002009001, "文件路径已经存在");
|
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1002009001, "文件路径已经存在");
|
||||||
|
|
||||||
// ========== 参数配置 1002010000 ==========
|
|
||||||
ErrorCode CONFIG_NOT_FOUND = new ErrorCode(1002010001, "参数配置不存在");
|
|
||||||
ErrorCode CONFIG_NAME_DUPLICATE = new ErrorCode(1002010002, "参数配置 key 重复");
|
|
||||||
ErrorCode CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE = new ErrorCode(1002010003, "不能删除类型为系统内置的参数配置");
|
|
||||||
ErrorCode CONFIG_GET_VALUE_ERROR_IF_SENSITIVE = new ErrorCode(1002010004, "不允许获取敏感配置到前端");
|
|
||||||
}
|
}
|
||||||
|
2
src/main/resources/META-INF/spring.factories
Normal file
2
src/main/resources/META-INF/spring.factories
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||||
|
cn.iocoder.dashboard.framework.apollo.spring.boot.ApolloApplicationContextInitializer
|
@ -53,6 +53,10 @@ apollo:
|
|||||||
enabled: true # 设置 Apollo 在启动阶段生效
|
enabled: true # 设置 Apollo 在启动阶段生效
|
||||||
eagerLoad:
|
eagerLoad:
|
||||||
enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
|
enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
|
||||||
|
jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
|
||||||
|
url: ${spring.datasource.url}
|
||||||
|
username: ${spring.datasource.username}
|
||||||
|
password: ${spring.datasource.password}
|
||||||
|
|
||||||
# MyBatis Plus 的配置项
|
# MyBatis Plus 的配置项
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
Loading…
Reference in New Issue
Block a user