diff --git a/pom.xml b/pom.xml
index 8fb46e19c..56e5d9e27 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,6 @@
2.4.2
-
@@ -48,7 +47,7 @@
5.1.46
1.2.4
3.4.1
- 3.13.6
+ 3.14.1
8.3.0
@@ -142,6 +141,12 @@
com.github.xiaoymin
knife4j-spring-boot-starter
${knife4j.version}
+
+
+ mapstruct
+ org.mapstruct
+
+
diff --git a/ruoyi-ui/src/api/system/config.js b/ruoyi-ui/src/api/system/config.js
index 56301ad40..eec151779 100644
--- a/ruoyi-ui/src/api/system/config.js
+++ b/ruoyi-ui/src/api/system/config.js
@@ -1,62 +1,62 @@
-import request from '@/utils/request'
-
-// 查询参数列表
-export function listConfig(query) {
- return request({
- url: '/system/config/page',
- method: 'get',
- params: query
- })
-}
-
-// 查询参数详细
-export function getConfig(configId) {
- return request({
- url: '/system/config/get?id=' + configId,
- method: 'get'
- })
-}
-
-// 根据参数键名查询参数值
-export function getConfigKey(configKey) {
- return request({
- url: '/system/config/get-value-by-key?key=' + configKey,
- method: 'get'
- })
-}
-
-// 新增参数配置
-export function addConfig(data) {
- return request({
- url: '/system/config/create',
- method: 'post',
- data: data
- })
-}
-
-// 修改参数配置
-export function updateConfig(data) {
- return request({
- url: '/system/config/update',
- method: 'put',
- data: data
- })
-}
-
-// 删除参数配置
-export function delConfig(configId) {
- return request({
- url: '/system/config/delete?id=' + configId,
- method: 'delete'
- })
-}
-
-// 导出参数
-export function exportConfig(query) {
- return request({
- url: '/system/config/export',
- method: 'get',
- params: query,
- responseType: 'blob'
- })
-}
+import request from '@/utils/request'
+
+// 查询参数列表
+export function listConfig(query) {
+ return request({
+ url: '/infra/config/page',
+ method: 'get',
+ params: query
+ })
+}
+
+// 查询参数详细
+export function getConfig(configId) {
+ return request({
+ url: '/infra/config/get?id=' + configId,
+ method: 'get'
+ })
+}
+
+// 根据参数键名查询参数值
+export function getConfigKey(configKey) {
+ return request({
+ url: '/infra/config/get-value-by-key?key=' + configKey,
+ method: 'get'
+ })
+}
+
+// 新增参数配置
+export function addConfig(data) {
+ return request({
+ url: '/infra/config/create',
+ method: 'post',
+ data: data
+ })
+}
+
+// 修改参数配置
+export function updateConfig(data) {
+ return request({
+ url: '/infra/config/update',
+ method: 'put',
+ data: data
+ })
+}
+
+// 删除参数配置
+export function delConfig(configId) {
+ return request({
+ url: '/infra/config/delete?id=' + configId,
+ method: 'delete'
+ })
+}
+
+// 导出参数
+export function exportConfig(query) {
+ return request({
+ url: '/infra/config/export',
+ method: 'get',
+ params: query,
+ responseType: 'blob'
+ })
+}
diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue
index 7c0d92137..f53cedd28 100644
--- a/ruoyi-ui/src/views/system/config/index.vue
+++ b/ruoyi-ui/src/views/system/config/index.vue
@@ -304,7 +304,10 @@ export default {
},
/** 导出按钮操作 */
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('是否确认导出所有参数数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
diff --git a/src/main/java/cn/iocoder/dashboard/framework/apollo/core/ConfigConsts.java b/src/main/java/cn/iocoder/dashboard/framework/apollo/core/ConfigConsts.java
new file mode 100644
index 000000000..2d83836f9
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/framework/apollo/core/ConfigConsts.java
@@ -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";
+
+}
diff --git a/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java b/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java
index eeb583398..9898591dc 100644
--- a/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java
+++ b/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java
@@ -1,8 +1,9 @@
package cn.iocoder.dashboard.framework.apollo.internals;
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.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.build.ApolloInjector;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
@@ -59,12 +60,9 @@ public class DBConfigRepository extends AbstractConfigRepository {
this.m_namespace = namespace;
this.propertiesFactory = ApolloInjector.getInstance(PropertiesFactory.class);
this.m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
- // TODO 优化到配置
- String url = "jdbc:mysql://127.0.1:33061/ruoyi-vue-pro?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT";
- String username = "root";
- String password = "123456";
-// DataSource dataSource = DataSourceBuilder.create().url(url).username(username).password(password).build();
- DataSource dataSource = new DriverManagerDataSource(url, username, password);
+ // 初始化 DB
+ DataSource dataSource = new DriverManagerDataSource(System.getProperty(ConfigConsts.APOLLO_JDBC_URL),
+ System.getProperty(ConfigConsts.APOLLO_JDBC_USERNAME), System.getProperty(ConfigConsts.APOLLO_JDBC_PASSWORD));
this.jdbcTemplate = new JdbcTemplate(dataSource);
// 初始化加载
@@ -76,7 +74,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
@Override
protected void sync() {
// 第一步,尝试获取配置
- List configs = this.loadConfigIfUpdate(this.maxUpdateTime);
+ List configs = this.loadConfigIfUpdate(this.maxUpdateTime);
if (CollUtil.isEmpty(configs)) { // 如果没有更新,则返回
return;
}
@@ -111,7 +109,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
return ConfigSourceType.REMOTE;
}
- private Properties buildProperties(List configs) {
+ private Properties buildProperties(List configs) {
Properties properties = propertiesFactory.getPropertiesInstance();
configs.stream().filter(config -> 0 == config.getDeleted()) // 过滤掉被删除的配置
.forEach(config -> properties.put(config.getKey(), config.getValue()));
@@ -145,7 +143,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
* @param maxUpdateTime 当前配置的最大更新时间
* @return 配置列表
*/
- private List loadConfigIfUpdate(Date maxUpdateTime) {
+ private List loadConfigIfUpdate(Date maxUpdateTime) {
// 第一步,判断是否要更新。
boolean isUpdate = maxUpdateTime == null; // 如果更新时间为空,说明 DB 一定有新数据
if (!isUpdate) {
@@ -159,12 +157,12 @@ public class DBConfigRepository extends AbstractConfigRepository {
}
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);
}
- private List getSysConfigList() {
- return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM sys_config", new BeanPropertyRowMapper<>(SysConfigDO.class));
+ private List getSysConfigList() {
+ return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM inf_config", new BeanPropertyRowMapper<>(InfConfigDO.class));
}
}
diff --git a/src/main/java/cn/iocoder/dashboard/framework/apollo/package-info.java b/src/main/java/cn/iocoder/dashboard/framework/apollo/package-info.java
index f8a617005..ce21e8454 100644
--- a/src/main/java/cn/iocoder/dashboard/framework/apollo/package-info.java
+++ b/src/main/java/cn/iocoder/dashboard/framework/apollo/package-info.java
@@ -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;
diff --git a/src/main/java/cn/iocoder/dashboard/framework/apollo/spi/DBConfigFactory.java b/src/main/java/cn/iocoder/dashboard/framework/apollo/spi/DBConfigFactory.java
index 8bc760a4b..bfa9e53fb 100644
--- a/src/main/java/cn/iocoder/dashboard/framework/apollo/spi/DBConfigFactory.java
+++ b/src/main/java/cn/iocoder/dashboard/framework/apollo/spi/DBConfigFactory.java
@@ -8,6 +8,11 @@ import com.ctrip.framework.apollo.internals.ConfigRepository;
import com.ctrip.framework.apollo.internals.DefaultConfig;
import com.ctrip.framework.apollo.spi.ConfigFactory;
+/**
+ * 基于 DB 的 ConfigFactory 实现类
+ *
+ * @author 芋道源码
+ */
public class DBConfigFactory implements ConfigFactory {
@Override
@@ -21,7 +26,7 @@ public class DBConfigFactory implements ConfigFactory {
}
private ConfigRepository createDBConfigRepository(String namespace) {
- return new DBConfigRepository(namespace); // TODO 芋艿:看看怎么优化
+ return new DBConfigRepository(namespace);
}
}
diff --git a/src/main/java/cn/iocoder/dashboard/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java b/src/main/java/cn/iocoder/dashboard/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java
new file mode 100644
index 000000000..86498fe74
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java
@@ -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;
+ }
+
+}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/SysConfigController.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/InfConfigController.java
similarity index 65%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/SysConfigController.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/InfConfigController.java
index 45b05569c..a72ececad 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/SysConfigController.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/InfConfigController.java
@@ -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.pojo.CommonResult;
import cn.iocoder.dashboard.common.pojo.PageResult;
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.*;
-import cn.iocoder.dashboard.modules.system.convert.config.SysConfigConvert;
-import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
-import cn.iocoder.dashboard.modules.system.service.config.SysConfigService;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.*;
+import cn.iocoder.dashboard.modules.infra.convert.config.InfConfigConvert;
+import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
+import cn.iocoder.dashboard.modules.infra.service.config.InfConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@@ -21,12 +21,12 @@ import java.io.IOException;
import java.util.List;
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 = "参数配置")
@RestController
-@RequestMapping("/system/config")
-public class SysConfigController {
+@RequestMapping("/infra/config")
+public class InfConfigController {
@Value("${demo.test}")
private String demo;
@@ -42,42 +42,42 @@ public class SysConfigController {
}
@Resource
- private SysConfigService configService;
+ private InfConfigService configService;
@ApiOperation("获取参数配置分页")
@GetMapping("/page")
-// @PreAuthorize("@ss.hasPermi('system:config:list')")
- public CommonResult> getConfigPage(@Validated SysConfigPageReqVO reqVO) {
- PageResult page = configService.getConfigPage(reqVO);
- return success(SysConfigConvert.INSTANCE.convertPage(page));
+// @PreAuthorize("@ss.hasPermi('infra:config:list')")
+ public CommonResult> getConfigPage(@Validated InfConfigPageReqVO reqVO) {
+ PageResult page = configService.getConfigPage(reqVO);
+ return success(InfConfigConvert.INSTANCE.convertPage(page));
}
@ApiOperation("导出参数配置")
@GetMapping("/export")
// @Log(title = "参数管理", businessType = BusinessType.EXPORT)
-// @PreAuthorize("@ss.hasPermi('system:config:export')")
- public void exportSysConfig(HttpServletResponse response, @Validated SysConfigExportReqVO reqVO) throws IOException {
- List list = configService.getConfigList(reqVO);
+// @PreAuthorize("@ss.hasPermi('infra:config:export')")
+ public void exportSysConfig(HttpServletResponse response, @Validated InfConfigExportReqVO reqVO) throws IOException {
+ List list = configService.getConfigList(reqVO);
// 拼接数据
- List excelDataList = SysConfigConvert.INSTANCE.convertList(list);
+ List excelDataList = InfConfigConvert.INSTANCE.convertList(list);
// 输出
ExcelUtils.write(response, "参数配置.xls", "配置列表",
- SysConfigExcelVO.class, excelDataList);
+ InfConfigExcelVO.class, excelDataList);
}
@ApiOperation("获得参数配置")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@GetMapping(value = "/get")
-// @PreAuthorize("@ss.hasPermi('system:config:query')")
- public CommonResult getConfig(@RequestParam("id") Long id) {
- return success(SysConfigConvert.INSTANCE.convert(configService.getConfig(id)));
+// @PreAuthorize("@ss.hasPermi('infra:config:query')")
+ public CommonResult getConfig(@RequestParam("id") Long id) {
+ return success(InfConfigConvert.INSTANCE.convert(configService.getConfig(id)));
}
@ApiOperation(value = "根据参数键名查询参数值", notes = "敏感配置,不允许返回给前端")
@ApiImplicitParam(name = "key", value = "参数键", required = true, example = "yunai.biz.username", dataTypeClass = String.class)
@GetMapping(value = "/get-value-by-key")
public CommonResult getConfigKey(@RequestParam("key") String key) {
- SysConfigDO config = configService.getConfigByKey(key);
+ InfConfigDO config = configService.getConfigByKey(key);
if (config == null) {
return null;
}
@@ -89,18 +89,18 @@ public class SysConfigController {
@ApiOperation("新增参数配置")
@PostMapping("/create")
-// @PreAuthorize("@ss.hasPermi('system:config:add')")
+// @PreAuthorize("@ss.hasPermi('infra:config:add')")
// @Log(title = "参数管理", businessType = BusinessType.INSERT)
// @RepeatSubmit
- public CommonResult createConfig(@Validated @RequestBody SysConfigCreateReqVO reqVO) {
+ public CommonResult createConfig(@Validated @RequestBody InfConfigCreateReqVO reqVO) {
return success(configService.createConfig(reqVO));
}
@ApiOperation("修改参数配置")
@PutMapping("/update")
-// @PreAuthorize("@ss.hasPermi('system:config:edit')")
+// @PreAuthorize("@ss.hasPermi('infra:config:edit')")
// @Log(title = "参数管理", businessType = BusinessType.UPDATE)
- public CommonResult edit(@Validated @RequestBody SysConfigUpdateReqVO reqVO) {
+ public CommonResult edit(@Validated @RequestBody InfConfigUpdateReqVO reqVO) {
configService.updateConfig(reqVO);
return success(true);
}
@@ -108,7 +108,7 @@ public class SysConfigController {
@ApiOperation("删除参数配置")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@DeleteMapping("/delete")
-// @PreAuthorize("@ss.hasPermi('system:config:remove')")
+// @PreAuthorize("@ss.hasPermi('infra:config:remove')")
// @Log(title = "参数管理", businessType = BusinessType.DELETE)
public CommonResult deleteConfig(@RequestParam("id") Long id) {
configService.deleteConfig(id);
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigBaseVO.java
similarity index 93%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigBaseVO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigBaseVO.java
index 90d4922c5..bf086f0a6 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigBaseVO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigBaseVO.java
@@ -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 lombok.Data;
@@ -13,7 +13,7 @@ import javax.validation.constraints.Size;
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
-public class SysConfigBaseVO {
+public class InfConfigBaseVO {
@ApiModelProperty(value = "参数分组", required = true, example = "biz")
@NotEmpty(message = "参数分组不能为空")
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigCreateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigCreateReqVO.java
similarity index 82%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigCreateReqVO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigCreateReqVO.java
index 98bb4be00..7b0bcfb5d 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigCreateReqVO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigCreateReqVO.java
@@ -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.ApiModelProperty;
@@ -11,7 +11,7 @@ import javax.validation.constraints.Size;
@ApiModel("参数配置创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
-public class SysConfigCreateReqVO extends SysConfigBaseVO {
+public class InfConfigCreateReqVO extends InfConfigBaseVO {
@ApiModelProperty(value = "参数键名", required = true, example = "yunai.db.username")
@NotBlank(message = "参数键名长度不能为空")
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigExcelVO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigExcelVO.java
similarity index 91%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigExcelVO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigExcelVO.java
index 75f9671ed..a11de329c 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigExcelVO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigExcelVO.java
@@ -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.convert.DictConvert;
@@ -12,7 +12,7 @@ import java.util.Date;
* 参数配置 Excel 导出响应 VO
*/
@Data
-public class SysConfigExcelVO {
+public class InfConfigExcelVO {
@ExcelProperty("参数配置序号")
private Long id;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigExportReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigExportReqVO.java
similarity index 91%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigExportReqVO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigExportReqVO.java
index 85dfe96c3..b2145203b 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigExportReqVO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigExportReqVO.java
@@ -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.ApiModelProperty;
@@ -11,7 +11,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
@ApiModel("参数配置导出 Request VO")
@Data
-public class SysConfigExportReqVO {
+public class InfConfigExportReqVO {
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
private String name;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigPageReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigPageReqVO.java
similarity index 90%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigPageReqVO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigPageReqVO.java
index 29299664c..9af18b16a 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigPageReqVO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigPageReqVO.java
@@ -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 io.swagger.annotations.ApiModel;
@@ -14,7 +14,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
@ApiModel("参数配置分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
-public class SysConfigPageReqVO extends PageParam {
+public class InfConfigPageReqVO extends PageParam {
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
private String name;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigRespVO.java
similarity index 88%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigRespVO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigRespVO.java
index 8934a7eed..10673e2d3 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigRespVO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigRespVO.java
@@ -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.ApiModelProperty;
@@ -12,7 +12,7 @@ import java.util.Date;
@ApiModel("参数配置信息 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
-public class SysConfigRespVO extends SysConfigBaseVO {
+public class InfConfigRespVO extends InfConfigBaseVO {
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
private Long id;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigUpdateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigUpdateReqVO.java
similarity index 77%
rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigUpdateReqVO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigUpdateReqVO.java
index b4c9d978a..3d0f5c7b4 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/config/vo/SysConfigUpdateReqVO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/config/vo/InfConfigUpdateReqVO.java
@@ -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.ApiModelProperty;
@@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull;
@ApiModel("参数配置创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
-public class SysConfigUpdateReqVO extends SysConfigBaseVO {
+public class InfConfigUpdateReqVO extends InfConfigBaseVO {
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
@NotNull(message = "参数配置编号不能为空")
diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/package-info.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/package-info.java
new file mode 100644
index 000000000..c8d5eb166
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/package-info.java
@@ -0,0 +1 @@
+package cn.iocoder.dashboard.modules.infra.controller;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/convert/config/InfConfigConvert.java b/src/main/java/cn/iocoder/dashboard/modules/infra/convert/config/InfConfigConvert.java
new file mode 100644
index 000000000..e53c84bf9
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/convert/config/InfConfigConvert.java
@@ -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 convertPage(PageResult page);
+
+ InfConfigRespVO convert(InfConfigDO bean);
+
+ InfConfigDO convert(InfConfigCreateReqVO bean);
+
+ InfConfigDO convert(InfConfigUpdateReqVO bean);
+
+ List convertList(List list);
+
+}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/convert/package-info.java b/src/main/java/cn/iocoder/dashboard/modules/infra/convert/package-info.java
new file mode 100644
index 000000000..7479ece0e
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/convert/package-info.java
@@ -0,0 +1 @@
+package cn.iocoder.dashboard.modules.infra.convert;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/config/SysConfigMapper.java b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dao/config/InfConfigMapper.java
similarity index 55%
rename from src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/config/SysConfigMapper.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dao/config/InfConfigMapper.java
index 41201ec97..3e4e2bc37 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/config/SysConfigMapper.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dao/config/InfConfigMapper.java
@@ -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.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigExportReqVO;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigPageReqVO;
-import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigExportReqVO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigPageReqVO;
+import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
-public interface SysConfigMapper extends BaseMapperX {
+public interface InfConfigMapper extends BaseMapperX {
- default PageResult selectPage(SysConfigPageReqVO reqVO) {
+ default PageResult selectPage(InfConfigPageReqVO reqVO) {
return selectPage(reqVO,
- new QueryWrapperX().likeIfPresent("name", reqVO.getName())
+ new QueryWrapperX().likeIfPresent("name", reqVO.getName())
.likeIfPresent("`key`", reqVO.getKey())
.eqIfPresent("`type`", reqVO.getType())
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
}
- default SysConfigDO selectByKey(String key) {
- return selectOne(new QueryWrapper().eq("`key`", key));
+ default InfConfigDO selectByKey(String key) {
+ return selectOne(new QueryWrapper().eq("`key`", key));
}
- default List selectList(SysConfigExportReqVO reqVO) {
- return selectList(new QueryWrapperX().likeIfPresent("name", reqVO.getName())
+ default List selectList(InfConfigExportReqVO reqVO) {
+ return selectList(new QueryWrapperX().likeIfPresent("name", reqVO.getName())
.likeIfPresent("`key`", reqVO.getKey())
.eqIfPresent("`type`", reqVO.getType())
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dao/package-info.java b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dao/package-info.java
new file mode 100644
index 000000000..129637d95
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dao/package-info.java
@@ -0,0 +1 @@
+package cn.iocoder.dashboard.modules.infra.dal.mysql.dao;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/config/SysConfigDO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dataobject/config/InfConfigDO.java
similarity index 80%
rename from src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/config/SysConfigDO.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dataobject/config/InfConfigDO.java
index 73f01a397..7d5dee858 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/config/SysConfigDO.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dataobject/config/InfConfigDO.java
@@ -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.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.TableName;
import lombok.Data;
@@ -13,11 +13,11 @@ import lombok.ToString;
*
* @author ruoyi
*/
-@TableName("sys_config")
+@TableName("inf_config")
@Data
@EqualsAndHashCode(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`")
private Integer type;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dataobject/package-info.java b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dataobject/package-info.java
new file mode 100644
index 000000000..6e04595d1
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/dataobject/package-info.java
@@ -0,0 +1 @@
+package cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java b/src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java
new file mode 100644
index 000000000..20e2f390a
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java
@@ -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, "不允许获取敏感配置到前端");
+
+}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/config/SysConfigTypeEnum.java b/src/main/java/cn/iocoder/dashboard/modules/infra/enums/config/InfConfigTypeEnum.java
similarity index 71%
rename from src/main/java/cn/iocoder/dashboard/modules/system/enums/config/SysConfigTypeEnum.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/enums/config/InfConfigTypeEnum.java
index ef3a51b5e..315da6f56 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/enums/config/SysConfigTypeEnum.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/enums/config/InfConfigTypeEnum.java
@@ -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.Getter;
@Getter
@AllArgsConstructor
-public enum SysConfigTypeEnum {
+public enum InfConfigTypeEnum {
/**
* 系统配置
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/config/SysConfigService.java b/src/main/java/cn/iocoder/dashboard/modules/infra/service/config/InfConfigService.java
similarity index 51%
rename from src/main/java/cn/iocoder/dashboard/modules/system/service/config/SysConfigService.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/service/config/InfConfigService.java
index 735ba425e..f367f6f08 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/config/SysConfigService.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/service/config/InfConfigService.java
@@ -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.modules.system.controller.config.vo.SysConfigCreateReqVO;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigExportReqVO;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigPageReqVO;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigUpdateReqVO;
-import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigCreateReqVO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigExportReqVO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigPageReqVO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigUpdateReqVO;
+import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
import java.util.List;
/**
* 参数配置 Service 接口
*/
-public interface SysConfigService {
+public interface InfConfigService {
/**
* 获得参数配置分页列表
@@ -20,7 +20,7 @@ public interface SysConfigService {
* @param reqVO 分页条件
* @return 分页列表
*/
- PageResult getConfigPage(SysConfigPageReqVO reqVO);
+ PageResult getConfigPage(InfConfigPageReqVO reqVO);
/**
* 获得参数配置列表
@@ -28,7 +28,7 @@ public interface SysConfigService {
* @param reqVO 列表
* @return 列表
*/
- List getConfigList(SysConfigExportReqVO reqVO);
+ List getConfigList(InfConfigExportReqVO reqVO);
/**
* 获得参数配置
@@ -36,7 +36,7 @@ public interface SysConfigService {
* @param id 配置编号
* @return 参数配置
*/
- SysConfigDO getConfig(Long id);
+ InfConfigDO getConfig(Long id);
/**
* 根据参数键,获得参数配置
@@ -44,7 +44,7 @@ public interface SysConfigService {
* @param key 配置键
* @return 参数配置
*/
- SysConfigDO getConfigByKey(String key);
+ InfConfigDO getConfigByKey(String key);
/**
* 创建参数配置
@@ -52,14 +52,14 @@ public interface SysConfigService {
* @param reqVO 创建信息
* @return 配置编号
*/
- Long createConfig(SysConfigCreateReqVO reqVO);
+ Long createConfig(InfConfigCreateReqVO reqVO);
/**
* 更新参数配置
*
* @param reqVO 更新信息
*/
- void updateConfig(SysConfigUpdateReqVO reqVO);
+ void updateConfig(InfConfigUpdateReqVO reqVO);
/**
* 删除参数配置
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/config/impl/SysConfigServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/infra/service/config/impl/InfConfigServiceImpl.java
similarity index 54%
rename from src/main/java/cn/iocoder/dashboard/modules/system/service/config/impl/SysConfigServiceImpl.java
rename to src/main/java/cn/iocoder/dashboard/modules/infra/service/config/impl/InfConfigServiceImpl.java
index b4cb29747..1e2ff841c 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/config/impl/SysConfigServiceImpl.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/service/config/impl/InfConfigServiceImpl.java
@@ -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.pojo.PageResult;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigCreateReqVO;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigExportReqVO;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigPageReqVO;
-import cn.iocoder.dashboard.modules.system.controller.config.vo.SysConfigUpdateReqVO;
-import cn.iocoder.dashboard.modules.system.convert.config.SysConfigConvert;
-import cn.iocoder.dashboard.modules.system.dal.mysql.dao.config.SysConfigMapper;
-import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.config.SysConfigDO;
-import cn.iocoder.dashboard.modules.system.enums.config.SysConfigTypeEnum;
-import cn.iocoder.dashboard.modules.system.service.config.SysConfigService;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigCreateReqVO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigExportReqVO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigPageReqVO;
+import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigUpdateReqVO;
+import cn.iocoder.dashboard.modules.infra.convert.config.InfConfigConvert;
+import cn.iocoder.dashboard.modules.infra.dal.mysql.dao.config.InfConfigMapper;
+import cn.iocoder.dashboard.modules.infra.dal.mysql.dataobject.config.InfConfigDO;
+import cn.iocoder.dashboard.modules.infra.enums.config.InfConfigTypeEnum;
+import cn.iocoder.dashboard.modules.infra.service.config.InfConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -18,64 +18,64 @@ import javax.annotation.Resource;
import java.util.List;
-import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
+import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.*;
/**
* 参数配置 Service 实现类
*/
@Service
@Slf4j
-public class SysConfigServiceImpl implements SysConfigService {
+public class InfConfigServiceImpl implements InfConfigService {
@Resource
- private SysConfigMapper configMapper;
+ private InfConfigMapper configMapper;
@Override
- public PageResult getConfigPage(SysConfigPageReqVO reqVO) {
+ public PageResult getConfigPage(InfConfigPageReqVO reqVO) {
return configMapper.selectPage(reqVO);
}
@Override
- public List getConfigList(SysConfigExportReqVO reqVO) {
+ public List getConfigList(InfConfigExportReqVO reqVO) {
return configMapper.selectList(reqVO);
}
@Override
- public SysConfigDO getConfig(Long id) {
+ public InfConfigDO getConfig(Long id) {
return configMapper.selectById(id);
}
@Override
- public SysConfigDO getConfigByKey(String key) {
+ public InfConfigDO getConfigByKey(String key) {
return configMapper.selectByKey(key);
}
@Override
- public Long createConfig(SysConfigCreateReqVO reqVO) {
+ public Long createConfig(InfConfigCreateReqVO reqVO) {
// 校验正确性
checkCreateOrUpdate(null, reqVO.getKey());
// 插入参数配置
- SysConfigDO config = SysConfigConvert.INSTANCE.convert(reqVO);
- config.setType(SysConfigTypeEnum.CUSTOM.getType());
+ InfConfigDO config = InfConfigConvert.INSTANCE.convert(reqVO);
+ config.setType(InfConfigTypeEnum.CUSTOM.getType());
configMapper.insert(config);
return config.getId();
}
@Override
- public void updateConfig(SysConfigUpdateReqVO reqVO) {
+ public void updateConfig(InfConfigUpdateReqVO reqVO) {
// 校验正确性
checkCreateOrUpdate(reqVO.getId(), null); // 不允许更新 key
// 更新参数配置
- SysConfigDO updateObj = SysConfigConvert.INSTANCE.convert(reqVO);
+ InfConfigDO updateObj = InfConfigConvert.INSTANCE.convert(reqVO);
configMapper.updateById(updateObj);
}
@Override
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);
}
// 删除
@@ -89,11 +89,11 @@ public class SysConfigServiceImpl implements SysConfigService {
checkConfigKeyUnique(id, key);
}
- private SysConfigDO checkConfigExists(Long id) {
+ private InfConfigDO checkConfigExists(Long id) {
if (id == null) {
return null;
}
- SysConfigDO config = configMapper.selectById(id);
+ InfConfigDO config = configMapper.selectById(id);
if (config == null) {
throw ServiceExceptionUtil.exception(CONFIG_NOT_FOUND);
}
@@ -101,7 +101,7 @@ public class SysConfigServiceImpl implements SysConfigService {
}
private void checkConfigKeyUnique(Long id, String key) {
- SysConfigDO config = configMapper.selectByKey(key);
+ InfConfigDO config = configMapper.selectByKey(key);
if (config == null) {
return;
}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/service/package-info.java b/src/main/java/cn/iocoder/dashboard/modules/infra/service/package-info.java
new file mode 100644
index 000000000..310528922
--- /dev/null
+++ b/src/main/java/cn/iocoder/dashboard/modules/infra/service/package-info.java
@@ -0,0 +1 @@
+package cn.iocoder.dashboard.modules.infra.service;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/config/SysConfigConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/config/SysConfigConvert.java
deleted file mode 100644
index be88834c6..000000000
--- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/config/SysConfigConvert.java
+++ /dev/null
@@ -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 convertPage(PageResult page);
-
- SysConfigRespVO convert(SysConfigDO bean);
-
- SysConfigDO convert(SysConfigCreateReqVO bean);
-
- SysConfigDO convert(SysConfigUpdateReqVO bean);
-
- List convertList(List list);
-
-}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java
index f94ff789b..1bbde5784 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java
@@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.system.enums;
import cn.iocoder.dashboard.common.exception.ErrorCode;
/**
- * 错误码枚举类
+ * System 错误码枚举类
*
* system 系统,使用 1-002-000-000 段
*/
@@ -75,9 +75,4 @@ public interface SysErrorCodeConstants {
// ========== 文件 1002009000 ==========
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, "不允许获取敏感配置到前端");
}
diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..8a5fa5488
--- /dev/null
+++ b/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.env.EnvironmentPostProcessor=\
+ cn.iocoder.dashboard.framework.apollo.spring.boot.ApolloApplicationContextInitializer
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
index de8e890c9..8eb614f9b 100644
--- a/src/main/resources/application.yaml
+++ b/src/main/resources/application.yaml
@@ -53,6 +53,10 @@ apollo:
enabled: true # 设置 Apollo 在启动阶段生效
eagerLoad:
enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
+ jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
+ url: ${spring.datasource.url}
+ username: ${spring.datasource.username}
+ password: ${spring.datasource.password}
# MyBatis Plus 的配置项
mybatis-plus: