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